I have a PS script that will delete msi files that are older than 1 year. I set up an alert to trigger if there's less than 2gb of space left on the C:\ drive. I want this script to execute against the triggered node. How do i pass in the node that was triggered to the script?
Here's my code:
$DeleteOlderThan = (Get-Date).AddDays(-365) #files older than a year
$Destination = "C:\Windows\Installer\" #path
Get-ChildItem $Destination -File | Where-Object { $_.LastWriteTime -lt $DeleteOlderThan } | Remove-Item -Include "*.msi" -Force #delete msi files