How to reload user profile from script file in PowerShell

后端 未结 8 572
情深已故
情深已故 2020-12-29 01:02

I want to reload my user profile from a script file. I thought that dot sourcing it from within the script file would do the trick, but it doesn\'t work:

# f         


        
8条回答
  •  遥遥无期
    2020-12-29 01:47

    I used this to troubleshoot what profile was taking forever to load.

    Start Run:

    powershell_ise -noprofile
    

    Then i ran this:

    function Reload-Profile {
        @(
            $Profile.AllUsersAllHosts,
            $Profile.AllUsersCurrentHost,
            $Profile.CurrentUserAllHosts,
            $Profile.CurrentUserCurrentHost
        ) | % {
            if(Test-Path $_){
                Write-Verbose "Running $_"
                $measure = Measure-Command {. $_}
                "$($measure.TotalSeconds) for $_"
            }
        }    
    }
    
    . Reload-Profile
    

    Thank you @Winston Fassett for getting me closer to finding my issue.

提交回复
热议问题