#Alan dot Kaplan at VA dot Gov #12-16-14, 12-24-14 #Script to display contents of IE Zones as set by administrator in HKLM #This requires Out-Gridview which is installed with v2 and ISE or v3 or later #WMI read code loosely based on post by Ken Sweet #at http://powershell.org/wp/forums/topic/wmi-registry-syntax/ [long]$HKLM = 2147483650 Add-Type -assemblyname Microsoft.visualBasic $Computer = [Microsoft.VisualBasic.Interaction]::InputBox("Enter computername to check HKLM IE Zones", "Name", "$env:computername") if ($Computer.Length -eq 0){Exit} #Script requires admin permissions. Show errors if can't reach remote WMI Try{ $RegProv = [WMIClass]"\\$Computer\Root\Default:StdRegProv" }catch{ Write-Warning $Error[0].Exception.Message exit } $Sub_key = 'SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey' $Values = $RegProv.EnumValues($HKLM, $Sub_key) if ($Values.ReturnValue -eq 0) { $Total = $Values.sNames.Count Write "Found $Total zone settings in HKLM on $computer" # Loop Throught All found Values $ZoneData=For ($Count=0; $Count -lt $Total; $Count++) { $ValueName = $Values.sNames[$Count] $RegValue = $RegProv.GetStringValue($HKLM, $Sub_key, $ValueName) # Make Sure No Error when Reading Registry if ($RegValue.ReturnValue -eq 0) { # String, Multi-String, and Expanded String Values New-Object -TypeName PSObject -Property @{"Hive"=$Hive; "Key"=$Sub_key; "Value"=$ValueName; "DataType"=$ValueType; "Data"=$RegValue.sValue} } } } ELSE{ Write-Warning Could Not read $Sub_key } $ZoneData | sort data, value | select @{Name="Zone";Expression={ switch ($_."data") { 0 {"My Computer"} 1 {"Local Intranet Zone"} 2 {"Trusted sites Zone"} 3 {"Internet Zone"} 4 {"Restricted Sites Zone"} } } },@{Name="Entry";Expression={$_."Value"}} | Out-GridView -PassThru -Title "Zone Information from HKLM on $computer. Selected items will go to the clipboard on clicking `'Ok`' " | clip