[英]Powershell DSC - Download MSI file to VM
我嘗試過以下示例從Azure blob或Azure文件共享下載,但從未成功。 是否可以通過憑據或密鑰將文件下載到VM?
Import-DSCResource -ModuleName PSDesiredStateConfiguration, xPSDesiredStateConfiguration
Node webServer
{ xRemoteFile Installs
{
DestinationPath = "C:\Scripts"
Credential = $StorageCredential
Ensure = "Present"
SourcePath = "https://storagename.blob.core.windows.net/installs"
Type = "Directory"
Recurse = $true
}
}
我還嘗試了使用文件模塊。
Import-DSCResource -ModuleName PSDesiredStateConfiguration, xPSDesiredStateConfiguration
Node webServer
{
File Installs
{
DestinationPath = "C:\Scripts"
Credential = $StorageCredential
Ensure = "Present"
SourcePath = "\\storagename.file.core.windows.net\installs"
Type = "Directory"
Recurse = $true
}
}
如果從Azure File Share下載文件,則可以參考此示例 。 將以下腳本添加到您的腳本中。
Configuration SimpleExampleWithCredentials {
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[PSCredential]$Credentials
)
如果您使用經典VM,則可以使用以下cmdlet。
Set-AzureVMDscExtension -VM $vm -ConfigurationArchive MyConfiguration.ps1.zip -ConfigurationName MyConfiguration -ConfigurationArgument @{ storageCredential= (Get-Credential) }
如果使用ARM VM,則應使用cmdlet Set-AzureRmVMDscExtension 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.