We have a function that does nothing more than check the value of
[System.Environment]::OSVersion.Version for specific values and returns a $true/$false result. I saw a post on Stack Overflow that demonstrated how to do this but it does not appear to work for all variables. When I tried to set the OSVersion value within a Pester test I received the error below.
[-] Error occurred in Context block 327ms
SetValueException: 'OSVersion' is a ReadOnly property.
RuntimeException: 'OSVersion' is a ReadOnly property.
Is there a way to mock these system environment variables or is this a function that simply cannot be tested using mocked values?