quinta-feira, 14 de fevereiro de 2013

Find the Shares from your DFS Namespace

DFS Namespace information can be easily exported to a nice XML file with the command:

dfsutil root export \\domain\namespacename C:\Export.xml

But now you have a XML file, which is not the best file type to work with and check important info. Basically what I will show you is a small script in Powershell that parses the XML and return the ONLINE targets sharename, but you can adapt to return the info you need.

# Parsing XML from Namespace
[xml]$dfs = Get-Content output.xml
$output = @()
foreach ($link in $dfs.Root.Link)
    if ($link.Name -match "DEEI\\Groups")
        $user = $link.Name.Split("\")

        foreach ($target in $link.Target)
            $shareName = $target.get_InnerXml()
            if ($target.state -eq "ONLINE")
$output | Out-File '.\OUTPUT-SHARE.TXT'

The small script above returns all shares which are ONLINE and output them to the OUTPUT-SHARE.TXT. It takes as input the file 'output.xml' which is the xml from the namespace.

Feel free to adapt it. Please let your comment.

Nenhum comentário:

Postar um comentário