我正在寻找能够更改所有DFS命名空间的文件夹目标中的文件服务器名称的PowerShell脚本
e.g。文件夹目标' \\ server1 \ Marketing \ Branding'应该成为' \\ server2 \ Marketing \ Branding'
这就是我所提出的,但是取而代之的并不是我想要的。另外我相信代码可能结构化得更简单:
$Namespaces = Get-DfsnRoot
$Namespaces | ForEach-Object {
$NSpath = $_.path
$NSfullpath = $NSpath + '\*'
$DFSTree = Get-DfsnFolder $NSfullpath
$DFSTree | ForEach-Object {
$DFSTarget = Get-DfsnFolderTarget $_.Path
$DFSTarget -replace "server1", "server2"
Set-DfsnFolderTarget -Path $DFSTarget.Path -TargetPath $DFSTarget.TargetPath -WhatIf
$DFSTarget -replace "server2", "server1"
Remove-DfsnFolderTarget -Path $DFSTarget.Path -TargetPath $DFSTarget.TargetPath -WhatIf
}
}
非常感谢任何帮助!