【问题标题】:Unable to execute DSC file i n Windows server 2012 R2 from remote machine无法从远程计算机执行 Windows server 2012 R2 中的 DSC 文件
【发布时间】:2015-01-16 00:37:22
【问题描述】:

当我对机器执行命令时,我收到以下错误 -

PS C:\Windows\system32> $cimsession = New-CimSession -Credential (Get-Credential -UserName "test" -Message "test") -ComputerName test.cloudapp.net -Port 58718 -SessionOption $cimsessionoption

PS C:\Windows\system32> Get-DscConfiguration -CimSession $cimsession

Get-DscConfiguration : Current configuration does not exist. Execute Start-DscConfiguration command with -Path parameter to specify a 
configuration file and create a current configuration first.
At line:1 char:1
+ Get-DscConfiguration -CimSession $cimsession
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MSFT_DSCLocalConfigurationManager:root/Microsoft/...gurationManager) [Get-DscConfiguration],  
   CimException
    + FullyQualifiedErrorId : MI RESULT 1,Get-DscConfiguration
    + PSComputerName        : powerlabdns.cloudapp.net

这是什么意思?

【问题讨论】:

  • 我正在通过 powershell 更新我的 azure VM。我使用以下命令设置 DSC 扩展 -
  • 我正在通过 powershell 更新我的 azure VM。我使用以下命令设置 DSC 扩展 - $Vm = Set-AzureVMDSCExtension -VM $Vm -ConfigurationArchive "IISInstall.ps1.zip" -ConfigurationName IISInstall 和然后更新 vm - $vm |更新 AzureVM。当我运行以下命令 Get-AzureVMDscExtension -Vm $vm,
  • 我得到以下结果集 - ModulesUrl:chiazurenetwork.blob.core.windows.net/windows-powershell-dsc/… ConfigurationFunction:IISInstall.ps1\IISInstall 属性:{} ExtensionName:DSC 发布者:Microsoft.Powershell 版本:1.* PrivateConfiguration:
  • PublicConfiguration : {"SasToken":"?sv=2014-02-14&sr=b&sig=QpKd51nR2%2FVJPp3Ev6dVcHmclQdXZwweKZ%2FAlEW5A7Y%3D&se=2015-01-16T01%3A16&% Modules=Urlrr"," ":"chiazurenetwork.blob.core.windows.net/windows-powershell-dsc/…n":"IISInstall.ps1\\IISInstall","Properties":[],"ProtocolVersion":{"Major":2,"Minor":0,"Build":0,"Revision ":0,"MajorRevisio n":0,"MinorRevision":0}} 参考名称:DSC 状态:启用角色名称:example-1
  • 我假设当我更新 VM 时,附加的脚本应该被执行到我的 $vm。是这样吗?

标签: powershell azure dsc


【解决方案1】:

您没有执行 DSC 文件,您正在请求当前不存在的 DSC 配置(如错误所示)。

您需要首先运行Start-DscConfiguration,再次按照错误提示运行。您必须将 -Path 传递给该调用,该调用是 MOF 文件(已编译的配置)所在的目录(相对于目标节点)。

完成此操作后,您就可以致电 Get-DscConfiguration 以查看当前配置。

【讨论】:

  • 当我使用 powershell 将其传递给我的虚拟天蓝色机器时,我如何知道目标代码上配置文件的相对路径。我已经用更多细节更新了问题部分,请参考,如果需要更多输入问题,请告诉我。
  • 不幸的是,我实际上并不知道如何在 Azure 中使用 DSC。我知道 Azure 有用于使用 DSC 的特定 cmdlet,但我不知道它是如何工作的。如果这不是 Azure,我会说配置 MOF 需要在目标节点上本地或在它可访问的共享上,你会给它那个路径。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-04
  • 2018-05-24
  • 1970-01-01
  • 2016-03-08
  • 1970-01-01
  • 2014-12-07
相关资源
最近更新 更多