PowerShell: List all folders where access is denied

I just needed a list with all folders I couldn’t access.

Here is the PowerShell script (you may have to change the directory C:\app):

$errors=@()
get-childitem -recurse 'C:\app' -ea silentlycontinue -ErrorVariable +errors | Out-Null
$errors.Count
$errors | Foreach-Object { Write-Host $_ }

If you want to see everything in your PowerShell console, remove the | Out-Null.

This is a possible output from the script:

3 
Access to the path 'C:\app\pfile' is denied. 
Access to the path 'C:\app\adump' is denied. 
Access to the path 'C:\app\diag' is denied.

Enjoy 😉

[ technet ]

Advertisements

2 thoughts on “PowerShell: List all folders where access is denied

  1. Thanks for the script, to output into csv (for US localization use “,”) :

    $errors=@()
    get-childitem -recurse ‘c:\priv’ -ea silentlycontinue -ErrorVariable +errors | Out-Null
    $errors.Count
    $errors | select -expand categoryinfo | select reason,targetname | export-csv -NoTypeInformation -Delimiter “;” .\ErrorList.csv

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s