How to execute powershell Script from CMD
To execute PowerShell scripts in windows CMD prompt we have to use the argument -File.Example
Open Notepad and copy/paste the below code and save it as print.ps1 extension ( be very careful and try not saving it as .ps1.txt )
Write-output "hello world!"
Then open the windows command prompt and assume that the script has been saved in temp folder, give the below line for the code to execute.
powershell -File "c:\temp\print.ps1"
Now, you could try more complicated stuff in your PowerShell Script.
No comments:
Post a Comment