我有一個PowerShell腳本,將刪除至少X天的文件。我想知道如何在刪除文件之前將其更改爲打印文件。腳本是如何在刪除文件之前打印文件的名稱/路徑?
$limit = (Get-Date).AddDays(-45)
$path = "\\noc2-storage\IT_Backup\Daily_SQL\" #"
# Delete files older than the $limit.
echo "Deleting files: "
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
# Delete any empty directories left behind after deleting the old files.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse
定義「打印」 - 輸出到屏幕上,或實際上是紙張複印? –
輸出到屏幕 – kevorski