gpt4 book ai didi

powershell - Azure DSC VM 扩展 : Why does $Home directory change?

转载 作者:行者123 更新时间:2023-12-03 03:09:00 25 4
gpt4 key购买 nike

环境:PowerShell 版本:5、Windows Server 2016

我的 DSC 在目录中创建一个 Hello World 文件:

$Home\Desktop

我希望映射到C:\Users\<username>\Desktop 。并调用$home.desktop远程虚拟机的 PowerShell 确实会返回桌面目录。但是,当执行 DSC 本身时,该文件会在以下位置创建: C:\Windows\System32\config\systemprofile\Desktop .

以下是 DSC 的副本:

Configuration HelloWorldConfig 
{
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
Node localhost
{
File TestFile {
Ensure = "Present"
DestinationPath = "$Home\Desktop\HelloWorld.txt"
Contents = "Hello World!"
}

}
}

知道为什么会发生这种情况吗?也许 Azure VM 代理是它自己的用户,因此它是 $home目录不在 C:\Users 中,而是C:\Windows\System32\config\systemprofile

最佳答案

Azure DSC 扩展 由作为本地系统C:\Windows\运行的 Azure VM Agent 运行System32\config\systemprofile\Desktop本地系统的桌面。

关于powershell - Azure DSC VM 扩展 : Why does $Home directory change?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41389342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com