I had tried removing the -UseBasicParsing from the Invoke-WebRequest commands, but it has a bad side effect. It seemed to work fine, but I noticed after months of running it that instances of iexplorer.exe don't close properly after the command uses it internally. The effect was that I had around 40 instances that don't terminate. The number possibly just keep growing until the server is rebooted.
So, keep that switch on those statements to avoid having the commandlet using IE internally and have this issue.
I had tried removing the -UseBasicParsing from the Invoke-WebRequest commands, but it has a bad side effect. It seemed to work fine, but I noticed after months of running it that instances of iexplorer.exe don't close properly after the command uses it internally. The effect was that I had around 40 instances that don't terminate. The number possibly just keep growing until the server is rebooted.
So, keep that switch on those statements to avoid having the commandlet using IE internally and have this issue.