我有一个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