mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-20 15:12:24 +00:00
33 lines
1.5 KiB
PowerShell
33 lines
1.5 KiB
PowerShell
function Remove-GPOZaurrWMI {
|
|
[CmdletBinding(SupportsShouldProcess)]
|
|
Param (
|
|
[Guid[]] $Guid,
|
|
[string[]] $Name,
|
|
|
|
[alias('ForestName')][string] $Forest,
|
|
[string[]] $ExcludeDomains,
|
|
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
|
[System.Collections.IDictionary] $ExtendedForestInformation
|
|
)
|
|
if (-not $Forest -and -not $ExcludeDomains -and -not $IncludeDomains -and -not $ExtendedForestInformation) {
|
|
$IncludeDomains = $Env:USERDNSDOMAIN
|
|
}
|
|
$ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
|
foreach ($Domain in $ForestInformation.Domains) {
|
|
$QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0]
|
|
[Array] $Objects = @(
|
|
if ($Guid) {
|
|
Get-GPOZaurrWMI -Guid $Guid -ExtendedForestInformation $ForestInformation -IncludeDomains $Domain
|
|
}
|
|
if ($Name) {
|
|
Get-GPOZaurrWMI -Name $Name -ExtendedForestInformation $ForestInformation -IncludeDomains $Domain
|
|
}
|
|
)
|
|
$Objects | ForEach-Object -Process {
|
|
if ($_.DistinguishedName) {
|
|
Write-Verbose "Remove-GPOZaurrWMI - Removing WMI Filter $($_.DistinguishedName)"
|
|
Remove-ADObject $_.DistinguishedName -Confirm:$false -Server $QueryServer
|
|
}
|
|
}
|
|
}
|
|
} |