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:
$server = '${IP}'
$DeleteOlderThan = (Get-Date).AddDays(-365) #files older than a year
$Destination = "\\$server\C$\Windows\Installer\"
Get-ChildItem $Destination -File | Where-Object { $_.LastWriteTime -lt $DeleteOlderThan } | Remove-Item -Include "*.msi" -Force
And this is my Network Path to external program:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "C:\PROGRAMNAME.ps1 '${IP}'"
It seems the ${IP} is not passing in at all.
Any help would be greatly appreciated!