It happends because your script is not signed. You have two optinos at this point, Sign your scripts or set your computers policy to run unsigned scripts.
all signing a script does is digitally sign off on it saying that its legit and you want to run it. i prefer not to do this, as it just takes too long to do any actual real work. if you work in a large corporate environment you might need to though.
your first move would be to run the command:
Set-ExecutionPolicy Unrestricted
but its going to fail since we arent running PS as an admin.
PS C:\Users\Matt\Desktop> Set-ExecutionPolicy Unrestricted
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 at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
Set-ExecutionPolicy : Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution
policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option. To
change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
At line:1 char:1
+ Set-ExecutionPolicy Unrestricted
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyComma
nd
PS C:\Users\Matt\Desktop>
close this instance of PS and run a new one, as admin. (Right click on your shortcut and click run as administrator.)
All done!!!
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.
PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted
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 at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
PS C:\WINDOWS\system32>
No comments:
Post a Comment