11 lines
501 B
PowerShell
11 lines
501 B
PowerShell
$ImportCsv = Import-Csv -Path 'D:\OneDrive - State of North Dakota\CleanupFileLocations.csv'
|
|
|
|
$FilesToDelete=@()
|
|
ForEach($Directory in $ImportCsv) {
|
|
$GetChildItemParams = @{
|
|
Path = $Directory.Path
|
|
}
|
|
If($Directory.Filter){$GetChildItemParams += @{Filter = $Directory.Filter}}
|
|
If($Directory.Recursive -eq $true){$GetChildItemParams += @{Recurse = $true}}
|
|
$Files = Get-ChildItem @GetChildItemParams | Where-Object LastWriteTime -lt (Get-Date).AddDays(-$Directory.DaysToKeep)
|
|
} |