Customize Script

Use AI to customize Restart Service Safely for your specific needs

Describe Your Customization
Tell the AI how you want to modify the script. Be specific about your requirements.
Original Script
Reference the original script while customizing
PowerShell
1param(
2 [Parameter(Mandatory=$true)]
3 [string]$ServiceName,
4 [int]$TimeoutSeconds = 30
5)
6
7$service = Get-Service -Name $ServiceName -ErrorAction Stop
8$dependentServices = Get-Service -DependentServices $service.Name | Where-Object { $_.Status -eq "Running" }
9
10Write-Host "Stopping dependent services..."
11$dependentServices | Stop-Service -Force -PassThru
12
13Write-Host "Restarting $ServiceName..."
14Restart-Service -Name $ServiceName -Force -PassThru
15
16Start-Sleep -Seconds 5
17
18Write-Host "Starting dependent services..."
19$dependentServices | Start-Service -PassThru
20
21Get-Service -Name $ServiceName | Select-Object Name, Status
Customized Script
Your customized script will appear here

Describe your customization and click "Customize" to generate

Customization Tips
  • Be specific about file paths, server names, or other variables
  • Mention any error handling or logging requirements
  • Specify output format preferences (CSV, JSON, etc.)
  • Include any scheduling or automation requirements
Customize: Restart Service Safely - PowerShell Hub