Last active
August 7, 2020 09:14
-
-
Save moddingg33k/f2615fc1a1ff5636540496abb3ba0061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-DfsnFolderTargetsRecursive | |
{ | |
[CmdletBinding()] | |
Param( | |
[Parameter(Position = 0, Mandatory = $true)] | |
[ValidateNotNullOrEmpty()] | |
[string] $DFSPath | |
) | |
Write-Progress "Getting all DFS folders for $DFSPath (this can take a very long time)" -PercentComplete -1 | |
$DFSTree = Get-DfsnFolder $DFSPath | |
$i = 1 | |
$result = $DFSTree | ForEach-Object { | |
Write-Progress "Getting DFS Folder Targets for $($_.Path)" -PercentComplete (($i / $DFSTree.Count) * 100) | |
$DFSTarget = Get-DfsnFolderTarget $_.Path | Select Path,TargetPath,State | |
$Result = [ordered]@{ | |
Path = $DFSTarget.Path | |
TargetPath = $DFSTarget.TargetPath | |
State = $DFSTarget.State | |
"ValidFrom_$Env:ComputerName" = Test-Path $DFSTarget.Path | |
} | |
New-Object PSObject -Property $Result | |
$i++ | |
} | Sort Path | |
return $result | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-DfsnFolderTargetsRecursive '\\example.com\share' | Export-Csv "DFS-$(Get-Date -format yyyy-MM-dd).csv" -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment