diff --git a/Public/Get-GPOZaurrSysvolDFSR.ps1 b/Public/Get-GPOZaurrSysvolDFSR.ps1 new file mode 100644 index 0000000..36b9ae4 --- /dev/null +++ b/Public/Get-GPOZaurrSysvolDFSR.ps1 @@ -0,0 +1,37 @@ +function Get-GPOZaurrSysvolDFSR { + [cmdletBinding()] + param( + [alias('ForestName')][string] $Forest, + [string[]] $ExcludeDomains, + [string[]] $ExcludeDomainControllers, + [alias('Domain', 'Domains')][string[]] $IncludeDomains, + [alias('DomainControllers')][string[]] $IncludeDomainControllers, + [switch] $SkipRODC, + [System.Collections.IDictionary] $ExtendedForestInformation, + [string] $SearchDFSR = 'SYSVOL Share' + ) + $ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExcludeDomainControllers $ExcludeDomainControllers -IncludeDomainControllers $IncludeDomainControllers -SkipRODC:$SkipRODC -ExtendedForestInformation $ExtendedForestInformation + foreach ($Domain in $ForestInformation.Domains) { + Write-Verbose "Get-GPOZaurrSysvolDFSR - Processing $Domain" + $QueryServer = $ForestInformation['QueryServers']["$Domain"].HostName[0] + + $DFSRConfig = Get-CimInstance -Namespace 'root\microsoftdfs' -Class 'dfsrreplicatedfolderconfig' -ComputerName $QueryServer | Where-Object { $_.ReplicatedFolderName -eq $SearchDFSR } + $DFSR = Get-CimInstance -Namespace 'root\microsoftdfs' -Class 'dfsrreplicatedfolderinfo' -ComputerName $QueryServer | Where-Object { $_.ReplicatedFolderName -eq $SearchDFSR } + if ($DFSR -and $DFSRConfig -and ($DFSR.ReplicatedFolderGuid -eq $DFSRConfig.ReplicatedFolderGuid)) { + [PSCustomObject] @{ + ComputerName = $DFSR.PSComputerName + DomainName = $Domain + ConflictPath = $DFSRConfig.ConflictPath + LastConflictCleanupTime = $DFSR.LastConflictCleanupTime + CurrentConflictSizeInMb = $DFSR.CurrentConflictSizeInMb + MaximumConflictSizeInMb = $DFSRConfig.ConflictSizeInMb + LastErrorCode = $DFSR.LastErrorCode + LastErrorMessageId = $DFSR.LastErrorMessageId + LastTombstoneCleanupTime = $DFSR.LastTombstoneCleanupTime + ReplicatedFolderGuid = $DFSR.ReplicatedFolderGuid + DFSRConfig = $DFSRConfig + DFSR = $DFSR + } + } + } +} \ No newline at end of file