Actually, this is an issue with PowerShell and not PowerCLI. When a script is downloaded via Internet Explorer from the Internet or an Intranet, a NTFS Alternative Data Stream is added to the file with a Zone Identifier, indicating the file’s origin. These scripts are unsigned, and thus untrusted.
PowerCLI C:\vCheck-vSphere-master> .\vCheck.ps1 Security Warning Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run C:\vCheck-vSphere-master\Styles\Default\Style.ps1? [D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): D |
To resolve this, Right-click on PowerCLI > Run as Administrator:
PowerCLI C:\> Get-ExecutionPolicy Unrestricted PowerCLI C:\> Set-ExecutionPolicy bypass 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 policy? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y |
References
- http://theitbros.com/run-only-scripts-that-you-trust-powershell/
- http://www.hanselman.com/blog/RemovingSecurityFromDownloadedPowerShellScriptsWithAlternativeDataStreams.aspx
- http://blogs.msdn.com/b/powershell/archive/2008/09/30/powershell-s-security-guiding-principles.aspx?Redirected=true
- http://stackoverflow.com/questions/728143/ignore-security-warning-running-script-from-command-line
- http://www.leeholmes.com/blog/2007/11/20/3rd-parties-and-powershell-execution-policies/