From f3f5b22090141d5240087e06f2f681facae5a40c Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Sun, 4 Oct 2020 21:30:27 +0200 Subject: [PATCH] Update --- Examples/Example-29-FindGPO0.ps1 | 2 +- Examples/Example-29-FindGPO7.ps1 | 9 + Examples/Example-34-GPOSupport.ps1 | 32 +++- GPOZaurr.psd1 | 8 +- Private/Script.GPODictionary.ps1 | 294 ++++++++++++++++++++++------- Public/Invoke-GPOZaurrSupport.ps1 | 128 +++++++++++-- 6 files changed, 377 insertions(+), 96 deletions(-) create mode 100644 Examples/Example-29-FindGPO7.ps1 diff --git a/Examples/Example-29-FindGPO0.ps1 b/Examples/Example-29-FindGPO0.ps1 index c46e0d6..358f7c8 100644 --- a/Examples/Example-29-FindGPO0.ps1 +++ b/Examples/Example-29-FindGPO0.ps1 @@ -9,4 +9,4 @@ foreach ($Key in $Output.Reports.Keys) { $Output.Reports[$Key] | ConvertTo-Excel -FilePath $Env:USERPROFILE\Desktop\EFGPOAnalysis.xlsx -ExcelWorkSheetName $Key -AutoFilter -AutoFit -FreezeTopRowFirstColumn } # Show the Excel -Start-Process "$Env:USERPROFILE\Desktop\EFGPOAnalysis.xlsx" \ No newline at end of file +Start-Process "$Env:USERPROFILE\Desktop\EFGPOAnalysis1.xlsx" \ No newline at end of file diff --git a/Examples/Example-29-FindGPO7.ps1 b/Examples/Example-29-FindGPO7.ps1 new file mode 100644 index 0000000..ae485d5 --- /dev/null +++ b/Examples/Example-29-FindGPO7.ps1 @@ -0,0 +1,9 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +$Output = Invoke-GPOZaurr -GPOPath $ENV:USERPROFILE\Desktop\GPOTestingUserAccess -Verbose #-SkipCleanup #-Type PoliciesPrinters, Policies +$Output | Format-Table * + +#$Output.Reports | Format-Table +#$Output.Reports.SecurityOptions | Format-Table +#$Output.Reports.UserRightsAssignment | Format-Table + diff --git a/Examples/Example-34-GPOSupport.ps1 b/Examples/Example-34-GPOSupport.ps1 index 320e137..e47437b 100644 --- a/Examples/Example-34-GPOSupport.ps1 +++ b/Examples/Example-34-GPOSupport.ps1 @@ -1,6 +1,8 @@ Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force -#Invoke-GPOZaurrSupport -ComputerName 'AD1' -UserName 'przemyslaw.klys' -Type HTML +Invoke-GPOZaurrSupport -ComputerName 'ad1.ad.evotec.xyz' -UserName 'EVOTEC\przemyslaw.klys' -Type NativeHTML -ForceGPResult -Verbose + +return #$Support1 = Invoke-GPOZaurrSupport -ComputerName 'AD1' -UserName 'przemyslaw.klys' -Type Object #$Support = Invoke-GPOZaurrSupport -ComputerName 'AD1' -UserName 'EVOTEC\Administrator' -Type Object #$Support.ComputerResults.ExtensionData @@ -45,11 +47,35 @@ foreach ($GpoType in @('UserResults', 'ComputerResults')) { #Add-WindowsCapability -Online -Name 'Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0' #Remove-WindowsCapability -Online -Name 'Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0' -echo %logonserver% +Write-Output %logonserver% nltest /dsgetsite nltest /dclist: $env:LOGONSERVER [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name nslookup -type=srv _ldap._tcp.ad.colmore.com. -nslookup -type=srv _ldap._tcp.birmingham._sites.dc._msdcs.ad.colmore.com. \ No newline at end of file +nslookup -type=srv _ldap._tcp.birmingham._sites.dc._msdcs.ad.colmore.com. + + +function Get-PreData { + param( + + ) + [PSCustomObject] @{ + Site = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name + } +} + +function Get-ComputerDataInformation { + [cmdletBinding()] + param( + [string] $ComputerName = $Env:COMPUTERNAME + ) + [PSCustomObject] @{ + Bios = Get-ComputerBios -ComputerName $ComputerName + Network = Get-ComputerNetwork -ComputerName $ComputerName + NetworkCard = Get-ComputerNetworkCard -ComputerName $ComputerName + } +} +Get-ComputerDataInformation -ComputerName 'AD1.AD.EVOTEC.XYZ' +#Get-ComputerNetwork -ComputerName 'AD1.AD.EVOTEC.XYZ' #| Format-Table \ No newline at end of file diff --git a/GPOZaurr.psd1 b/GPOZaurr.psd1 index c14ecb8..9bc0e2e 100644 --- a/GPOZaurr.psd1 +++ b/GPOZaurr.psd1 @@ -14,11 +14,11 @@ PSData = @{ Tags = @('Windows', 'ActiveDirectory', 'GPO', 'GroupPolicy') ProjectUri = 'https://github.com/EvotecIT/GPOZaurr' - ExternalModuleDependencies = @('ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility') + ExternalModuleDependencies = @('CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility') } } RequiredModules = @(@{ - ModuleVersion = '0.0.180' + ModuleVersion = '0.0.181' ModuleName = 'PSSharedGoods' Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe' }, @{ @@ -26,9 +26,9 @@ ModuleName = 'ADEssentials' Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f' }, @{ - ModuleVersion = '0.0.110' + ModuleVersion = '0.0.111' ModuleName = 'PSWriteHTML' Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c' - }, 'ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility') + }, 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility') RootModule = 'GPOZaurr.psm1' } \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index e6e9974..85d8f71 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -1,5 +1,5 @@ $Script:GPODitionary = [ordered] @{ - AccountPolicies = [ordered] @{ + AccountPolicies = [ordered] @{ Types = @( @{ Category = 'SecuritySettings' @@ -14,7 +14,7 @@ ConvertTo-XMLAccountPolicy -GPO $GPO } } - Audit = [ordered] @{ + Audit = [ordered] @{ Types = @( @{ Category = 'SecuritySettings' @@ -36,7 +36,7 @@ ConvertTo-XMLAudit -GPO $GPO } } - Autologon = [ordered] @{ + Autologon = [ordered] @{ # We want to process this based on other report called RegistrySettings # This is because registry settings can be stored in Collections or nested within other registry settings # The original function ConvertTo-XMLRegistryAutologon was processing it in limited ordered and potentially would skip some entries. @@ -50,7 +50,7 @@ ConvertTo-XMLRegistryAutologonOnReport -GPO $GPO } } - AutoPlay = @{ + AutoPlay = @{ Types = @( @{ Category = 'RegistrySettings' @@ -62,7 +62,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/AutoPlay Policies*' } } - Biometrics = @{ + Biometrics = @{ Types = @( @{ Category = 'RegistrySettings' @@ -75,7 +75,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Biometrics*' } } - Bitlocker = @{ + Bitlocker = @{ Types = @( @{ Category = 'RegistrySettings' @@ -88,7 +88,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/BitLocker Drive Encryption*' } } - ControlPanel = [ordered]@{ + ControlPanel = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -100,7 +100,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel' } } - ControlPanelAddRemove = [ordered]@{ + ControlPanelAddRemove = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -112,7 +112,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Add or Remove Programs' } } - ControlPanelDisplay = [ordered]@{ + ControlPanelDisplay = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -124,7 +124,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Display' } } - ControlPanelPersonalization = [ordered]@{ + ControlPanelPersonalization = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -136,7 +136,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Personalization' } } - ControlPanelPrinters = [ordered]@{ + ControlPanelPrinters = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -148,7 +148,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Printers' } } - ControlPanelPrograms = [ordered]@{ + ControlPanelPrograms = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -160,7 +160,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Programs' } } - ControlPanelRegional = [ordered]@{ + ControlPanelRegional = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -172,7 +172,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Control Panel/Regional and Language Options' } } - CredentialsDelegation = @{ + CredentialsDelegation = @{ Types = @( @{ Category = 'RegistrySettings' @@ -184,7 +184,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Credentials Delegation*' } } - CustomInternationalSettings = [ordered]@{ + CustomInternationalSettings = [ordered]@{ Types = @( @{ Category = 'RegistrySettings' @@ -196,7 +196,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Custom International Settings*' } } - Desktop = @{ + Desktop = @{ Types = @( @{ Category = 'RegistrySettings' @@ -208,7 +208,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Desktop*' } } - DnsClient = @{ + DnsClient = @{ Types = @( @{ Category = 'RegistrySettings' @@ -220,7 +220,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Network/DNS Client*' } } - DriveMapping = [ordered] @{ + DriveMapping = [ordered] @{ Types = @( @{ Category = 'DriveMapSettings' @@ -235,7 +235,7 @@ ConvertTo-XMLDriveMapSettings -GPO $GPO -SingleObject } } - EventLog = [ordered] @{ + EventLog = [ordered] @{ Types = @( @{ Category = 'SecuritySettings' @@ -250,7 +250,7 @@ ConvertTo-XMLEventLog -GPO $GPO } } - EventForwarding = @{ + EventForwarding = @{ Types = @( @{ Category = 'RegistrySettings' @@ -262,7 +262,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Event Forwarding*' } } - EventLogService = @{ + EventLogService = @{ Types = @( @{ Category = 'RegistrySettings' @@ -274,7 +274,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Event Log Service*' } } - FileExplorer = @{ + FileExplorer = @{ Types = @( @{ Category = 'RegistrySettings' @@ -286,7 +286,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/File Explorer*' } } - FolderRedirection = @{ + FolderRedirection = @{ Types = @( @{ Category = 'RegistrySettings' @@ -298,7 +298,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Folder Redirection' } } - FSLogix = @{ + FSLogix = @{ Types = @( @{ Category = 'RegistrySettings' @@ -310,7 +310,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'FSLogix' } } - GoogleChrome = @{ + GoogleChrome = @{ Types = @( @{ Category = 'RegistrySettings' @@ -326,7 +326,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Google Chrome', 'Google/Google Chrome', 'Google Chrome - Default Settings (users can override)' } } - GroupPolicy = @{ + GroupPolicy = @{ Types = @( @{ Category = 'RegistrySettings' @@ -338,7 +338,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Group Policy*' } } - InternetCommunicationManagement = @{ + InternetCommunicationManagement = @{ Types = @( @{ Category = 'RegistrySettings' @@ -350,7 +350,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Internet Communication Management*' } } - InternetExplorer = @{ + InternetExplorer = @{ Types = @( @{ Category = 'RegistrySettings' @@ -362,7 +362,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Internet Explorer*', 'Composants Windows/Celle Internet Explorer' } } - InternetExplorerZones = [ordered] @{ + InternetExplorerZones = [ordered] @{ ByReports = @( @{ Report = 'RegistrySettings' @@ -373,7 +373,7 @@ ConvertTo-XMLRegistryInternetExplorerZones -GPO $GPO } } - KDC = @{ + KDC = @{ Types = @( @{ Category = 'RegistrySettings' @@ -385,7 +385,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/KDC' } } - LAPS = @{ + LAPS = @{ Types = @( @{ Category = 'RegistrySettings' @@ -397,7 +397,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'LAPS' } } - Lithnet = @{ + Lithnet = @{ Types = @( @{ Category = 'RegistrySettings' @@ -410,7 +410,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Lithnet/Password Protection for Active Directory*' } } - LocalUsers = [ordered] @{ + LocalUsers = [ordered] @{ Types = @( @{ Category = 'LugsSettings' @@ -425,7 +425,7 @@ ConvertTo-XMLLocalUser -GPO $GPO -SingleObject } } - LocalGroups = [ordered] @{ + LocalGroups = [ordered] @{ Types = @( @{ Category = 'LugsSettings' @@ -440,7 +440,7 @@ ConvertTo-XMLLocalGroups -GPO $GPO -SingleObject } } - Logon = @{ + Logon = @{ Types = @( @{ Category = 'RegistrySettings'; Settings = 'Policy' } ) @@ -449,7 +449,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Logon*' } } - MicrosoftOutlook2002 = @{ + MicrosoftOutlook2002 = @{ Types = @( @{ Category = 'RegistrySettings' @@ -461,7 +461,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Outlook 2002*' } } - MicrosoftEdge = @{ + MicrosoftEdge = @{ Types = @( @{ Category = 'RegistrySettings' @@ -477,7 +477,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Edge*', 'Windows Components/Microsoft Edge', 'Windows Components/Edge UI' } } - MicrosoftOutlook2003 = @{ + MicrosoftOutlook2003 = @{ Types = @( @{ Category = 'RegistrySettings' @@ -492,7 +492,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Office Outlook 2003*', 'Outlook 2003 RPC Encryption' } } - MicrosoftOutlook2010 = @{ + MicrosoftOutlook2010 = @{ Types = @( @{ Category = 'RegistrySettings' @@ -504,7 +504,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Outlook 2010*' } } - MicrosoftOutlook2013 = @{ + MicrosoftOutlook2013 = @{ Types = @( @{ Category = 'RegistrySettings' @@ -516,7 +516,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Outlook 2013*' } } - MicrosoftOutlook2016 = @{ + MicrosoftOutlook2016 = @{ Types = @( @{ Category = 'RegistrySettings' @@ -528,7 +528,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Microsoft Outlook 2016*' } } - MicrosoftManagementConsole = @{ + MicrosoftManagementConsole = @{ Types = @( @{ Category = 'RegistrySettings' @@ -540,7 +540,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Microsoft Management Console*' } } - NetMeeting = @{ + NetMeeting = @{ Types = @( @{ Category = 'RegistrySettings' @@ -552,7 +552,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/NetMeeting*' } } - MSSLegacy = @{ + MSSLegacy = @{ Types = @( @{ Category = 'RegistrySettings' @@ -564,7 +564,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'MSS (Legacy)' } } - MSSecurityGuide = @{ + MSSecurityGuide = @{ Types = @( @{ Category = 'RegistrySettings' @@ -576,7 +576,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'MS Security Guide' } } - OneDrive = @{ + OneDrive = @{ Types = @( @{ Category = 'RegistrySettings' @@ -588,7 +588,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/OneDrive*' } } - Policies = @{ + Policies = @{ Comment = "This isn't really translated" Types = @( @{ @@ -604,7 +604,7 @@ ConvertTo-XMLPolicies -GPO $GPO -SingleObject } } - Printers = @{ + Printers = @{ Types = @( @{ Category = 'PrintersSettings' @@ -623,7 +623,7 @@ ConvertTo-XMLPrinter -GPO $GPO -SingleObject } } - PrintersPolicies = @{ + PrintersPolicies = @{ Types = @( @{ Category = 'RegistrySettings' @@ -638,7 +638,133 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Printers*', 'Control Panel/Printers*' } } - RegistrySettings = [ordered] @{ + PublicKeyPoliciesCertificates = [ordered] @{ + Types = @( + @{ + Category = 'PublicKeySettings' + Settings = 'RootCertificate' + } + @{ + Category = 'PublicKeySettings' + Settings = 'IntermediateCACertificate' + } + @{ + Category = 'PublicKeySettings' + Settings = 'TrustedPeopleCertificate' + } + @{ + Category = 'PublicKeySettings' + Settings = 'UntrustedCertificate' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + <# + PublicKeyPoliciesAll = [ordered] @{ + Types = @( + @{ + Category = 'PublicKeySettings' + Settings = 'AutoEnrollmentSettings' + } + @{ + Category = 'PublicKeySettings' + Settings = 'EFSSettings' + } + @{ + Category = 'PublicKeySettings' + Settings = 'RootCertificateSettings' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + #> + PublicKeyPoliciesAutoEnrollment = [ordered] @{ + Types = @( + @{ + Category = 'PublicKeySettings' + Settings = 'AutoEnrollmentSettings' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + PublicKeyPoliciesEFS = [ordered] @{ + Types = @( + @{ + Category = 'PublicKeySettings' + Settings = 'EFSSettings' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + PublicKeyPoliciesRootCA = [ordered] @{ + Types = @( + @{ + Category = 'PublicKeySettings' + Settings = 'RootCertificateSettings' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + PublicKeyPoliciesEnrollmentPolicy = @{ + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'Policy' + } + ) + GPOPath = @( + 'Policies -> Windows Settings -> Security Settings -> Public Key Policies' + ) + Code = { + ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Internet Communication Management*' + } + } + RegistrySetting = [ordered] @{ + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'RegistrySetting' + } + ) + GPOPath = "Mixed - missing ADMX?" + Code = { + ConvertTo-XMLGenericPublicKey -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject + } + } + RegistrySettings = [ordered] @{ Types = @( @{ Category = 'RegistrySettings' @@ -653,7 +779,7 @@ ConvertTo-XMLRegistrySettings -GPO $GPO -SingleObject } } - OnlineAssistance = @{ + OnlineAssistance = @{ Types = @( @{ Category = 'RegistrySettings' @@ -665,7 +791,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Online Assistance*' } } - RemoteAssistance = @{ + RemoteAssistance = @{ Types = @( @{ Category = 'RegistrySettings' @@ -677,7 +803,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'System/Remote Assistance*' } } - RemoteDesktopServices = @{ + RemoteDesktopServices = @{ Types = @( @{ Category = 'RegistrySettings' @@ -689,7 +815,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Remote Desktop Services*' } } - RSSFeeds = @{ + RSSFeeds = @{ Types = @( @{ Category = 'RegistrySettings' @@ -701,7 +827,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/RSS Feeds*' } } - Scripts = [ordered] @{ + Scripts = [ordered] @{ Types = @( @{ Category = 'Scripts' @@ -716,7 +842,7 @@ ConvertTo-XMLScripts -GPO $GPO -SingleObject } } - SecurityOptions = [ordered] @{ + SecurityOptions = [ordered] @{ Types = @( @{ Category = 'SecuritySettings' @@ -731,7 +857,7 @@ ConvertTo-XMLSecurityOptions -GPO $GPO -SingleObject } } - SoftwareInstallation = [ordered] @{ + SoftwareInstallation = [ordered] @{ Types = @( @{ Category = 'SoftwareInstallationSettings' @@ -746,7 +872,7 @@ ConvertTo-XMLSoftwareInstallation -GPO $GPO -SingleObject } } - SystemServices = [ordered] @{ + SystemServices = [ordered] @{ Types = @( @{ Category = 'SecuritySettings' @@ -762,7 +888,7 @@ ConvertTo-XMLSystemServices -GPO $GPO -SingleObject } } - SystemServicesNT = [ordered] @{ + SystemServicesNT = [ordered] @{ Types = @( @{ Category = 'ServiceSettings' @@ -796,7 +922,7 @@ } } #> - TaskScheduler = [ordered] @{ + TaskScheduler = [ordered] @{ Types = @( @{ Category = 'ScheduledTasksSettings' @@ -812,7 +938,7 @@ ConvertTo-XMLTaskScheduler -GPO $GPO -SingleObject } } - TaskSchedulerPolicies = @{ + TaskSchedulerPolicies = @{ Types = @( @{ Category = 'RegistrySettings' @@ -842,7 +968,22 @@ } } #> - WindowsDefender = @{ + UserRightsAssignment = [ordered] @{ + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'UserRightsAssignment' + } + ) + GPOPath = 'Policies -> Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment' + Code = { + ConvertTo-XMLUserRightsAssignment -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLUserRightsAssignment -GPO $GPO -SingleObject + } + } + WindowsDefender = @{ Types = @( @{ Category = 'RegistrySettings' @@ -854,7 +995,20 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Defender*' } } - WindowsHelloForBusiness = @{ + WindowsDefenderExploitGuard = @{ + # this needs improvements because of DropDownList + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'Policy' + } + ) + GPOPath = 'Policies -> Administrative Templates -> Windows Components/Microsoft Defender Antivirus/Microsoft Defender Exploit Guard' + Code = { + ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Microsoft Defender Antivirus/Microsoft Defender Exploit Guard*' + } + } + WindowsHelloForBusiness = @{ Types = @( @{ Category = 'RegistrySettings' @@ -866,7 +1020,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Hello For Business*' } } - WindowsInstaller = @{ + WindowsInstaller = @{ Types = @( @{ Category = 'RegistrySettings' @@ -878,7 +1032,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Installer*' } } - WindowsLogon = @{ + WindowsLogon = @{ Types = @( @{ Category = 'RegistrySettings' @@ -890,7 +1044,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Logon Options*' } } - WindowsMediaPlayer = @{ + WindowsMediaPlayer = @{ Types = @( @{ Category = 'RegistrySettings' @@ -902,7 +1056,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Media Player*' } } - WindowsMessenger = @{ + WindowsMessenger = @{ Types = @( @{ Category = 'RegistrySettings' @@ -914,7 +1068,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Messenger*' } } - WindowsPowerShell = @{ + WindowsPowerShell = @{ Types = @( @{ Category = 'RegistrySettings' @@ -926,7 +1080,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows PowerShell*' } } - WindowsRemoteManagement = @{ + WindowsRemoteManagement = @{ Types = @( @{ Category = 'RegistrySettings' @@ -938,7 +1092,7 @@ ConvertTo-XMLGenericPolicy -GPO $GPO -Category 'Windows Components/Windows Remote Management (WinRM)*' } } - WindowsUpdate = @{ + WindowsUpdate = @{ Types = @( @{ Category = 'RegistrySettings' diff --git a/Public/Invoke-GPOZaurrSupport.ps1 b/Public/Invoke-GPOZaurrSupport.ps1 index 3119287..7416b31 100644 --- a/Public/Invoke-GPOZaurrSupport.ps1 +++ b/Public/Invoke-GPOZaurrSupport.ps1 @@ -7,26 +7,30 @@ [string] $Path, [string] $Splitter = [System.Environment]::NewLine, [switch] $PreventShow, - [switch] $Offline + [switch] $Offline, + [switch] $ForceGPResult ) # if user didn't choose anything, lets run as currently logged in user locally if (-not $UserName -and -not $ComputerName) { $UserName = $Env:USERNAME - # we can also check if the session is Administrative and if so request computer policies if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $ComputerName = $Env:COMPUTERNAME } } - If ($Type -eq 'HTML') { $Exists = Get-Command -Name 'New-HTML' -ErrorAction SilentlyContinue if (-not $Exists) { - Write-Warning "Request-GPOZaurr - PSWriteHTML module is required for HTML functionality. Use XML, Object or NativeHTML option instead." + Write-Warning "Invoke-GPOZaurrSupport - PSWriteHTML module is required for HTML functionality. Use XML, Object or NativeHTML option instead." return } } - + $Command = Get-Command -Name 'Get-GPResultantSetOfPolicy' -ErrorAction SilentlyContinue + $NativeCommand = Get-Command -Name 'gpresult' -ErrorAction SilentlyContinue + if (-not $Command -and -not $NativeCommand) { + Write-Warning "Invoke-GPOZaurrSupport - Neither gpresult or Get-GPResultantSetOfPolicy are available. Terminating." + return + } $SplatPolicy = @{} if ($Type -in 'Object', 'XML', 'HTML') { @@ -50,22 +54,42 @@ if ($UserName) { $SplatPolicy['User'] = $UserName } - try { - #Write-Verbose "Request-GPOZaurr - ComputerName: $($SplatPolicy['Computer']) UserName: $($SplatPolicy['User'])" - $ResultantSetPolicy = Get-GPResultantSetOfPolicy @SplatPolicy -ErrorAction Stop - } catch { - if ($_.Exception.Message -eq 'Exception from HRESULT: 0x80041003') { - Write-Warning "Request-GPOZaurr - Are you running as admin? $($_.Exception.Message)" - return - } else { - $ErrorMessage = $($_.Exception.Message).Replace([Environment]::NewLine, ' ') - Write-Warning "Request-GPOZaurr - Error: $ErrorMessage" - return + if ($Command -and -not $ForceGPResult) { + try { + #Write-Verbose "Request-GPOZaurr - ComputerName: $($SplatPolicy['Computer']) UserName: $($SplatPolicy['User'])" + $ResultantSetPolicy = Get-GPResultantSetOfPolicy @SplatPolicy -ErrorAction Stop + } catch { + if ($_.Exception.Message -eq 'Exception from HRESULT: 0x80041003') { + Write-Warning "Request-GPOZaurr - Are you running as admin? $($_.Exception.Message)" + return + } else { + $ErrorMessage = $($_.Exception.Message).Replace([Environment]::NewLine, ' ') + Write-Warning "Request-GPOZaurr - Error: $ErrorMessage" + return + } } + } else { + $Arguments = @( + if ($SplatPolicy['Computer']) { + "/S $ComputerName" + } + if ($SplatPolicy['User']) { + "/USER $($SplatPolicy['User'])" + } + if ($SplatPolicy['ReportType'] -eq 'HTML') { + '/H' + } elseif ($SplatPolicy['ReportType'] -eq 'XML') { + '/X' + } + $SplatPolicy['Path'] + "/F" + ) + Write-Verbose "Invoke-GPOZaurrSupport - GPResult Arguments: $Arguments" + Start-Process -NoNewWindow -FilePath 'gpresult' -ArgumentList $Arguments -Wait } if ($Type -eq 'NativeHTML') { if (-not $PreventShow) { - Write-Verbose "Invoke-GPOZaurrSupport - Opening up file $SplatPolicy['Path']" + Write-Verbose "Invoke-GPOZaurrSupport - Opening up file $($SplatPolicy['Path'])" Start-Process -FilePath $SplatPolicy['Path'] } return @@ -109,4 +133,72 @@ New-GPOZaurrReportHTML -Path $Path -Offline:$Offline -Open:(-not $PreventShow) -Support $Output } } -} \ No newline at end of file +} + +<# + + +GPRESULT [/S system [/U username [/P [password]]]] [/SCOPE scope] + [/USER targetusername] [/R | /V | /Z] [(/X | /H) [/F]] + +Description: + This command line tool displays the Resultant Set of Policy (RSoP) + information for a target user and computer. + +Parameter List: + /S system Specifies the remote system to connect to. + + /U [domain\]user Specifies the user context under which the + command should run. + Can not be used with /X, /H. + + /P [password] Specifies the password for the given user + context. Prompts for input if omitted. + Cannot be used with /X, /H. + + /SCOPE scope Specifies whether the user or the + computer settings need to be displayed. + Valid values: "USER", "COMPUTER". + + /USER [domain\]user Specifies the user name for which the + RSoP data is to be displayed. + + /X Saves the report in XML format at the + location and with the file name specified + by the parameter. (valid in Windows + Vista SP1 and later and Windows Server 2008 and later) + + /H Saves the report in HTML format at the + location and with the file name specified by + the parameter. (valid in Windows + at least Vista SP1 and at least Windows Server 2008) + + /F Forces Gpresult to overwrite the file name + specified in the /X or /H command. + + /R Displays RSoP summary data. + + /V Specifies that verbose information should + be displayed. Verbose information provides + additional detailed settings that have + been applied with a precedence of 1. + + /Z Specifies that the super-verbose + information should be displayed. Super- + verbose information provides additional + detailed settings that have been applied + with a precedence of 1 and higher. This + allows you to see if a setting was set in + multiple places. See the Group Policy + online help topic for more information. + + /? Displays this help message. + + +Examples: + GPRESULT /R + GPRESULT /H GPReport.html + GPRESULT /USER targetusername /V + GPRESULT /S system /USER targetusername /SCOPE COMPUTER /Z + GPRESULT /S system /U username /P password /SCOPE USER /V +#> \ No newline at end of file