Powershell DSC 1.7版本参数问题
我正在编写PowerShell脚本以在Azure中创建网络。我刚刚检查了dsc版本,在过去两天内从1.5升级到1.6和1.7。因此,我的脚本中出现了错误 dsc已正确应用,但在管理门户中出错,并显示以下消息- 启用DSC扩展时出错:无法处理参数 参数“ConfigurationFunction”的转换。无法转换 要键入的“System.Object[]”类型的“System.Object[]”值 “系统、管理、自动化、配置信息” 脚本如下:Powershell DSC 1.7版本参数问题,powershell,azure,dsc,Powershell,Azure,Dsc,我正在编写PowerShell脚本以在Azure中创建网络。我刚刚检查了dsc版本,在过去两天内从1.5升级到1.6和1.7。因此,我的脚本中出现了错误 dsc已正确应用,但在管理门户中出错,并显示以下消息- 启用DSC扩展时出错:无法处理参数 参数“ConfigurationFunction”的转换。无法转换 要键入的“System.Object[]”类型的“System.Object[]”值 “系统、管理、自动化、配置信息” 脚本如下: Configuration DomainControl
Configuration DomainControllerVM
{
Node localhost
{
Script DomainControllerVM
{
SetScript = {
$Pass = 'Test'
$credpass = ConvertTo-SecureString -String $Pass -AsPlainText -Force
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Install-ADDSForest -DomainName corp.contoso.com -DatabasePath "C:\NTDS" -SysvolPath "C:\SYSVOL" -LogPath "C:\Logs" -SafeModeAdministratorPassword $credpass -Force
#insert password twice when prompted
#Log to the machine using CORP\[Local administrator account name]
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -enabled True
winrm quickconfig
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
}
TestScript = {
return $false
}
GetScript = { <# This must return a hash table #> }
}
}
}
Set-StrictMode -Off
DomainControllerVM
Start-DscConfiguration -Force -Wait -Verbose -Path .\DomainControllerVM
[2015-02-25T20:25:17] Executing DSC Extension
[2015-02-25T20:25:17] File lock does not exist: begin processing
[2015-02-25T20:25:17] Reading handler environment from C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\..\HandlerEnvironment.json
[2015-02-25T20:25:19] Reading handler settings from C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\RuntimeSettings\0.settings
[2015-02-25T20:25:20] Applying DSC configuration:
[2015-02-25T20:25:20] Sequence Number: 0
[2015-02-25T20:25:20] Configuration Package URL: https://~/windows-powershell-dsc/DomainControllerVM.ps1.zip
[2015-02-25T20:25:20] Configuration Container: DomainControllerVM.ps1
[2015-02-25T20:25:20] Configuration Function: DomainControllerVM (0 arguments)
[2015-02-25T20:25:20] Configuration Data URL:
[2015-02-25T20:25:20] Certificate Thumbprint: 979C0B1CB40273DE0485B63AD45F59AA6E7DE2F6
[2015-02-25T20:25:21] Using existing working directory: C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\..\DSCWork\DomainControllerVM.ps1.0
[2015-02-25T20:25:21] Applying DSC configuration DomainControllerVM.ps1\DomainControllerVM
[2015-02-25T20:25:21] Writing handler status to C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\Status\0.status
[2015-02-25T20:25:21] Looking for the definition of the configuration function.
[2015-02-25T20:25:21] Executing script: C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\..\DSCWork\DomainControllerVM.ps1.0\DomainControllerVM.ps1
Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
An LCM method call arrived from computer CHINEWN with user sid S-1-5-18.
An LCM method call arrived from computer CHINEWN with user sid S-1-5-18.
[CHINEWN]: LCM: [ Start Set ]
[CHINEWN]: LCM: [ Start Resource ] [[Script]DomainControllerVM]
[CHINEWN]: LCM: [ Start Test ] [[Script]DomainControllerVM]
[CHINEWN]: LCM: [ End Test ] [[Script]DomainControllerVM] in 1.5140 seconds.
[CHINEWN]: LCM: [ Start Set ] [[Script]DomainControllerVM]
[CHINEWN]: [[Script]DomainControllerVM] Performing the operation "Set-TargetResource" on target "Executing the SetScript with the user supplied credential".
[CHINEWN]: [[Script]DomainControllerVM] Installation started...
[CHINEWN]: [[Script]DomainControllerVM] Installation succeeded.
Verification of prerequisites for Domain Controller promotion failed. The specified argument 'DataBasePath' was not recognized.
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : Test.VerifyDcPromoCore.DCPromo.General.77,Microsoft.DirectoryServices.Deployment.PowerShell.Commands.InstallADDSForestCommand
+ PSComputerName : localhost
[CHINEWN]: LCM: [ End Set ] [[Script]DomainControllerVM] in 24.1760 seconds.
The PowerShell DSC resource MSFT_ScriptResource threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : NonTerminatingErrorFromProvider
+ PSComputerName : localhost
The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
Operation 'Invoke CimMethod' complete.
Time taken for configuration job to complete is 35.692 seconds
[2015-02-25T20:26:02] Preparing configuration arguments.
[2015-02-25T20:26:02] Removing file lock
C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensionHandler.ps1 : Error enabling the DSC Extension: Cannot process argument transformation on parameter 'ConfigurationFunction'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Management.Automation.ConfigurationInfo".
At line:7 char:2
+ C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,DscExtensionHandler.ps1
[2015-02-25T20:26:02] Writing handler status to C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\Status\0.status
但是当从目标azure机器执行时,相同的脚本可以正常工作。
非常感谢您的帮助。您可以通过运行“Set-AzureVMDscExtension-version 1.5”来使用该扩展的1.5版。让我知道这是否解决了问题Nana的解决方案应该有效,但是如果您想继续使用最新的扩展,请从配置脚本中删除以下两行。分机为您做这件事。此外,如果添加了配置定义以外的任何内容,请确保将输出重定向到null 重定向到null的示例:
Dir>$null
要删除的行:
DomainControllerVM
Start-DscConfiguration -Force -Wait -Verbose -Path .\DomainControllerVM
免责声明:这一切都是我在手机上凭记忆完成的。请原谅任何打字错误