[英]Powershell DSC - Unzip file to remote destination
我的目标是创建Powershell DSC配置,以从本地计算机将文件解压缩到Hyper-V Win10 VM上的远程目录(我已经共享了该目标文件夹)。 但是,现在,将VM凭据插入.ps1仍然有一些问题。 这是我的代码:
Configuration CopyTest {
Node 'localhost'
{
User Admin
{
UserName = "Admin"
Password = "Password"
Ensure = "Present"
}
Archive ArchiveExample {
Ensure = 'Present'
Path = 'C:\Users\myuser\Documents\test.zip'
Destination = '\\DESKTOP-HEFLNJ6\destination'
}
}
}
谁能建议我一种在Powershell脚本中插入Windows凭据的方法?
感谢您的宝贵时间...希望可以为您提供帮助!
您将必须在DSC配置中使用凭据。 以下文档将帮助您实现这一目标。
https://docs.microsoft.com/zh-cn/powershell/dsc/runasuser
下面是一个在DSC配置中使用凭据的小示例。
configuration FileCopy
{
Param(
[PSCredential]$Credential
)
node localhost
{
File CopyFile{
Ensure = 'Present'
DestinationPath = '\\server\share'
SourcePath = 'c:\sourcepath'
PsDscRunAsCredential = $Credential
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.