Bit of an odd one here. I have several Powershell scripts I've been using for years that end in a pause with the following command:
Write-Host "Done.";
Write-Host "Press any key to continue";
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown");
The main idea being to prevent the window closing and allowing me to review outputs, like AD group memberships and such. We've recently updated our servers to Powershell 5.1 and since the update the pause has been occurring in the wrong place. Instead of the script outputting the results and then pausing, it's now doing the opposite. It seems to be waiting for the script to finish and then providing the results from the script.
Is this a design change that has been put in place in Powershell? If so, is there a new command that will let me get these scripts back to business as usual?