Launch Windows PowerShell, and wait a moment for the PS command prompt to appear
Navigate to the directory where the script lives
- PS> cd C:\my_path\yada_yada\ (enter)
- Execute the script:
- PS> .\run_import_script.ps1 (enter)
Or: you can run the PowerShell script from cmd.exe like this:
powershell -noexit "& ""C:\my_path\yada_yada\run_import_script.ps1""" (enter)
If you are on PowerShell 2.0, use PowerShell.exe’s -File parameter to invoke a script from another environment, like cmd.exe. For example:
Powershell.exe -File C:\my_path\yada_yada\run_import_script.ps1
If you want to run a script without modifying the default script execution policy, you can use the bypass switch when launching Windows PowerShell.
powershell [-noexit] -executionpolicy bypass -File <Filename>
Additional Resources:
Operating Systems and You: Becoming a Power User
References:
https://stackoverflow.com/questions/2035193/how-to-run-a-powershell-script
https://www.codeproject.com/Articles/18409/Asynchronously-Execute-PowerShell-Scripts-from-C
Other Dev posts:
Discussion (0)