diff --git a/Examples/Example-40-ShowGPO4.ps1 b/Examples/Example-40-ShowGPO4.ps1 new file mode 100644 index 0000000..c9051f6 --- /dev/null +++ b/Examples/Example-40-ShowGPO4.ps1 @@ -0,0 +1,15 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +$Types = @( + @{ Name = 'GPOOwners'; Path = "$PSScriptRoot\Reports\GPOOwners.html" } + @{ Name = 'GPOConsistency'; Path = "$PSScriptRoot\Reports\GPOConsistency.html" } + @{ Name = 'GPODuplicates'; Path = "$PSScriptRoot\Reports\GPODuplicates.html" } + @{ Name = 'GPOList'; Path = "$PSScriptRoot\Reports\GPOList.html" } + @{ Name = 'GPOOrphans'; Path = "$PSScriptRoot\Reports\GPOOrphans.html" } + @{ Name = 'GPOPassword'; Path = "$PSScriptRoot\Reports\GPOPassword.html" } + @{ Name = 'NetLogonPermissions'; Path = "$PSScriptRoot\Reports\NetLogonPermissions.html" } +) + +foreach ($Type in $Types) { + Invoke-GPOZaurr -FilePath $Type.Path -Type $Type.Name -HideHTML +} \ No newline at end of file diff --git a/Examples/Example-43-OptimizeGPO.ps1 b/Examples/Example-43-OptimizeGPO.ps1 new file mode 100644 index 0000000..97f78e0 --- /dev/null +++ b/Examples/Example-43-OptimizeGPO.ps1 @@ -0,0 +1,2 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + diff --git a/Public/Get-GPOZaurrNetlogon.ps1 b/Public/Get-GPOZaurrNetlogon.ps1 index d9242cd..f6123bc 100644 --- a/Public/Get-GPOZaurrNetlogon.ps1 +++ b/Public/Get-GPOZaurrNetlogon.ps1 @@ -13,9 +13,16 @@ $FilesAll = foreach ($Domain in $ForestInformation.Domains) { $Path = -join ("\\", $Domain, '\Netlogon') $PathOnSysvol = -join ("\\", $Domain, "\SYSVOL\", $Domain, "\Scripts") - $Files = Get-ChildItem -LiteralPath $Path -Recurse -Force - foreach ($_ in $Files) { - $ACL = Get-Acl -Path $_.FullName + $Files = Get-ChildItem -LiteralPath $Path -Recurse -Force -ErrorVariable Err -ErrorAction SilentlyContinue + foreach ($e in $err) { + Write-Warning "Get-GPOZaurrNetLogon - Listing file failed with error $($e.Exception.Message) ($($e.CategoryInfo.Reason))" + } + foreach ($File in $Files) { + try { + $ACL = Get-Acl -Path $File.FullName -ErrorAction Stop + } catch { + Write-Warning "Get-GPOZaurrNetLogon - ACL reading failed for $($File.FullName) with error $($_.Exception.Message) ($($_.CategoryInfo.Reason))" + } if ($ACL.Owner) { $IdentityOwner = Convert-Identity -Identity $ACL.Owner -Verbose:$false } else { @@ -24,19 +31,19 @@ if (-not $OwnerOnly) { if (-not $SkipOwner) { [PSCustomObject] @{ - FullName = $_.FullName - Extension = $_.Extension - CreationTime = $_.CreationTime - LastAccessTime = $_.LastAccessTime - LastWriteTime = $_.LastWriteTime - Attributes = $_.Attributes + FullName = $File.FullName + Extension = $File.Extension + CreationTime = $File.CreationTime + LastAccessTime = $File.LastAccessTime + LastWriteTime = $File.LastWriteTime + Attributes = $File.Attributes AccessControlType = 'Allow' # : Allow Principal = $IdentityOwner.Name # : BUILTIN\Administrators PrincipalSid = $IdentityOwner.SID PrincipalType = $IdentityOwner.Type FileSystemRights = 'Owner' # : FullControl IsInherited = $false - FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol) + FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol) #Owner = $ACL.Owner } } @@ -44,33 +51,33 @@ foreach ($Perm in $FilePermission) { $Identity = Convert-Identity -Identity $Perm.Principal -Verbose:$false [PSCustomObject] @{ - FullName = $_.FullName - Extension = $_.Extension - CreationTime = $_.CreationTime - LastAccessTime = $_.LastAccessTime - LastWriteTime = $_.LastWriteTime - Attributes = $_.Attributes + FullName = $File.FullName + Extension = $File.Extension + CreationTime = $File.CreationTime + LastAccessTime = $File.LastAccessTime + LastWriteTime = $File.LastWriteTime + Attributes = $File.Attributes AccessControlType = $Perm.AccessControlType # : Allow Principal = $Identity.Name # : BUILTIN\Administrators PrincipalSid = $Identity.SID PrincipalType = $Identity.Type FileSystemRights = $Perm.FileSystemRights # : FullControl IsInherited = $Perm.IsInherited # : True - FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol) + FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol) } } } else { [PSCustomObject] @{ - FullName = $_.FullName - Extension = $_.Extension - CreationTime = $_.CreationTime - LastAccessTime = $_.LastAccessTime - LastWriteTime = $_.LastWriteTime - Attributes = $_.Attributes + FullName = $File.FullName + Extension = $File.Extension + CreationTime = $File.CreationTime + LastAccessTime = $File.LastAccessTime + LastWriteTime = $File.LastWriteTime + Attributes = $File.Attributes Owner = $IdentityOwner.Name OwnerSid = $IdentityOwner.SID OwnerType = $IdentityOwner.Type - FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol) + FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol) } } } diff --git a/README.md b/README.md index 34f7a43..af86093 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ That's it. Whenever there's a new version, you run the command, and you can enjo ## Changelog +- 0.0.76 - 8.11.2020 + - Improved `Get-GPOZaurrNetLogon` to better handle errors - 0.0.75 - 8.11.2020 - Improved `Get-GPOZaurrPermissionConsistency` to stop checking consistency if path doesn't exists - 0.0.74 - 8.11.2020