powershell - How can I use Psconsole.psc1 -Command Get-{anything} -
i working powershell scripts executed way:
ps c:\long\path\to\psconsole.psc1 -command {get-whatever...}
they generate error:
you must provide value expression on right hand side of value '-' operator.
*
here's example:
ps c:\> "c:\program files\common files\microsoft shared\web server extensions\14\config\powershell\registration\psconsole.psc1" -command "get-service"
same error message:
`you must provide value expression on right hand side of value '-' operator.` ... @ line 1... - <<< command "get-service" + categoryinfo: pasererror: (:) [], parentcontainserrorrecordexception + fullyqualifiederror: expectedvalueexpression
can tell me way -command working?
by enclosing path in quotes, you're telling powershell string , - before "-command" interpreted operator not parameter.
to around this, prefix statement "call" operator "&":
& "c:\program files\common files\microsoft shared\web server extensions\14\config\powershell\registration\psconsole.psc1" -command "get-service"
edit: if use tab key autocompletion of path, console automatically put & call operator there when sees space in full path.
Comments
Post a Comment