2

I would like extract the information from the DFS property tab of a folder using powershell.

DFS properties tab

Essentially I would like to traverse through a folder structure and recursively retrieve the dfs information for every folder that has it.

Bruno
  • 5,772
  • 1
  • 26
  • 43
  • 1
    Do you have Server 2012 or Windows 8? If so you should have the cmdlets needed to get that information with ease. Check out [this link](http://blogs.technet.com/b/filecab/archive/2012/10/19/introducing-dfs-namespaces-windows-powershell-cmdlets.aspx) for more information. – TheMadTechnician Jun 20 '14 at 20:42
  • @TheMadTechnician Nah, I am working with Windows 7. – Bruno Jun 20 '14 at 22:17
  • I don't have anything to test with, but this looks like it should work: http://dfscommands.codeplex.com/. – Tim Ferrill Jun 20 '14 at 22:51

3 Answers3

1

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:

  • It uses the cmdlets from the DFSR module for Powershell, which is available since/for Windows Server 2012 R2, I believe (you may need to install/enable it first).
  • The trailing \* 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.
  • I was only interested in the target paths, so other DFS properties weren't taken into consideration in the code snippet above.

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
...
0

Try the dfsutil command:

PS C:\> dfsutil client property state $DFSPath
Charlie Joynt
  • 4,411
  • 1
  • 24
  • 46
Jibin
  • 1
0

Using WMI

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'"
Charlie Joynt
  • 4,411
  • 1
  • 24
  • 46