powershellpowershell-2.0

How to run a Powershell script from the command line and pass a directory as a parameter


PowerShell -Command .\Foo.ps1


I then tried to call it specifying the full path to the script file, but no matter what I try, I can't get it to work. I believe I have to quote the path because it contains whitespaces, as does the file name I need to pass in an argument to the script.


Solution

  • try this:

    powershell "C:\Dummy Directory 1\Foo.ps1 'C:\Dummy Directory 2\File.txt'"