UPDATE today without anything changing we are back to folders being Access Denied.
I'm giving
$drives = Get-PSDrive -PSProvider 'FileSystem'
foreach ($drive in $drives) {
$root = $drive.Root
if (Test-Path $root) {
Write-Host "Checking root of $root for PoolPart folders..."
Get-ChildItem -Path $root -Directory -Force -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like 'PoolPart.*' } |
ForEach-Object {
Write-Host "Fixing permissions on: $($_.FullName)"
takeown /f "$($_.FullName)" /r /d y | Out-Null
icacls "$($_.FullName)" /grant SYSTEM:F /t | Out-Null
icacls "$($_.FullName)" /grant Administrators:F /t | Out-Null
}
}
}
Write-Host "Done."
Sadly hindsight tells me i should threaded this
$drives = Get-PSDrive -PSProvider 'FileSystem'
$jobs = @()
foreach ($drive in $drives) {
$root = $drive.Root
if (Test-Path $root) {
$jobs += Start-Job -ScriptBlock {
param($driveRoot)
Write-Host "Checking root of $driveRoot for PoolPart folders..."
Get-ChildItem -Path $driveRoot -Directory -Force -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like 'PoolPart.*' } |
ForEach-Object {
Write-Host "Fixing permissions on: $($_.FullName)"
takeown /f "$($_.FullName)" /r /d y | Out-Null
icacls "$($_.FullName)" /grant SYSTEM:F /t | Out-Null
icacls "$($_.FullName)" /grant Administrators:F /t | Out-Null
}
} -ArgumentList $root
}
}
Write-Host "Waiting for all jobs to finish..."
Wait-Job -Job $jobs
foreach ($job in $jobs) {
Receive-Job -Job $job
Remove-Job -Job $job
}
Write-Host "All done."
With any luck this fixes my issue will let you know when its done