I would like extract the information from the DFS property tab of a folder using powershell.
Essentially I would like to traverse through a folder structure and recursively retrieve the dfs information for every folder that has it.
I would like extract the information from the DFS property tab of a folder using powershell.
Essentially I would like to traverse through a folder structure and recursively retrieve the dfs information for every folder that has it.
Here's the Powershell snippet that helped me with the same question:
(Get-DfsnRoot -Domain example.net).Path |
% { (Get-DfsnFolder -Path (Join-Path -Path $_ -ChildPath "\*")).Path } |
% { Get-DfsnFolderTarget -Path $_ | select Path, TargetPath } |
sort Path |
ft -autosize
Some remarks:
\*
at the end of the Get-DfsnFolder -Path parameter is important! Without it, I got a “CimException”; I first tried a simple string concatenation, but that didn’t work, that’s why I use Join-Path.The output should look like this:
Path TargetPath
---- ----------
\\example.net\Admin\AdminScripts \\FS101XY0123.example.net\SysAdmin$\AdminScripts
\\example.net\Admin\Setup \\fs302az8901.example.net\SysAdmin$\Tools\Setup
\\example.net\Admin\Tools \\fs202zz4567.example.net\SysAdmin$\Tools
...
Try the dfsutil
command:
PS C:\> dfsutil client property state $DFSPath
If you have permission to query WMI, you can use the Get-WmiObject
PowerShell cmdlet; you should be able to adapt this example:
$DfsProvider = "SERVER"
$DfsPath = "\\SOME\DFS\Path"
Get-WmiObject -ComputerName $DfsProvider -Class Win32_DFSTarget `
-Filter "SELECT ServerName,ShareName,LinkName FROM Win32_DFSTarget WHERE LinkName = '$DfsPath'"