first off, powerscript is disabled by default
first off => the execution of powerscript is disabled by default. Run a powerscript for the first time on a box, and you’ll get :
File C:\psscripts\script.ps1 cannot be loaded because the execut
ion of scripts is disabled on this system. Please see “get-help about_signing”
for more details.
At line:1 char:28
+ .\script.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) , PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
query the exectionpolicy and you’ll get
PS C:\psscripts> Get-ExecutionPolicy
a good help about the executionpolicies, is, like always, built in the powerscript help.
Get-Help About_Signing | more
when you’ve decided how you want to restrict the execution of powerscript scripts (remotesigned, all signed, unrestricted) run the following command :
PS C:\psscripts> set-executionpolicy RemoteSigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust.
Changing the execution policy might expose you to the security risks described
in the about_Execution_Policies help topic. Do you want to change the execution
[Y] Yes [N] No [S] Suspend [?] Help (default is “Y”): y
more first steps into powershell can be found @ the windows powershell graphical help file found here.
now, how to run the file from the command line, start/run, vbscript, published app, …
powershell.exe -noexit & ‘q:\my scripting folder\script.ps1’