标签: powershell-dsc

在DSC复合资源中使用变量

我对PowerShell DSC相当新,对此的回答可能非常明显,但我找不到任何地方描述的类似问题.

我有一个PowerShell DSC复合资源,可以下载一些MSI并运行它们.下载文件的目录在几个地方被引用,所以我试图将它存储在一个变量中.但是,当我来应用使用此资源的配置时,Start-DscConfiguration值始终显示为null.

以下是资源的示例:

Configuration xExample {

  Import-Module -ModuleName 'PSDesiredStateConfiguration'

  $path = 'C:\Temp\Installer.msi'

  Script Download {
    SetScript = { 
      Invoke-WebRequest -Uri "..." -OutFile $path 
    }
    GetScript = {
      @{ 
        Result = $(Test-Path $path)
      }
    }
    TestScript = {
      Write-Verbose "Testing $($path)"
      Test-Path $path
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

当执行此资源时,详细输出显示"Testing",并且Test-Path由于Path参数为null ,调用失败.

我已经尝试$path在配置之外声明变量并且使用$global无效.

我错过了什么?

powershell powershell-dsc

4
推荐指数
1
解决办法
2309
查看次数

使用DSC资源配置HKEY_CURRENT_USER实际上会更新HKEY_USERS \ .DEFAULT

下面的DSC声明而不是HKEY_CURRENT_USER \ Console写入注册表项HKEY_USERS.DEFAULT \ Console。为什么?

Registry ConsoleFaceName
{
  Key         = 'HKEY_CURRENT_USER\Console'
  ValueName   = "FaceName"
  ValueData   = "Lucida Console"
  Ensure      = "Present"
}
Run Code Online (Sandbox Code Playgroud)

dsc powershell-dsc

2
推荐指数
1
解决办法
663
查看次数

Azure DSC - 使用 SAS 从存储帐户复制文件 - 错误“不支持相对路径”

当我尝试使用 DSC 将网站(甚至是单个文件)复制到 VM 时,配置如下:

    File WebSiteContent {
        Ensure = "Present"              
        SourcePath = "https://MYBLOB.blob.core.windows.net/prod/index.html?sv=2016-05-31&ss=b&srt=s&sp=rl&se=2017-11-29T21:47:36Z&st=2017-07-26T13:47:36Z&spr=https&sig=SIG_HERE"
        DestinationPath = "C:\inetpub\backend\app_data" 
        Type = "Directory"
    }
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

[ERROR] Relative path is not supported. The related file/directory is: https://MYBLOB.blob.core.windows.net/prod/index.html?sv=2016-05-31&ss=b&srt=s&sp=rl&se=2017-11-29T21:47:36Z&st=2017-07-26T13:47:36Z&spr=https&sig=SIG_HERE. \r\n

不知道是什么原因,因为这是文件的绝对路径。任何使其工作的建议表示赞赏:)

azure powershell-dsc

2
推荐指数
1
解决办法
1709
查看次数

标签 统计

powershell-dsc ×3

azure ×1

dsc ×1

powershell ×1