Monday, March 29, 2010

Powershell warning prompts

Scenario:
I downloaded some powershell commandlets from web and while trying to execute them. I got the following warning

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:\moss-script-collection\Get-XYZ.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"):


Solution:
This is because of in-build security of Powershell to block files downloaded from untrusted locations including World Wide Web.

If you really trust the source and script and want to run the script , you can choose from one of the optioned mentioned but If you need to run this script often and you dont want this propmpt to bug you again and again then ---

Steps:
1. Create a new file with ps1 extension i.e. newFile.ps1
2. Open the file you downloaded from WWW and copy all the content
3. Paste it now to newFile.ps1 file
4. Use the newFile.ps1 going forward it will work without prompting

As you see this was just a workaround, there are other ways also to make the original file work rather than creating a new one. But I found this one easier :)

0 comments: