windows 在 PowerShell 中重置会话

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7254517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:58:13  来源:igfitidea点击:

Resetting the session in PowerShell

windowspowershellpowershell-2.0

提问by tugberk

When I change a setting in my PowerShell profile, I am closing the PowerShell window and reopening it to reset the session.

当我更改 PowerShell 配置文件中的设置时,我将关闭 PowerShell 窗口并重新打开它以重置会话。

I assume there is a better command or cmdlet to refresh the session. Any clue?

我假设有更好的命令或 cmdlet 来刷新会话。有什么线索吗?

采纳答案by JPBlanc

You can just dotsource your profile.

您可以点源您的个人资料。

. $Profile

If your profile handles errors when things like drives, or vars even exists, everything is ok.

如果您的配置文件在驱动器或变量等存在时处理错误,则一切正常。

回答by Shay Levy

You can try and dot-source your profile instead though some things may not work (like trying to redefine constants, etc).

您可以尝试 dot-source 您的个人资料,尽管有些事情可能不起作用(例如尝试重新定义常量等)。

A blog post to restart the shell:

重新启动 shell 的博客文章:

http://scriptolog.blogspot.com/2006/12/restart-your-engins-powershell-way_28.html

http://scriptolog.blogspot.com/2006/12/restart-your-engins-powershell-way_28.html