I think the following happens:
You are trying to request a webpage using GetResponse (). This is not performed, therefore the following expressions are executed with the values set in the previous run. This leads to the output you described.
I personally use invoke-webrequest in my scripts. This simplifies error handling, as it supports all common parameters, such as Erroraction, etc.
Tomg
source share