mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-17 14:08:18 +00:00
36 lines
1.4 KiB
PowerShell
36 lines
1.4 KiB
PowerShell
function Repair-GPOZaurrNetLogonOwner {
|
|
[cmdletBinding(SupportsShouldProcess)]
|
|
param(
|
|
[alias('ForestName')][string] $Forest,
|
|
[string[]] $ExcludeDomains,
|
|
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
|
[System.Collections.IDictionary] $ExtendedForestInformation,
|
|
|
|
[string] $Principal = 'S-1-5-32-544',
|
|
[int] $LimitProcessing = [int32]::MaxValue
|
|
)
|
|
$Identity = Convert-Identity -Identity $Principal -Verbose:$false
|
|
if ($Identity.Error) {
|
|
Write-Warning "Repair-GPOZaurrNetLogonOwner - couldn't convert Identity $Principal to desired name. Error: $($Identity.Error)"
|
|
return
|
|
}
|
|
$Principal = $Identity.Name
|
|
|
|
$getGPOZaurrNetLogonSplat = @{
|
|
OwnerOnly = $true
|
|
Forest = $Forest
|
|
IncludeDomains = $IncludeDomains
|
|
ExcludeDomains = $ExcludeDomains
|
|
ExtendedForestInformation = $ExtendedForestInformation
|
|
}
|
|
|
|
Get-GPOZaurrNetLogon @getGPOZaurrNetLogonSplat -Verbose | Where-Object {
|
|
if ($_.OwnerSid -ne 'S-1-5-32-544') {
|
|
$_
|
|
}
|
|
} | Select-Object -First $LimitProcessing | ForEach-Object {
|
|
if ($PSCmdlet.ShouldProcess($_.FullName, "Setting NetLogon Owner to $($Principal)")) {
|
|
Set-FileOwner -JustPath -Path $_.FullName -Owner $Principal -Verbose:$true -WhatIf:$WhatIfPreference
|
|
}
|
|
}
|
|
} |