I want to add my internal network folders to the trusted sites dynamically because Excel is blocking the macros inside them (when opening the Excel document via network folder). I want my users to be able to read and update the document as their wish, meaning that I don't want to make local copies of the file onto the user's computers every time they want to use, edit or add a macro.
Is there a way to replicate the "Internet Options -> Security -> Trusted sites -> Sites -> Add site" process using a PowerShell (or a bash) script?
CodePudding user response:
If you want to add the domain name to the trusted site list in the IE browser then you could refer to the Powershell script example below.
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains"
New-Item test.com
Set-Location test.com
New-ItemProperty . -Name http -Value 2 -Type DWORD
If you want to add the IP address to the trusted site list in the Ie browser then you could refer to the Powershell script example below.
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges"
New-Item Range1 # Modify it if it is exists#
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" #Modify the path, if you modify the Range key in line above#
New-ItemProperty . -Name ":Range" -Value "129.0.0.1"
New-ItemProperty . -Name "file" -Value 2
Note:
- If you receive an error that
A key in this path already exists
then you need to modify the key name (e.g. Range2, Range3, etc.) - After you modify the Key name(in 2nd line), you need to modify the path(in 3rd line) according to the new key name.
Further, you could modify the above example as per your requirements.