I would like to get a list of DFS-Shares, where a specific server is registered as the TargetPath.
I have been trying to get this by the following code
`$DFSPath = "\\DFSpath"
$DFSNFolders = Get-DfsnFolder $DFSPath
foreach($DFSNFolder in $DFSNFolders )
{
$DFSTarget = Get-DfsnFolderTarget $DFSNFolder.path | Select Path,TargetPath |
Where {$DFSNFolder.TargetPath -like $servername} |
}`
But no matter what I try, the result $DFSTarget is always empty.
Powershell version is 5.
I have tried to adjust the Where {} clause, but no matter what I enter there, the result is empty (eventhough I know there is results).
I am using Match instead of like, but the same idea:
$ServerToFind = "server1.example.com"
$RootPath = (Get-DfsnRoot).Path
$RootTargets = Get-DfsnRootTarget -Path $RootPath
$RootTargets | Where-Object {$_.TargetPath -match $ServerToFind}