# Take ownership over a folder or file
$FilePath = "C:\Users\Ron\Documents"
$Condition = Test-Path -Path $FilePath -PathType 'Container'
Switch ($Condition) {
$True { & 'TakeOwn.exe' '/F' $FilePath, '/A', '/R', '/D:Y' | Out-Null
& 'ICACLS.exe' $FilePath, '/Grant', 'Everyone:(F)', '/T', '/Q', '/C'
}
Default { & 'TakeOwn.exe' '/F' $FilePath, '/A'
& 'ICACLS.exe' $FilePath, '/Grant', 'Everyone:(F)', '/T', '/Q', '/C'
}
}
#