diff --git a/Examples/Example-08-ListingPermissions.ps1 b/Examples/Example-08-ListingPermissions.ps1 index 3e05fc2..b8ba981 100644 --- a/Examples/Example-08-ListingPermissions.ps1 +++ b/Examples/Example-08-ListingPermissions.ps1 @@ -1,7 +1,7 @@ Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force -#$T = Get-GPOZaurrPermission -GPOName 'DC | PowerShell Logging' -Type Unknown +$T = Get-GPOZaurrPermission -GPOName 'DC | PowerShell Logging' -Type Unknown -$T = Get-GPOZaurrPermission -ResolveAccounts -IncludeOwner #-ExcludePermissionType GpoRead,GpoApply #-Type All #-SkipWellKnown -SkipAdministrative # -ExcludePermissionType GpoRead,GpoApply #| Out-HtmlView +#$T = Get-GPOZaurrPermission -ResolveAccounts -IncludeOwner #-ExcludePermissionType GpoRead,GpoApply #-Type All #-SkipWellKnown -SkipAdministrative # -ExcludePermissionType GpoRead,GpoApply #| Out-HtmlView $T | Format-Table -AutoSize * -$T | Out-HtmlView -ScrollX -Filtering -Online -DisablePaging \ No newline at end of file +#$T | Out-HtmlView -ScrollX -Filtering -Online -DisablePaging \ No newline at end of file diff --git a/Examples/Example-08-ListingPermissionsPerGPO.ps1 b/Examples/Example-08-ListingPermissionsPerGPO.ps1 new file mode 100644 index 0000000..c6c69ce --- /dev/null +++ b/Examples/Example-08-ListingPermissionsPerGPO.ps1 @@ -0,0 +1,4 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +$T = Get-GPOZaurrPermission -GPOName 'ALL | Enable RDP' #-ExcludePermissionType GpoApply,GpoRead -IncludeGPOObject +$T | Format-Table -AutoSize * \ No newline at end of file diff --git a/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 b/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 index 62add99..4ac63ba 100644 --- a/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 +++ b/Examples/Example-11-ReplaceGPOOwnerAutomated.ps1 @@ -5,9 +5,9 @@ # regardless if current user is still Domain Admin or not $GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' -$GPOs | Format-Table DisplayName, Owner, OwnerSID +$GPOs | Format-Table DisplayName, Owner, OwnerSID, OwnerType -Set-GPOZaurrOwner -Type 'NonAdministrative','EmptyOrUnknown' -Verbose -LimitProcessing 3 #-WhatIf +Set-GPOZaurrOwner -Type 'EmptyOrUnknown' -Verbose -LimitProcessing 1 -WhatIf $GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' $GPOs | Format-Table DisplayName, Owner, OwnerSID \ No newline at end of file diff --git a/Examples/Example-10-ReplaceGPOOwner.ps1 b/Examples/Example-11-ReplaceGPOOwnerManual.ps1 similarity index 90% rename from Examples/Example-10-ReplaceGPOOwner.ps1 rename to Examples/Example-11-ReplaceGPOOwnerManual.ps1 index f08aeba..ec228bc 100644 --- a/Examples/Example-10-ReplaceGPOOwner.ps1 +++ b/Examples/Example-11-ReplaceGPOOwnerManual.ps1 @@ -1,5 +1,6 @@ Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force +# You can set owner per guid if you want to have more control. $LImitProcessing = 2 # check what is there now diff --git a/Examples/Example-11-ReplaceGPOOwnerPerGPO.ps1 b/Examples/Example-11-ReplaceGPOOwnerPerGPO.ps1 new file mode 100644 index 0000000..b449af9 --- /dev/null +++ b/Examples/Example-11-ReplaceGPOOwnerPerGPO.ps1 @@ -0,0 +1,15 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +# this example shows how to replace owner of a single GPO + +$GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' +$GPOs | Format-Table DisplayName, Owner, OwnerSID, OwnerType + +# If Principal is not provided Domain Admins are set as default principal +Set-GPOZaurrOwner -GPOName 'ALL | Enable RDP' -WhatIf + +# If principal is given it is set (of course if it exits). Otherwise warning is returned. +Set-GPOZaurrOwner -GPOName 'ALL | Enable RDP' -Principal 'przemyslaw.klys' #-WhatIf + +$GPOs = Get-GPOZaurr #-GPOName 'New Group Policy Object' +$GPOs | Format-Table DisplayName, Owner, OwnerSID, OwnerType \ No newline at end of file diff --git a/Examples/Example-14-ListingGPOsPerOU1.ps1 b/Examples/Example-14-ListingGPOsPerOU1.ps1 new file mode 100644 index 0000000..87d3113 --- /dev/null +++ b/Examples/Example-14-ListingGPOsPerOU1.ps1 @@ -0,0 +1,3 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +Get-GPOZaurrLink | Format-Table -AutoSize \ No newline at end of file diff --git a/Examples/Example-14-ListingGPOsPerOU2.ps1 b/Examples/Example-14-ListingGPOsPerOU2.ps1 new file mode 100644 index 0000000..bf00eeb --- /dev/null +++ b/Examples/Example-14-ListingGPOsPerOU2.ps1 @@ -0,0 +1,7 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +Get-GPOZaurrLink -SearchBase 'OU=Domain Controllers,DC=ad,DC=evotec,DC=xyz' | Format-Table -AutoSize + +Get-GPOZaurrLink -SearchBase 'OU=Computers,OU=Production,DC=ad,DC=evotec,DC=xyz' | Format-Table -AutoSize + +Get-GPOZaurrLink -SearchBase 'DC=ad,DC=evotec,DC=xyz' -SearchScope Base | Format-Table -AutoSize \ No newline at end of file diff --git a/Examples/Example-14-ListingGPOsPerOU3.ps1 b/Examples/Example-14-ListingGPOsPerOU3.ps1 new file mode 100644 index 0000000..84feac5 --- /dev/null +++ b/Examples/Example-14-ListingGPOsPerOU3.ps1 @@ -0,0 +1,5 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +Get-ADOrganizationalUnit -Filter * -Properties distinguishedName, LinkedGroupPolicyObjects | Get-GPOZaurrLink | Format-Table +Get-ADObject -Filter * -Properties distinguishedName, gplink -Server 'ad.evotec.pl' | Get-GPOZaurrLink | Format-Table -AutoSize +Get-GPOZaurrLink | Format-Table -AutoSize \ No newline at end of file diff --git a/Examples/Example-15-FixingGPOPermissions.ps1 b/Examples/Example-15-FixingGPOPermissions.ps1 new file mode 100644 index 0000000..87d3113 --- /dev/null +++ b/Examples/Example-15-FixingGPOPermissions.ps1 @@ -0,0 +1,3 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +Get-GPOZaurrLink | Format-Table -AutoSize \ No newline at end of file diff --git a/Examples/Example-16-AddGPOPermission.ps1 b/Examples/Example-16-AddGPOPermission.ps1 new file mode 100644 index 0000000..0447f06 --- /dev/null +++ b/Examples/Example-16-AddGPOPermission.ps1 @@ -0,0 +1,13 @@ +Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force + +$T = Get-GPOZaurrPermission -GPOName 'ALL | Enable RDP' -IncludeGPOObject #-ExcludePermissionType GpoApply,GpoRead -IncludeGPOObject +$T | Format-Table -AutoSize * + +Remove-GPOZaurrPermission -GPOName 'ALL | Enable RDP' -PermissionType GpoEditDeleteModifySecurity -Principal 'CN=Przemysław Kłys,OU=Users,OU=Production,DC=ad,DC=evotec,DC=xyz' -PrincipalType 'DistinguishedName' + +#$T = Add-GPOZaurrPermission -GPOName 'ALL | Enable RDP' -PermissionType GpoEditDeleteModifySecurity -Principal 'Domain Admins' -verbose #| Format-Table +#$T = Add-GPOZaurrPermission -GPOName 'ALL | Enable RDP' -PermissionType GpoApply -Principal 'przemyslaw.klys' -verbose #| Format-Table +#$T | Format-Table -AutoSize * + +$T = Get-GPOZaurrPermission -GPOName 'ALL | Enable RDP' #-ExcludePermissionType GpoApply,GpoRead -IncludeGPOObject +$T | Format-Table -AutoSize * \ No newline at end of file