2 ms·
Had a script that managed disk space on windows servers. The config file was xml, and Powershell did not treat the commented child element as nothing, it import
by mickotron 5y ago
Had a script that managed disk space on windows servers. The config file was xml, and Powershell did not treat the commented child element as nothing, it imported a blank child element in the PSObject.
So when it ran it looked in blank directory (default c:\windows\system32), for blank conditions. Zip filetype matching blank. Delete files over blank age.
These servers were rebuilt over a weekend, and the script was scheduled again, and broke these servers again, requiring another rebuild.
When I came in on Monday, I was told that the script had caused this carnage. I didn't believe them until I read the debug logs in horror.
Luckily the config was specific yo a subset of servers, but they happened to be servers that were responsible for police GPS radios to function.
Suffice to say it now has a lot of defensive programming in it to test the config file and resulting config object before doing anything.