I was recently developing and executing a PowerShell script when I suddenly encountered the following error message:
Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented."
I was very confused by this error message since this was documented as the recommended method of pausing a PowerShell script: http://blogs.technet.com/b/heyscriptingguy/archive/2013/09/14/powertip-use-powershell-to-wait-for-a-key-press.aspx
Unfortunately, what was not mentioned in the article was that it does not work in the PowerShell ISE!
Since I develop ALL of my PowerShell scripts in the PowerShell ISE, this functionality seemed to frustrate me immensely.
I was able to find a workaround that also worked in the PowerShell ISE by following this article: https://adamstech.wordpress.com/2011/05/12/how-to-properly-pause-a-powershell-script/
However, it still irks me that Microsoft has not found a reliable "pause" function that works just as well in the PowerShell console as in the PowerShell ISE.
If you would like Microsoft to remedy this issue for the next release of PowerShell, you should vote for this Microsoft Connect feedback item: https://connect.microsoft.com/PowerShell/feedbackdetail/view/1934336/provide-a-true-pause-function-in-powershell-that-works-both-in-powershell-console-and-powershell-ise
Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented."
I was very confused by this error message since this was documented as the recommended method of pausing a PowerShell script: http://blogs.technet.com/b/heyscriptingguy/archive/2013/09/14/powertip-use-powershell-to-wait-for-a-key-press.aspx
Unfortunately, what was not mentioned in the article was that it does not work in the PowerShell ISE!
Since I develop ALL of my PowerShell scripts in the PowerShell ISE, this functionality seemed to frustrate me immensely.
I was able to find a workaround that also worked in the PowerShell ISE by following this article: https://adamstech.wordpress.com/2011/05/12/how-to-properly-pause-a-powershell-script/
However, it still irks me that Microsoft has not found a reliable "pause" function that works just as well in the PowerShell console as in the PowerShell ISE.
If you would like Microsoft to remedy this issue for the next release of PowerShell, you should vote for this Microsoft Connect feedback item: https://connect.microsoft.com/PowerShell/feedbackdetail/view/1934336/provide-a-true-pause-function-in-powershell-that-works-both-in-powershell-console-and-powershell-ise
No comments:
Post a Comment