Skip to content

Instantly share code, notes, and snippets.

@AlexKasaku
Created February 18, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexKasaku/1e4380c453b6fb8360aa to your computer and use it in GitHub Desktop.
Save AlexKasaku/1e4380c453b6fb8360aa to your computer and use it in GitHub Desktop.
List contents of folder, ignoring certain folders.
$source = "C:\Sites\bma8"
Set-Location $source
$ignoreFolder = @()
$ignoreFolder += "\Website\App_Data"
$ignoreFolder += "\Website\temp"
$ignoreFolder += "\Data\debug"
$ignoreFolder += "\Data\diagnostics"
$ignoreFolder += "\Data\indexes"
$ignoreFolder += "\Data\logs"
$ignoreFolder += "\Data\mediaIndexing"
$ignoreFolder += "\Data\packages"
$ignoreFolder += "\Data\serialization"
$ignoreFolder += "\Data\Submit Queue"
$ignoreFolder += "\Data\viewstate"
filter Where-NotIgnored {
foreach( $folder in $ignoreFolder ) {
if ($_.FullName -match [Regex]::Escape($source + $folder) ) {
return
}
}
$_
}
Get-ChildItem -Recurse | Where-NotIgnored | Foreach-Object {$_.FullName} > C:\temp\pslist.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment