Hi,
I'm a newbie to powershell and I'm trying to get the user name for an installed service. When I execute the Get-WmiObject command from powershell everything works. However I need to execute it from a command prompt (calling it from Java). When I do that, the command fails.
Here is the command (substitute a real service name for MyService):
Powershell.exe -ExecutionPolicy ByPass Invoke-Command -ScriptBlock { Get-WmiObject -Query "select startname from win32_service where name='MyService'" }
I get the following error:
Get-WmiObject : A positional parameter cannot be found that accepts argument 'startname'.
I don't understand why this fails. I've tried placing " around the Get-WmiObject command. -Query is not a positional parameter and the query is in ". I'm not sure what's wrong.
Thanks,
-Mike