howto get powershell scripts running.

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
PS C:\psscripts>

a good help about the executionpolicies, is, like always, built in the powerscript help.

Get-Help About_Signing | more

help set-executionpolicy

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’


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s