Sometimes speed and efficiency are not that important when writing quick and dirty PowerShell scripts. At other times they are critical. I’ll highlight some of the common mistakes people make when writing PowerShell scripts that cause it to slow to a crawl.
How you write PowerShell can have a significant impact on performance. What seems innocuous when executed once can have a huge impact when executed hundreds or thousands of times in a loop or as part of a bigger script run against many machines.
Let’s go over two of the most common reasons your PowerShell script may be running slow.