查看所有的PowerShell配置文件 2


PowerShell的所有配置文件路径存放在自动化变量$profile中,但是这个家伙默认值显示1/5内容,不信你来看:

PS> $PROFILE
C:\Users\mosser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

那怎样显示其它隐藏的内容呢?-force参数就可以了。

PS> $PROFILE | Format-List -Force

AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\mosser\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\mosser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Length                 : 76

另外取得这些值时,可以像访问属性那样访问即可。

PS C:\> $PROFILE.Length
76
PS C:\> $PROFILE.AllUsersAllHosts
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

该方法参考自:Use PowerShell to Show Path to All Your Profiles

本文链接: https://www.pstips.net/use-powershell-to-show-path-to-all-your-profiles.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

关于 Mooser Lee

我是一个Powershell的爱好者,创建了PowerShell中文博客,热衷于Powershell技术的搜集和分享。本站部分内容来源于互联网,不足之处敬请谅解,并欢迎您批评指正。

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

2 条评论 “查看所有的PowerShell配置文件