0

I am writing the PowerShell scripts to create network in Azure. I just checked the dsc version got updated from 1.5 to 1.6 and 1.7 in last two days. Due to which I am getting error within my scripts.

The dsc gets applied properly but in the management portal it errs out with the following message -

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".

The script is as follows -

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

The log is as follows -

[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

But the same script when execute from the target azure machine works fine. Any help would be highly appreciated.

4

2 回答 2

0

Nana 的解决方法应该有效,但如果您想继续使用最新的扩展,请从配置脚本中删除以下两行。扩展为您执行此操作。此外,如果您确实添加了配置定义以外的任何内容,请确保将输出重定向到 null。

重定向到 null 的示例: Dir > $null

要删除的行:

 DomainControllerVM
 Start-DscConfiguration -Force -Wait -Verbose -Path .\DomainControllerVM

免责声明:我从记忆中在手机上完成了这一切。请原谅任何错别字。

于 2015-03-10T06:58:13.567 回答
0

您可以通过运行“Set-AzureVMDscExtension -version 1.5”来使用 1.5 版的扩展。让我知道这是否能解决问题

于 2015-03-06T01:07:53.237 回答