我目前正在设置一个Windows 2019图像与封隔器。我必须在用户文件夹C:\ User \user中复制一些配置文件,该文件无法工作。我尝试过多种方法:
# Copy the files to the image
provisioner "file" {
source = "./config/configfile "
destination = "/tmp/configfile"
}
# Copy the files to the target path var1
provisioner "powershell" {
inline = ["Copy-Item /tmp/configfile -Destination C:/Users/dev_admin/configfile -Force"]
}
# Copy the files to the target path var2
provisioner "windows-shell" {
inline = ["move c:\\tmptmp\\configfile c:\\Users\\dev_admin\\configfile"]
}我甚至尝试将文件复制到/tmp文件夹,并启动一个PowerShell脚本将文件复制到目标路径中。但即使这样也行不通。没有一个命令会抛出错误--它们会返回一个'0‘。
有人知道为什么会这样吗?
最好的
发布于 2022-03-09 10:55:16
你是以管理员身份登录Windows的吗?当我需要运行一些脚本时,我在packer上遇到了一些问题。问题是,在默认情况下,任何命令和脚本都不会与Admin一起运行。解决这一问题的方法是在内置管理帐户上打开Autologin,并运行此帐户中的所有内容。
https://stackoverflow.com/questions/71407780
复制相似问题