I want to call PowerShell command from cmd. For example, let it be get-content.
OK, my case will be
powershell -command <string> [<CommandParameters>]
In my case it will looks like
powershell -command "& {get-content <???>}" <filepath>
But it doesn't works. I can't understand how to pass cmd arg <filepath> into the command string "& {get-content <???>}".
powershell -command " #PasteCodeHere ". So, in your case, it should bepowershell -command "Get-Content 'c:\temp\textfile.txt' ". No need to use the&, only when running against a file.powershell -command "& 'C:\Temp\myps.ps1'"cmd. Is there only one way to do it - use externalps1file? Looks lame.