(e.g. powershell -command "& 'c:\scripts\VMBackup.ps1'" > c:\vmbackup.log)
my program reports that the service couldn't be stopped. I looked at the
vmbackup.log file but it doesn't contain any reason why this would happen.
My initial thought is that there is a problem with security and the user
that is being used for the execution of my script outside of PowerGUI.
Can anyone point me in the direction to figure out why the service will stop
when running the script inside my editor but not outside my editor?
Thanks.
How exactly are you running it again? Your subject mentions "runas".
Are you trying to run it with different credentials?
Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp
PowerGadgets MVP
http://www.powergadgets.com/mvp
Thanks.
So, I'm assuming you aren't running that *exact* same command within
PowerGui?
From DOS, if you do powershell /?, you don't seem to be following the
proper syntax, which should actually be something like:
PowerShell -Command "& {Get-EventLog -LogName security}"
Thanks.
OK, I just tried your syntax and it works fine also.
What OS? Vista? How are you starting PowerGUI? If Vista, you're
starting it elevated?
Marco
Odd from my viewpoint.
What happens if:
1. You open a DOS window and run it (not just from Start->Run)?
2. You open a PowerShell window and run it?
Run this of course as is: "powershell -command "&
1. Run from a command prompt the script appeared to start running but then
failed.
2. Opened Windows Powershell and ran from PS prompt. This works fine.
I've added a couple of command line arguments since we started this
conversation so now the command looks like:
powershell -command "& 'c:\scripts\VMBackup.ps1' ParmA ParmB ParmC" >
E:\VMBackup.log
Thanks.