Up 2 Down 0

Add network share to trusted locations

# Add the network location to Trusted Sites
$networkLocation = "file://san001"

# Retrieve the current Trusted Sites list
$trustedSites = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges" -ErrorAction SilentlyContinue

# Check if the network location is already in the Trusted Sites list
$exists = $false
foreach ($key in $trustedSites.PSObject.Properties) {
    if ($key.Value -match $networkLocation) {
        $exists = $true
        break
    }
}

# If the network location is not in the Trusted Sites list, add it
if (-not $exists) {
    New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "http" -Value "$networkLocation" -PropertyType String
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "https" -Value "$networkLocation" -PropertyType String
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "file" -Value "$networkLocation" -PropertyType String
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "ProxyBypass" -Value 0 -PropertyType DWord
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "IntranetName" -Value 1 -PropertyType DWord
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" -Name "UNCAsIntranet" -Value 1 -PropertyType DWord
}

# Modify registry settings to disable the warning
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments"
Set-ItemProperty -Path $registryPath -Name "SaveZoneInformation" -Value 1

# You may need to restart the Explorer process for changes to take effect
Stop-Process -Name explorer -Force
Start-Process explorer