Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://www.reddit.com/r/PowerShell/comments/47lvkb/function_getiezone_gets_activex_settings_and_more/
- function Get-IEZone-setlookup ($keything) {
- # 1A00 Excluded
- $KeyArray = '1001','1004','1200','1201','1206','1208','1209','1400','1402','1405','1605','1609','1803','1809','2000','2200','2201','2700','270C'
- if ($KeyArray -contains $Keything) {
- switch ($Keything) {
- '1001' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Download signed ActiveX controls'
- }}# ACTX:Download signed ActiveX controls
- '1004' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Download unsigned ActiveX controls'
- }}# ACTX:Download unsigned ActiveX controls
- '1200' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Run ActiveX controls and plug-ins'
- }}# ACTX:Run ActiveX controls and plug-ins
- '1201' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Initialize and script ActiveX controls not marked as safe for scripting'
- }}# A CTX:Initialize and script ActiveX controls not marked as safe for scripting
- '1206' {[pscustomobject][ordered]@{
- Category = 'Miscellaneous'
- Description = 'Allow scripting of Internet Explorer Web browser control'
- }}# MISC:Allow scripting of Internet Explorer Web browser control ^
- '1208' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Allow previously unused ActiveX controls to run without prompt'
- }}# ACTX:Allow previously unused ActiveX controls to run without prompt ^
- '1209' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Allow Scriptlets'
- }}# ACTX:Allow Scriptlets
- '1400' {[pscustomobject][ordered]@{
- Category = 'Scripting'
- Description = 'Active scripting'
- }}# SRPT:Active Scripting
- '1402' {[pscustomobject][ordered]@{
- Category = 'Scripting'
- Description = 'Scripting of Java applets'
- }}# SRPT:Scripting of Java applets
- '1405' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Script ActiveX controls marked as safe for scripting'
- }}# ACTX:Script ActiveX controls marked as safe for scripting
- '1605' {[pscustomobject][ordered]@{
- Category = 'Admin'
- Description = 'Run Java'
- }}# ADMN:Run Java #
- '1609' {[pscustomobject][ordered]@{
- Category = 'Miscellaneous'
- Description = 'Display mixed content'
- }}# MISC:Display mixed content *
- '1803' {[pscustomobject][ordered]@{
- Category = 'Downloads'
- Description = 'File Download'
- }}# DOWN:File downloads ^
- '1809' {[pscustomobject][ordered]@{
- Category = 'Miscellaneous'
- Description = 'Use Pop-up Blocker'
- }}# MISC:Use Pop-up Blocker ** ^
- '1A00' {[pscustomobject][ordered]@{
- Category = 'Authentication'
- Description = 'Logon'
- }}# USER:Logon
- '2000' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Binary and script behaviors'
- }}# ACTX:Binary and script behaviors
- '2200' {[pscustomobject][ordered]@{
- Category = 'Downloads'
- Description = 'Automatic prompting for file downloads'
- }}# DOWN:Automatic prompting for file downloads ** ^
- '2201' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Automatic prompting for ActiveX controls'
- }}# ACTX:Automatic prompting for ActiveX controls ** ^
- '2702' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Allow ActiveX Filtering'
- }}# ACTX:Allow ActiveX Filtering
- '270C' {[pscustomobject][ordered]@{
- Category = 'ActiveX'
- Description = 'Run Antimalware software on ActiveX controls'
- }}# ACTX:Run Antimalware software on ActiveX controls
- default { $null }
- }
- }
- # * indicates an Internet Explorer 6 or later setting
- # ** indicates a Windows XP Service Pack 2 or later setting
- # # indicates a setting that is not displayed in the user interface in Internet Explorer
- # ^ indicates a setting that only has two options, enabled or disabled
- }
- function Get-IEZone {
- [cmdletbinding(defaultparametersetname = 'Level_HKCU')]
- param(
- [Parameter(ParameterSetName = 'Level_HKLM',
- Mandatory = $true,
- Position = 0)]
- [Parameter(ParameterSetName = 'Level_HKU',
- Mandatory = $true,
- Position = 0)]
- [Parameter(ParameterSetName = 'Level_HKCU',
- Mandatory = $true,
- Position = 0)]
- [ValidateSet('Internet', 'Intranet', 'Trusted', 'Restricted')]
- [string]$Zone,
- [Parameter(ParameterSetName = 'Level_HKLM',
- Mandatory = $false,
- Position = 1)]
- [switch]$LocalMachine,
- [Parameter(ParameterSetName = 'Level_HKCU',
- Mandatory = $false,
- Position = 1)]
- [switch]$CurrentUser,
- [Parameter(ParameterSetName = 'Level_HKU',
- Mandatory = $false,
- Position = 1)]
- [string[]]$User)
- begin {
- $dWordNAME = $dWordVALUE = $requesttxt = $openZone = $ZoneSetsRAW = $null
- $userpath = $userRAW = $userfound = $UserSID = $null
- $regex1 = [regex]'[0-Z]{4}'
- $ZoneID = $null
- $settingsOUT = New-Object System.Collections.ArrayList
- switch ($zone) {
- 'Internet' {$ZoneID = 3}
- 'Intranet' {$zoneID = 1}
- 'Trusted' {$ZoneID = 2}
- 'Restricted'{$ZoneID = 4}
- }
- $set = $PSCmdlet.ParameterSetName
- switch ($set) {
- 'Level_HKLM' {$openBase_HKLM = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::default)}
- 'Level_HKCU' {$openBase_HKCU = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::CurrentUser, [Microsoft.Win32.RegistryView]::default)}
- 'Level_HKU' {$openBase_HKU = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::Users, [Microsoft.Win32.RegistryView]::default)}
- }
- }
- process {
- switch ($set) {
- 'Level_HKLM' {
- $ZoneSetsRAW = New-Object System.Collections.ArrayList
- $requesttxt = "`
- Zone: $zone | LOCAL MACHINE"
- $openZone = $openBase_HKLM.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\$ZONEID")
- foreach ($dWordNAME in $openZone.GetValueNames()) {
- if ($dWordName -match $regex1) {
- $dWordVALUE = $openZone.GetValue($dWordNAME)
- $ZoneSetsRAW.Add([pscustomobject][ordered]@{
- Name = $dWordNAME
- Value = $dWordVALUE
- }) | Out-Null
- }
- }
- foreach ($rec in $ZoneSetsRAW) {
- if ($rec.name -match $regex1) {
- $SetDESC = Get-IEZone-setlookup $rec.name
- $TranslatedValue = $(switch ($rec.value) {
- 0 {'Enabled'}
- 1 {'Prompt'}
- 3 {'Disabled'}
- })
- if ($SetDESC -ne $null) {
- $settingsOUT.Add([pscustomobject][ordered]@{
- Zone = $Zone
- User = 'LOCAL MACHINE'
- Category = $SetDESC.category
- Value = $TranslatedValue
- Description = $SetDESC.Description
- }) | Out-Null
- }
- }
- }
- }
- 'Level_HKCU' {
- $ZoneSetsRAW = New-Object System.Collections.ArrayList
- $requesttxt = "`
- Zone: $zone | Current User: $env:username"
- $openZone = $openBase_HKCU.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\$ZONEID")
- foreach ($dWordNAME in $openZone.GetValueNames()) {
- if ($dWordName -match $regex1) {
- $dWordVALUE = $openZone.GetValue($dWordNAME)
- $ZoneSetsRAW.Add([pscustomobject][ordered]@{
- Name = $dWordNAME
- Value = $dWordVALUE
- }) | Out-Null
- }
- }
- foreach ($rec in $ZoneSetsRAW) {
- if ($rec.name -match $regex1) {
- $SetDESC = Get-IEZone-setlookup $rec.name
- $settings = $null
- $TranslatedValue = $(switch ($rec.value) {
- 0 {'Enabled'}
- 1 {'Prompt'}
- 3 {'Disabled'}
- })
- if ($SetDESC -ne $null) {
- $settingsOUT.Add([pscustomobject][ordered]@{
- Zone = $Zone
- User = $env:username
- Category = $SetDESC.category
- Value = $TranslatedValue
- Description = $SetDESC.Description
- }) | Out-Null
- }
- }
- }
- }
- 'Level_HKU' {
- $userpath = $null
- $requesttxt = "`
- Zone: $Zone | User: $USER"
- $UserNameList = New-Object System.Collections.ArrayList
- foreach ($subkey in $openBase_HKLM.OpenSubKey('Software\\Microsoft\\Windows NT\\CurrentVersion\\profilelist').GetSubkeyNames()) {
- $userpath = $openBase_HKLM.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\profilelist\\$subkey").GetValue('ProfileImagePath')
- if ($userpath -notlike ('C:\Windows*')) {
- $userRAW = $userpath -split ('\\')
- $userfound = $userRAW[2]
- $UserNameList.Add([pscustomobject][ordered]@{
- Username = $userfound
- SID = $subkey
- }) | Out-Null
- }
- }
- if ($usernamelist.Username -eq $USER) {
- $UserSID = $usernamelist | Where {$_.Username -eq $user} | Select -ExpandProperty SID
- $ZoneSetsRAW = New-Object System.Collections.ArrayList
- $openZone = $openBase_HKU.OpenSubKey("$UserSID\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\$ZONEID")
- try {
- foreach ($dWordNAME in $openZone.GetValueNames()) {
- if ($dWordName -match $regex1) {
- $dWordVALUE = $openZone.GetValue($dWordNAME)
- $ZoneSetsRAW.Add([pscustomobject][ordered]@{
- Name = $dWordNAME
- Value = $dWordVALUE
- }) | Out-Null
- }
- }
- } catch {
- Write-Warning "User SID not found in REG lookup"
- }
- foreach ($rec in $ZoneSetsRAW) {
- $settings = $SetDESC = $null
- if ($rec.name -match $regex1) {
- $SetDESC = Get-IEZone-setlookup $rec.name
- $TranslatedValue = $(switch ($rec.value) {
- 0 {'Enabled'}
- 1 {'Prompt'}
- 3 {'Disabled'}
- })
- if ($SetDESC -ne $null) {
- $settingsOUT.Add([pscustomobject][ordered]@{
- Zone = $Zone
- User = $User
- Category = $SetDESC.category
- Value = $TranslatedValue
- Description = $SetDESC.Description
- }) | Out-Null
- }
- }
- }
- } else {
- Write-Warning 'User Not Found'
- }
- }
- }
- }
- end {
- #Write-Host $requesttxt -ForegroundColor Cyan
- Write-Output $settingsOUT | sort -Property Category, Value
- }
- }
Add Comment
Please, Sign In to add comment