Answers:
输入以下命令:
New-item –type file –force $profile
Microsoft.PowerShell_profile.ps1
将为C:\Users\<username>\Documents\WindowsPowerShell\
PowerShell 5及更早版本或C:\Users\<username>\Documents\PowerShell\
PowerShell 6 Core 创建一个文件(此文件夹将自动创建)。
然后编辑此文件,您可以添加个性化的PowerShell功能或加载模块或管理单元...
现在,当您运行Powershell控制台时,Microsoft.PowerShell_profile.ps1
将被触发。
有很多方法可以做到这一点。直接的方法是在默认的Powershell主目录中访问配置文件脚本。
$env:UserProfile\Documents\WindowsPowerShell
。C:\Users\<username>\Documents\WindowsPowerShell
。profile.ps1
。您可以在该文件中编写脚本,并且每次以用户身份启动powershell时都会执行该文件。如果您在其他地方有脚本,则可以profile.ps1
调用这些脚本。另外,默认的配置文件名称应为Microsoft.PowerShell_profile.ps1
。
而且profile.ps1
可行。