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:
Psf Out-Gridview -Passthru | Restart-Service produces error
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
Ah! I see now. Let's take a look at this issue and get back to you.
Thanks
Thanks
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
OK! The issue you're experiencing is due to admin rights.
You need to open PowerShell Studio as an Administrator in order for the restart service to work in the form.
You need to open PowerShell Studio as an Administrator in order for the restart service to work in the form.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
This is usually a permission problem and sounds similar to this:
https://serverfault.com/questions/35742 ... powershell
Your 'regular' Powershell console may run in admin mode (it is easy to miss that caption indicator), so check that.
It is also possible that the threading model interferes, but the error message points more towards permissions.
https://serverfault.com/questions/35742 ... powershell
Your 'regular' Powershell console may run in admin mode (it is easy to miss that caption indicator), so check that.
It is also possible that the threading model interferes, but the error message points more towards permissions.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
Also, you do not need to run PowerShell Studio as admin, there is a switch on the ribbon to run your scripts elevated.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
Easy to forget when you work all the time as an admin and already have control of your system.
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
Already tried, using that toggle switch (unfortunately get same error).
Also, simply just running the command in console window of Powershell Studio results in same error, just so you're aware.
Execution Policy verified as unrestricted in the Powershell Studio console window. However, strangely even with Elevated toggle on, same error.
Outside of Powershell Studio the error does not occur in Powershell Admin window.
Don't know if it helps, but even trying to set the execution policy (even though already verified it's unrestricted) in the Powershell Studio console window produces this error related to a Powershell registry key (also tried it after toggling the Elevated switch and restarting Powershell Studio):
Thanks!
Mark
Also, simply just running the command in console window of Powershell Studio results in same error, just so you're aware.
Execution Policy verified as unrestricted in the Powershell Studio console window. However, strangely even with Elevated toggle on, same error.
Outside of Powershell Studio the error does not occur in Powershell Admin window.
Don't know if it helps, but even trying to set the execution policy (even though already verified it's unrestricted) in the Powershell Studio console window produces this error related to a Powershell registry key (also tried it after toggling the Elevated switch and restarting Powershell Studio):
Thanks!
Mark
Re: Psf Out-Gridview -Passthru | Restart-Service produces error
Is anyone else able to duplicate/refute the error in this version?
Thanks
Thanks