替换DFS文件夹目标

时间:2017-06-09 14:27:06

标签: powershell dfs

我正在寻找能够更改所有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
    }
}

非常感谢任何帮助!

0 个答案:

没有答案