Как запустить / остановить несколько служб на удаленной машине с помощью powershell
HI i wrote some script for stop and start for a single service .. #Change this values to suit your needs: $SvcName = 'Spooler' $SvrName = 'remotePC' #Initialize variables: [string]$WaitForIt = "" [string]$Verb = "" [string]$Result = "FAILED" $svc = (get-service -computername $SvrName -name $SvcName) Write-host "$SvcName on $SvrName is $($svc.status)" Switch ($svc.status) { 'Stopped' { Write-host "Starting $SvcName..." Write-host "$SvcName is started" $Verb = "start" $WaitForIt = 'Running' $svc.Start()} 'Running' { Write-host "Stopping $SvcName..." Write-host "$SvcName is stopped" $Verb = "stop" $WaitForIt = 'Stopped' $svc.Stop()} Default { Write-host "$SvcName is $($svc.status). Taking no action."} } this script is fine for stop/start for one windows servcie . but i want to start/stop multiple services at a time in one server . plz help some one
Что я уже пробовал:
я попробовал для одной службы, она успешно работает, и я хочу остановить/запустить несколько служб одновременно .