windows 7 - Powershell very slow to open/respond

  • czuroski

    I am having an issue running powershell 3.0 on windows 7 64-bit. It takes a very long time to open/start when run it. It is also quite sluggish in response to just about anything.

    I believe this may be due to the fact that my profile is stored in my documents, and the my documents folder is synched to our network.

    Is there any way that I can move the location of my profile so that I can have it local instead of over the network?

    Thanks for any thoughts.

  • Answers
  • jmreicha

    There are a few different default places the Powershell profile can be stored.

    • The first location is the global location and would be useful when you want all users to have a customized Powershell profile. This profile should be placed in C:\WINDOWS\system32\WindowsPowerShell\v1.0\Profile.ps1.

    • The second location is for the local profile and would be specific to each user account. This file overrides the global configuration file and should be placed in C:\Username\My Documents\WindowsPowerShell\Profile.ps1.

    As a test try modifying the global Powershell profile (located in system32) and see if that speeds things up. If it does you will know the slowness is somehow due to the network and you can move forward from there.

  • Related Question

    windows 7 - how to run a powershell script as administrator
  • Sajee

    On my Windows 7 Desktop, I have script.ps1, which needs admin privileges (it starts a service). I want to click on this script and run it with admin privileges.

    What's the easiest way to accomplish this?

  • Related Answers
  • Kez

    Here is one way of doing it, with the help of an additional icon on your desktop. I guess you could move the script someone else if you wanted to only have a single icon on your desktop.

    1. Create a shortcut to your Powershell script on your desktop
    2. Right-click the shortcut and click Properties
    3. Click the Shortcut tab
    4. Click Advanced
    5. Select Run as Administrator

    You can now run the script elevated by simple double-clicking the new shortcut on your desktop.

  • mjsr

    if you are in the same powershell you could do this:

    Start-Process powershell -verb runas -ArgumentList "-file fullpathofthescript"
  • badp

    Since it's sitting onto your desktop, I'd say the most effortless way to get this done is dragging it onto the elevation gadget.

    Otherwise you could make a separate script using the elevate command on your ps1 script.

    Or, you could apply elevate just to the service-starting bit.

  • Community

    On UAC-enabled systems, to make sure a script is running with full admin privileges, add this code at the beginning of your script:

    function Test-Admin {
      $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    if ((Test-Admin) -eq $false)  {
        if ($elevated) 
            # tried to elevate, did not work, aborting
        else {
            Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
    'running with full privileges'

    when running your script with the -elevated switch, it will attempt to elevate privileges before running.

  • Diogo

    You can run PowerShell scripts in Windows 7 using powershell_ise.

    Step by step instruction can be found here.