The other day I was trying to execute a modified version of Alan Renouf’s vCheckv5 PowerShell script on a vCenter server. usually before running PowerShell scripts locally on a server I made sure that the ExecutionPolicy is set to RemoteSigned at least. In this case I set it to an even lower security level, that is Unrestricted as shown below:
I noticed that even thought I had set the ExecutionPolicy to Unrestricted the script would still pop up with a security warning message as shown below:
For your information the script was copied over to the vCenter server from a remote file server. You may say so what? That’s not a big deal! But actually it does have an impact on the execution of this PowerShell script locally on the server.
Here is a simple fix to solve my issue. Open up your PowerShell script with your favorite editor, in my case I used Notepad. then select all and copy it. Next, locally on the server where you will run the script, create a new text document and paste the content of the clipboard in it. Now save the file with a proper name and a .PS1 extension of course.
Re-run VMware vSphere PowerCLI, and launch your new locally created script… No more warnings! Job done🙂
Now what was my issue here? My script was copied from a remote file server and NOT created/written locally. PowerShell flags it as an unsecure script and therefore pops up a warning message.
Let me paste here an overview of the policy levels available in PowerShell:
Restricted: Individual cmdlets can run, but not saved Powershell scripts. This is the default setting.
AllSigned: Scripts can run, but must have a digital signature even if written on the local computer. Prompts you before running scripts from trusted publishers.
RemoteSigned: Scripts written on the local computer do not need a digital signature, but any script downloaded from outside (email, IM, Internet) must have a signature to execute.
Unrestricted: Any script can run, but scripts downloaded from outside will run with a warning.