Im trying to write a very brief powershell script that runs a few commands, pipes their output to a text file, and then does a search against a keyword.
I cant figure out what to change however for this line:
wmic service get name, startname | out-File "$pwd\admin\wmic.txt"
WMIC.exe : Invalid GET Expression.
At \\test.ps1:7 char:5
+ wmic <<<< service get name startname | out-File "$pwd\admin\wmic.txt"
+ CategoryInfo : NotSpecified: (Invalid GET Expression.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
I believe the error is generated from the ',' as powershell uses the comma to create an array. Any thoughts or suggestions?
Thanks
wmic service get name"," startname| out-File "$pwd\admin\wmic.txt"
This is easy to resolve comma, no change at all.