I've been using PowerShell (pwsh.exe) daily and really enjoy it, but I've noticed that it's generally much slower compared to CMD.exe. Can anyone explain why that is and if there are ways to improve PowerShell's performance?
3 Answers
The reason for the speed difference is that CMD and PowerShell are built differently. CMD simply starts up with the environment variables, while PowerShell loads multiple modules, profiles, and a lot of .NET classes, which makes it slower. You can try launching PowerShell without a profile or limit the modules it loads to speed things up a bit. If CMD works better for your tasks, it's perfectly fine to stick with it until you need PowerShell's features.
Have you tried using clink? It's a command line wrapper for CMD that can offer better performance and features. If PowerShell is slow for you, consider running powershell.exe instead of pwsh.exe, as it may be slightly faster for certain tasks. Also, check your antivirus settings and look into the files loaded by `$profile | fl *`, as those can add to the loading time.
Are you using Windows Terminal to run PowerShell? You might want to try running pwsh.exe without it. Just launching it with the command 'pwsh.exe -NoProfile' can speed things up. Personally, I noticed the loading time dropped significantly when I did that!
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically