1

我的用户配置文件路径在这里与 powershell 一起使用有一点问题。我已将 profile.ps1 设置为此:

$Shell = Host.UI.RawUI
$Shell.WindowTitle="PowerShell obeys me!"
$Shell.BackgroundColor="White"
$Shell.ForegroundColor="Blue"
$size = $Shell.WindowSize
$size.width=120
$size.height=50
$Shell.WindowSize = $size
$size = $Shell.BufferSize
$size.width=120
$size.height=5000
$Shell.BufferSize = $size

但是每次我执行 run poweshell 时,它都会显示一些像这样的错误:

Property 'WindowTitle' cannot be found on this object; make sure it exists and is settable.
At D:\data\d7bighs\Documents\WindowsPowerShell\profile.ps1:5 char:8
+ $Shell. <<<< WindowTitle="PowerShell obeys me!"
    + CategoryInfo          : InvalidOperation: (WindowTitle:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound    

现在是我检查我的个人资料它告诉我这个:

$profile
d:\data\myusername\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

但如果我通过 Windows 资源管理器检查它,它会告诉我:

d:\User\myusername\Documents\WindowsPowerShell\profile.ps1

我在这里感到困惑,因为在资源管理器中告诉我 d:\Useres 但 PS 将其显示为 d:\data...

我该如何更改或强制 PS 照顾 d:\users 而不是 d:\data?

4

1 回答 1

1

一个小错误:$Shell = $Host.UI.RawUI,您可能需要先创建配置文件

 New-Item -Path $PROFILE -Type file

然后编辑它

 notepad  $PROFILE
于 2012-11-01T11:01:35.487 回答