I want to run a few PowerShell commands through a batch file. Very similar question has been asked but I dont want to run a seperate shell file from a batch. Instead I want to embed PowerShell commands to a batch file.
When I try to run
powershell -command "&{$var = "something"}"
I get the following error:
something : The term 'something' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:10
&{$var = something}
CategoryInfo : ObjectNotFound: (something:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
But if I run something like
powershell -command "&{echo "something"}"
Then everything is fine :/
Am I doing a syntax error or something? And please don't give answers like "Instead of using PowerShell commands use batch commands etc..."
Thanks in advance!