When I change a setting in my PowerShell profile, I am closing the PowerShell window and reopening it to reset the session.
I assume there is a better command or cmdlet to refresh the session. Any clue?
Use the Update-SessionEnvironment command to refresh the current PowerShell session with all environment settings possibly performed by Chocolatey package installs.
The idea is if you are in ISE, it will restart ISE. If you are in plain PowerShell, it will restart plain PowerShell. Get-PSHostProcessInfo returns information about the current PowerShell session which allows you to determine whether or not you are running ISE or not.
To delete all the PSSessions in the current session, type Get-PSSession | Remove-PSSession . A PSSession uses a persistent connection to a remote computer. Create a PSSession to run a series of commands that share data.
You can restart a windows service by using the Powershell cmdlet Restart-Service. Here, the parameter -PassThru force the command to wait until the service get restarted completed and displays its running status.
You can just dotsource your profile.
. $Profile
If your profile handles errors when things like drives, or vars even exists, everything is ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With