我一直在研究如何检查是否使用PowerShell中的DFSR或FRS for Sysvol Replication。 这是我的天真的方法,我试图实现。
PS C:> Get-WindowsFeature |其中Displayname – 匹配“复制”
Display Name Name Install State ------------ ---- ------------- [ ] DFS Replication FS-DFS-Replication Available
那么,这certificate它使用FRS而不是DFSR?
检查DN
$FRSsysvol = "CN=Domain System Volume (SYSVOL share),CN=File Replication Service,CN=System,"+(Get-ADDomain $domain).DistinguishedName $DFSRsysvol = "CN=Domain System Volume,CN=DFSR-GlobalSettings,CN=System,"+(Get-ADDomain $domain).DistinguishedName $frs = Get-ADObject -Filter { distinguishedName -eq $FRSsysvol } $dfsr = Get-ADObject -Filter { distinguishedName -eq $DFSRsysvol } if ( $frs -ne $null ) { Write-Host -ForegroundColor red "FRS" } elseif ( $dfsr -ne $null ) { Write-Host -ForegroundColor green "DFS-R" } else { Write-Host -ForegroundColor Red "unknown" }
这返回“FRS”。 但是当我仔细检查$frs和$dfsr输出。 两者都不是$null 。 两者都返回DN,Name,ObjectClass和ObjectGUID。 那么,这里有什么问题?
如果你想用powershell检查你的DFS复制,你可以使用适当的cmdlet:
PS C:\> get-command -Name "*dfsr*" CommandType Name ModuleName ----------- ---- ---------- Cmdlet Add-DfsrConnection DFSR Cmdlet Add-DfsrMember DFSR Cmdlet ConvertFrom-DfsrGuid DFSR Cmdlet Export-DfsrClone DFSR Cmdlet Get-DfsrBacklog DFSR Cmdlet Get-DfsrCloneState DFSR Cmdlet Get-DfsrConnection DFSR Cmdlet Get-DfsrConnectionSchedule DFSR Cmdlet Get-DfsReplicatedFolder DFSR Cmdlet Get-DfsReplicationGroup DFSR Cmdlet Get-DfsrFileHash DFSR Cmdlet Get-DfsrGroupSchedule DFSR Cmdlet Get-DfsrIdRecord DFSR Cmdlet Get-DfsrMember DFSR Cmdlet Get-DfsrMembership DFSR Cmdlet Get-DfsrPreservedFiles DFSR Cmdlet Get-DfsrServiceConfiguration DFSR
特别是, Get-DfsrBacklog检查是否有文件等待复制:
PS C:\Windows\system32> (Get-DfsrBacklog -SourceComputerName Server1 -DestinationComputerName Server2).count 4
它会给出等待文件的数量,更一般地说是哪个文件…您可以反转源和目标以获得另一端的复制状态。
编辑评论
您可以使用dfsrmig.exe /GetGlobalState来testing使用哪个复制。 如果命令返回'dfsr not initalized',则使用FSR 。
我已经find了如何实现这一点,希望这个帮助!
$currentDomain =(Get-ADDomainController).hostname $defaultNamingContext = (([ADSI]"LDAP://$currentDomain/rootDSE").defaultNamingContext) $searcher = New-Object DirectoryServices.DirectorySearcher $searcher.Filter = "(&(objectClass=computer)(dNSHostName=$currentDomain))" $searcher.SearchRoot = "LDAP://" + $currentDomain + "/OU=Domain Controllers," + $defaultNamingContext $dcObjectPath = $searcher.FindAll() | %{$_.Path} # DFSR $searchDFSR = New-Object DirectoryServices.DirectorySearcher $searchDFSR.Filter = "(&(objectClass=msDFSR-Subscription)(name=SYSVOL Subscription))" $searchDFSR.SearchRoot = $dcObjectPath $dfsrSubObject = $searchDFSR.FindAll() if ($dfsrSubObject -ne $null){ [pscustomobject]@{ "SYSVOL Replication Mechanism"= "DFSR" "Path:"= $dfsrSubObject|%{$_.Properties."msdfsr-rootpath"} } } # FRS $searchFRS = New-Object DirectoryServices.DirectorySearcher $searchFRS.Filter = "(&(objectClass=nTFRSSubscriber)(name=Domain System Volume (SYSVOL share)))" $searchFRS.SearchRoot = $dcObjectPath $frsSubObject = $searchFRS.FindAll() if($frsSubObject -ne $null){ [pscustomobject]@{ "SYSVOL Replication Mechanism" = "FRS" "Path" = $frsSubObject|%{$_.Properties.frsrootpath} } }