PowerShell: How To Delete Files Over 30 Days

###################################
# deleteFilesOver30-days.ps1
###################################
# NOTES: 
# "Alt-Shift-Arrow" to select multiple lines
# The line continuation character in Windows PowerShell is the backtick ( ` )
# Parameters in calls to functions in PowerShell (all versions) are space-separated, not comma-separated.
###################################
<#######  ########>


# $workingDirectory = "D:\temp";
$workingDirectory = "\\serverName\dataFolder";
$timeToLive = (Get-Date).AddDays(-30);     ##### FOR FILES OLDER THAN 30 DAYS {AddDays(-30)} #####

Get-ChildItem -Path $workingDirectory -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.LastWriteTime -lt $timeToLive } | Remove-Item -Force;
(Get-ChildItem -Path $workingDirectory -Recurse -Force | Where-Object { $_.PSIsContainer -eq $true }) | Where-Object {$_.GetFileSystemInfos().Count -eq 0 }  | Remove-Item -Force;