Skip to content

Instantly share code, notes, and snippets.

@kmhuglen
Last active January 11, 2017 11:32
Show Gist options
  • Save kmhuglen/b5e64c96db66b0aa50af to your computer and use it in GitHub Desktop.
Save kmhuglen/b5e64c96db66b0aa50af to your computer and use it in GitHub Desktop.
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