我正在编写PowerShell脚本以在Azure中创建网络。我刚检查了dsc版本在过去两天内从1.5更新到1.6和1.7。因此我在脚本中遇到错误。
dsc已正确应用,但在管理门户中,它会出现以下错误消息 -
启用DSC扩展时出错:无法处理参数 转换参数'ConfigurationFunction'。无法转换 键入“System.Object []”类型的“System.Object []”值 “System.Management.Automation.ConfigurationInfo”。
脚本如下 -
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机器执行时相同的脚本运行正常。 任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
您可以通过运行“Set-AzureVMDscExtension -version 1.5”来使用扩展版本1.5。如果能解决问题,请告诉我
答案 1 :(得分:0)
Nana的解决方法应该可行,但如果您想继续使用最新的扩展,请从配置脚本中删除以下两行。扩展程序为您执行此操作。此外,如果您确实添加了除配置定义之外的任何内容,请确保将输出重定向到null。
示例重定向到null:
Dir > $null
要移除的行:
DomainControllerVM
Start-DscConfiguration -Force -Wait -Verbose -Path .\DomainControllerVM
免责声明:我是通过手机从记忆中完成的。请原谅任何错别字。