Hi All - I am trying to write a script to set up a new DFSR Replication group. It works technically, but the results aren’t really usable. The key goal here is to use an array to pipe in a long-ish table of folder names for the -contentpath in the Set-DFSRMembership cmdlet.
Everything up to the Foreach works swimmingly. The results are that for each item ($path) in the $source array, the set-dfsrmembership is run 18 times (thats how many lines are in $source), $foldername
increments each pass, but $path doesn’t until the whole 18 item pass is complete. Then it starts back at the top of $source, $path increments to the 2nd item in the $source array, runs 18 times again,
incrementing $folder along the way. It does this over and over again until $path has incremented all the way through the the array. I think thats like 324 times total…
$Foldername = get-content C:\documents\OldDfs01_folder_names.txt
$source = get-content C:\documents\OldDfs01_folder_paths.txt
$dest = get-content C:\documents\NewDfs01_folder_paths.txt
$group = “dfs test 2”
New-DfsReplicationGroup -GroupName $group | Add-DfsrMember -ComputerName “OldDfs01”,“NewDfs01” | Format-Table dnsname,groupname -auto -wrap
New-DfsReplicatedFolder -GroupName $group -FolderName $Foldername
Add-DfsrConnection -GroupName $group -SourceComputerName OldDfs01 -DestinationComputerName NewDfs01
foreach ($path in $source) {
Set-DfsrMembership -GroupName $group -FolderName $foldername -ComputerName OldDfs01 -ContentPath $path –PrimaryMember $true -Force
}
Here is a snip of the first few entries of the results (Ive only included the relevant bits):
Pass 1:
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Prodn
ContentPath : n:\Prodn
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Qa
ContentPath : n:\Prodn
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Shipping
ContentPath : n:\Prodn
Pass 2:
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Prodn
ContentPath : n:\Qa
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Qa
ContentPath : n:\Qa
GroupName : dfs test 2
ComputerName : OldDfs01
FolderName : Shipping
ContentPath : n:\Qa
I suspect its something to do with the fact that that switch (-contentpath) doesn’t accept piplining? Thoughts?
Thanks in advance for any assistance!