Last active
January 11, 2017 11:32
-
-
Save kmhuglen/b5e64c96db66b0aa50af to your computer and use it in GitHub Desktop.
This file contains 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
Param( | |
$ComputerName | |
, | |
$Filter ="*.dwg" | |
) | |
IF (-Not($ComputerName)) {$ComputerName = $env:COMPUTERNAME} | |
$dfsmemberships = Get-DfsrMembership -GroupName * -ComputerName $ComputerName | |
$dfsrPreservedFiles = $null | |
foreach ($dfsmembership in $dfsmemberships) | |
{ | |
$dfsrPreservedFiles += Get-DfsrPreservedFiles -Path ($dfsmembership.contentpath + "\dfsrprivate\conflictanddeletedmanifest.xml") | |
} | |
$selectedfiles = $dfsrPreservedFiles | Where {$_.path -like $filter } | Sort-Object PreservedTime -Descending | select PreservedTime,PreservedReason,Path,PreservedName,FileSize,uid | Out-GridView -Title "Preserved Files (filter = $filter)" -PassThru | |
foreach ($selectedfile in $selectedfiles) | |
{ | |
$file = $dfsrPreservedFiles | Where {$_.uid -eq $selectedfile.uid} | |
$file.path -match "^\\\\\.\\(?'path'.+)\\" | Out-Null | |
$path = $matches.path | |
$file.path -match "^\\\\\.\\(?'filepath'.+)" | Out-Null | |
$filepath = $matches.filepath | |
foreach ($dfspath in $dfsmemberships.contentpath) | |
{ | |
IF ($path -like "$dfspath*") | |
{ | |
$source = "$dfspath\DfsrPrivate\ConflictAndDeleted\$($selectedfile.PreservedName)" | |
$destination = $filepath | |
Copy-Item -Path $source -Destination $destination -Confirm | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment