0

I downloaded PS script from http://poshcode.org/2216. Whenever I try to run this script, security popup appears: "Run only scripts that you trust. While Scripts from the internet can be usefull, this script can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning message. (...)".

So I executed Unblock-File .\Send-File.ps1 but nothing changed. I also tried other variations like Get-Content .\SendFile | Unblock-File. Nothing seems to work.

Does anyone know what is the proper way to unblock PowerShell script? Thanks in advance.

Seblis
  • 339
  • 4
  • 17
  • 1
    Did you check this out? http://stackoverflow.com/questions/728143/ignore-security-warning-running-script-from-command-line – sweerpotato Sep 01 '15 at 12:27

4 Answers4

1

You can also wipe the ZoneId from the alternate data stream :

set-Content Send-File.ps1 -Stream zone.identifier -Value ''
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
1

To unblock a particular script file, Sam's answer will be ok. You also can run a script without actually unblocking it by bypassing your PowerShell execution policy explicitly. To do that execute the following console command:

powershell.exe -ExecutionPolicy Bypass .\Send-File.ps1

... and the script will start

Dmitry VS
  • 605
  • 5
  • 14
0

Right-click the downloaded script, select properties and unblock.

sweerpotato
  • 470
  • 2
  • 11
  • 22
0

By default the downloaded PS script will be treated as unsafe. You need to set Powershell's execution policy to bypass the security check for this particular file.

To do that, execute:

Set-ExecutionPolicy Bypass -File (...)

(Note that it is possible to run the above command with no File specified, which globally sets the execution policy to bypass the security check; we do not recommend you do that!)

Sam Holloway
  • 1,999
  • 15
  • 14
  • In PS versions i checked there is no `File` parameter for `Set-ExecutionPolicy` cmdlet. I am using v4.0. – Seblis Sep 04 '15 at 14:25