6

I suddenly started to recceive this warning when running any script on my computer:

Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer...

Screenshot:

Powershell Security Warning

The files are not blocked.

I have

  • checked in File Explorer > Properties.
  • used the Unblock-File cmdlet to unblock as well.
  • checked streams using cmdlet: Get-Content -Path '\\Path\Script.ps1' -Stream Zone.Identifier. No Streams found.
  • used Streams.exe from Sysinternals: streams.exe -d \\Path\Script.ps1. No files with streams found.

Also tried to remove streams with Powershell:

Remove-Item -Path \\Path\Script.ps1 -Stream Zone.Identifier

Of course without success as there are no streams.

Execution policy is Unrestricted.

When I run Set-ExecutionPolicy Bypass it works without warning. It should, however, also work when it's unrestricted.

I honestly don't know what's going on.

ATur
  • 117
  • 1
  • 2
  • 7

4 Answers4

9

After searching i found someone with similar issues and it was explained that Classic UNC paths will work without prompting to unblock the file:

\\Servername\Path...

However FQDN paths are not seen as safe by default and will prompt:

\\Servername.foo.local\Path...

My own testing confirms this to be correct as removing the .foo.local from the path causes the Unblock-File prompts to stop.

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Backlash52
  • 106
  • 1
  • 4
0

LGPE > gpedit.msc

Computer Configuration > Administrative Templates, > Windows Components, > Internet Explorer>expand Internet Control Panel. Security Page > Intranet Sites: Include all local (intranet) sites not listed in other zones, and then click Properties. Click Enabled.

Turn on automatic detection of the intranet, and then click Properties. Click Disabled, and then click OK.

or registry

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\"UNCAsIntranet" = "0"
DisplayName
  • 1,008
  • 10
  • 24
0

The correct registry keys, name and value, to treat all local sites as part of the intranet zone, are:

Keys:

HKLM\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap
HKCU\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap

Name:  IntranetName
Type:  DWORD
Value: 1

You can set this via PowerShell for the local machine (in an elevated prompt) like this:

Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap" -Name "IntranetName" -Type DWord -Value 1

See Intranet Sites: Include all local (intranet) sites not listed in other zones for more information about the group policy.

lauxjpn
  • 4,749
  • 1
  • 20
  • 40
-3

PS doesnot allow Scripts to run on system ENV by default. you need to set the policy to unrestricted or remote signed Use: Set-ExecutionPolicy Remotesigned OR Set-ExecutionPolicy Unrestricted

Open the PS console and type this and press enter and then try running your script.

A Nikhade
  • 17
  • 4
  • 2
    he says Execution policy is Unrestricted it means No restrictions; all Windows PowerShell scripts can be run. https://technet.microsoft.com/en-us/library/ee176961.aspx – DisplayName Jul 26 '16 at 09:03
  • My execution policy is Unrestricted. When changing execution policy to Bypass I don't receive the warning anymore. It should, however, also work when it is Unrestricted. – ATur Jul 27 '16 at 09:23
  • so setting execution policy bypass fixed the issue only on current session or all? – DisplayName Jul 27 '16 at 11:08