1

After a few months of using PowerShell, I recently found that my profile was loading much more slowly than normal. After a few more weeks, it has gotten to the point where loading my profile takes upwards of 16 seconds. It used to take less than 1 second to load. This problem appears every time I start PowerShell: even when I close it out and immediately start it again. No other aspect of PowerShell is affected by the problem- compiling programs and running scripts take the same amount of time they always have on my computer. What could be causing such ludicrous start up times? My Profile information is below, as well as the message that greets me after PowerShell finally loads.

Start Up Message:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

Loading personal and system profiles took 16371ms.
PS C:\Users\Zander Ackerman>

Profile Information

function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
if($p -and $v){
    Set-Item -path env:$p -value $v
}
}
}

Get-Batchfile("c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat") 2> $null
  • I don't know about the slowness, but your function call is using incorrect syntax. It should be Get-Batchfile "C:\.... (We don't use parentheses to call functions in PowerShell.) – Bill_Stewart Apr 6 '17 at 21:31
  • The code was mandated by my school. I don't know PowerShell, unfortunately, so I don't even know if it does whatever the writer intended it to do. :/ I am pretty sure it is intended to load stuff for Visual Studio and compile stuff, considering the file the function gets used on. Either way, it used to load in less than a second, and it is now up to more than 21 seconds. I'm not sure what to do. – Zander Ackerman Apr 6 '17 at 23:30
  • 1
    Sounds like an issue for your school to address. – Bill_Stewart Apr 7 '17 at 0:44
  • The behaviour randomly stopped one day. Load times are back down to when I first started using PowerShell. No changes to my profile were made. – Zander Ackerman Apr 20 '17 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.