【问题标题】:Running a powershell .ps1 script without loading any profile在不加载任何配置文件的情况下运行 powershell .ps1 脚本
【发布时间】:2020-01-10 19:58:17
【问题描述】:

我正在尝试在 windows 2012R2 中运行 powershell 脚本 5.1 版

powershell 命令控制台上的powershell.exe -NoProfile D:\test2.ps1(我不使用系统上的任何配置文件进行脚本会话)

现在我在 test.ps1 脚本中检查 test.ps1 脚本中加载了哪些配置文件

$个人资料


我得到输出 C:\Users\XXXXX\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

任何个人资料在我的会话中启动的任何想法。

【问题讨论】:

  • 我的理解是$Profile 列出了加载的,而不是已加载的。请记住,它会列出一个不存在的文件。 [咧嘴]

标签: powershell external profile


【解决方案1】:

配置文件未加载,因为您在 powershell.exe 上指定了 -NoProfile。但是,$profile 变量仍被定义。

【讨论】:

    猜你喜欢
    • 2016-01-13
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-20
    相关资源
    最近更新 更多