Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save konung/ad47cf347ba24df3912f1385ca99b9ef to your computer and use it in GitHub Desktop.
Save konung/ad47cf347ba24df3912f1385ca99b9ef to your computer and use it in GitHub Desktop.
$Path = 'i:\'
$OutCSV = 'c:\Windows\Temp\i_drive_suspects.csv'
$RegEx = "[^-\w\.\ \~\'\(\)\$\&\+\,\@\%]" # This matches anything that isn't a-z, A-Z, 0-9, or the '-', '_', and '.' characters. Add any others you need to permit.
$Output = Get-ChildItem -Path $Path -Recurse | Where-Object -FilterScript { $_.Name -match $RegEx } | ForEach-Object {
$out = [PSCustomObject]@{ # Note: add any additional inforamtion you want to caputure here
Name = $_.Name
FullPath = $Path
Path = (Split-Path -Path $_.FullName)
Type = $_.GetType().Name.Replace('Info', '')
}
Write-Output $out
}
$Output | Export-Csv -Path $OutCSV -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment