Run A Script In PowerShell?
- 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\ (enter)
- Execute the script:
PS> .\run_import_script.ps1 (enter)
If it fails, you should check “setexecutionpolicy”
- Launch a Windows PowerShell window run as an administrator.
- Navigate to the location where the reactivateUsers.ps1 is located on the central node.
- Update the PowerShell execution policy on the system to allow the script to run.
In the PowerShell window, enter set-executionpolicy unrestricted.
The system will prompt to confirm the change.
Enter the letter “Y” or press the enter key to change the execution policy setting.
PowerShell’s execution policy settings dictate what PowerShell scripts can be run on a Windows system. To run the reactivateUsers script, the execution policy needs to be changed.
- Run the PowerShell script reactivateUsers.ps1. PowerShell requires specifying a path with the script in order to run. If the PowerShell window is in the current directory of the script _._ can be used for specifying the current path. Assuming the PowerShell window is in the directory where reactivateUsers.ps1, enter .\reactivateUsers.ps1 to run the script.
- Set the execution policy back to the value it was before running the script using the set-executionpolicy commandlet.
- And you’re done!
What am I missing??
Or: you can run the PowerShell script from cmd.exe like this:
powershell -noexit “& “”C:\my_path\run_import_script.ps1″”” (enter)