I've been getting the same error and I think it's because the specified LogMaxSize limit has been reached, the file isn't in use anywhere else - I was expecting it to rollover to a new log file but this isn't happening.
$session.SessionLogPath = "C:\scripts\logs\logfile.log"
$session.AddRawConfiguration("Logging\LogMaxSize", "1000000")
$session.AddRawConfiguration("Logging\LogMaxCount", "20")
If I try to run the script again, it returns "Error: You cannot call a method on a null-valued expression".
I tried renaming the log file so a new one would be created but it was locked in use - I closed the powershell window which I was using to run the script and was then able to rename the log file.
I opened a new PS session, ran the same script and a new log was created. I deleted this (not locked) and renamed the original back, ran the script again and, sure enough, this time it rolled over to produce a new log with a '.1' suffix.
Not sure what happened the first time, looks like it didn't rollover properly and didn't exit properly either.
$session.SessionLogPath = "C:\scripts\logs\logfile.log"
$session.AddRawConfiguration("Logging\LogMaxSize", "1000000")
$session.AddRawConfiguration("Logging\LogMaxCount", "20")
If I try to run the script again, it returns "Error: You cannot call a method on a null-valued expression".
I tried renaming the log file so a new one would be created but it was locked in use - I closed the powershell window which I was using to run the script and was then able to rename the log file.
I opened a new PS session, ran the same script and a new log was created. I deleted this (not locked) and renamed the original back, ran the script again and, sure enough, this time it rolled over to produce a new log with a '.1' suffix.
Not sure what happened the first time, looks like it didn't rollover properly and didn't exit properly either.