Psf Out-Gridview -Passthru | Restart-Service produces error
Posted: Mon Oct 07, 2019 7:42 am
Product, version and build: Powershell Studio 5.6.167.0
32 or 64 bit version of product: 64-Bit
Operating system: Win 10 Ver 1809
64 bit OS: 64-Bit
$buttonRUN_Click={
(Get-Service | where { $_.Status -eq 'Running' }) | sort | Out-GridView -outputmode Single -Title "Restart Service" | Restart-Service
# (Get-Service | where { $_.Status -eq 'Running' }) | sort | Out-GridView -Passthru -Title "Restart Service" | Restart-Service (Produces same error in
Powershell studio when running from form)
}
Produces this error (after selecting a service to restart in ogv window), when run from Powershell Studio Form (but not when running in regular Powershell window on same system):
>> Running (Confirmation.psf) Script...
>> Platform: V5 64Bit (STA) (Forced)
ERROR: Restart-Service : Service 'World Wide Web Publishing Service (W3SVC)' cannot be stopped due to the following error: Cannot open W3SVC service on computer '.'.
Confirmation.psf (867, 4): ERROR: At Line: 867 char: 4
ERROR: + Restart-Service
ERROR: + ~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : CloseError: (System.ServiceProcess.ServiceController:ServiceController) [Restart-Service], ServiceCommandException
ERROR: + FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.RestartServiceCommand
ERROR:
32 or 64 bit version of product: 64-Bit
Operating system: Win 10 Ver 1809
64 bit OS: 64-Bit
$buttonRUN_Click={
(Get-Service | where { $_.Status -eq 'Running' }) | sort | Out-GridView -outputmode Single -Title "Restart Service" | Restart-Service
# (Get-Service | where { $_.Status -eq 'Running' }) | sort | Out-GridView -Passthru -Title "Restart Service" | Restart-Service (Produces same error in
Powershell studio when running from form)
}
Produces this error (after selecting a service to restart in ogv window), when run from Powershell Studio Form (but not when running in regular Powershell window on same system):
>> Running (Confirmation.psf) Script...
>> Platform: V5 64Bit (STA) (Forced)
ERROR: Restart-Service : Service 'World Wide Web Publishing Service (W3SVC)' cannot be stopped due to the following error: Cannot open W3SVC service on computer '.'.
Confirmation.psf (867, 4): ERROR: At Line: 867 char: 4
ERROR: + Restart-Service
ERROR: + ~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : CloseError: (System.ServiceProcess.ServiceController:ServiceController) [Restart-Service], ServiceCommandException
ERROR: + FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.RestartServiceCommand
ERROR: