r/PowerShell • • Apr 06 '21

Optimizing your $Profile

https://devblogs.microsoft.com/powershell/optimizing-your-profile/
119 Upvotes

24 comments sorted by

View all comments

34

u/Thotaz Apr 06 '21

I wish PS was faster to start in general. Even without any profiles the first launch after a fresh boot is pretty slow regardless of how fast your PC is. On slower/busier PCs it can easily take several seconds and it makes me pick cmd over PS for simple tasks like viewing the IP address or launching a program from a folder with special arguments.

1

u/HeKis4 Apr 07 '21

True. What really kills me is the time it takes for the first tab-completion of a session if you're tab-completing something from a module, like Get-ADUser -Prop *tab*. I could have typed the LDAP query faster than it takes to complete lol.

I think the console basically tries to parse your entire $PsModulePath when you do that, which takes ages especially on HDDs (don't ask me why I'm still using an HDD as a system drive in 2021). This is something that could be optimized a lot, I'm not sure I need my VMWare module ready to go if I'm doing AD work.

0

u/rmbolger Apr 07 '21

I mean, tab completing something from a module means it needs to actually import that module before it can know what to tab complete. And the AD module in particular is rather glacial on initial import. I'd guess it's primarily because it tries to setup the AD:\ drive connection to your default domain and it's even slower if you're on a non-domain joined machine.

0

u/Thotaz Apr 07 '21

The slow tab completion in this situation is because it has to import the module to figure out what parameters are available for the command. If you import the AD module in your $Profile you won't see this happen but this will of course make the initial start up slower.