Don’t forget the NodeName in your DSC ConfigurationData

Today I created a new configuration data for a DSC configuration and got the following error: all elements of AllNodes need to be hashtable and has a property ‘NodeName’. The config looked good:

$ConfigurationData = @{
    AllNodes = @(
        @{
			DeploymentPath   = "$(${env:ProgramFiles(x86)})\Company\MyProject" 
            ServiceName      = "NameOfService"
            DisplayName      = "Display name of the service."
        }

        @{
            NodeName = $env:Computername
        }
    );
}

AllNodes was a hashtable and it had the desired node name. So where was the error?

I forgot one little thing: the global configuration needs a property NodeName set to an asterisk. Adding this fixed the error.

$ConfigurationData = @{
    AllNodes = @(
        @{
            NodeName         = "*"
			DeploymentPath   = "$(${env:ProgramFiles(x86)})\Company\MyProject" 
            ServiceName      = "NameOfService"
            DisplayName      = "Display name of the service."
        }

        @{
            NodeName = $env:Computername
        }
    );
}

This is really easy – but a search for the error message did not return any useful results. Therefor I decided to share it anyway…

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> Microsoft.TeamFoundation.Release.Common.Helpers.OperationFailedException: Copying recursively from \\someserver\drop\... to C:\Windows\DtlDownloads\Component succeeded.

System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.

all elements of AllNodes need to be hashtable and has a property 'NodeName'.
 +At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:1171 char:30
+             $dataValidated = ValidateUpdate-ConfigurationData $ConfigurationData
+                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CategoryInfo :InvalidOperation: (:) [Write-Error], InvalidOperationException
 FullyQualifiedErrorId :ConfiguratonDataAllNodesNeedHashtable,ValidateUpdate-ConfigurationData
 ---> System.InvalidOperationException: all elements of AllNodes need to be hashtable and has a property 'NodeName'.
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.PowershellExecutor.Invoke(String errorContextMessage, Boolean writeResultToLog, Boolean isCancellable)
   at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.ScriptExecutor.ExecuteScript(IPowerShell powerShell, String script, Boolean useHttp)
   at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.DeploymentService.RunPowerShellScripts(DeploymentMachineSpecification deploymentMachine, ScriptSpecification scriptSpecification, ScriptSpecification initializationScriptSpecification, String applicationPath, IPowerShell powerShellSession)
---> (Inner Exception #0) System.InvalidOperationException: all elements of AllNodes need to be hashtable and has a property 'NodeName'.<---

   at Microsoft.TeamFoundation.Release.EnvironmentProvider.OnPrem.Implementation.OnPremDeploymentProvider.ReadDeploymentResponse(DeploymentResponse response)
   at Microsoft.TeamFoundation.Release.EnvironmentProvider.OnPrem.Implementation.OnPremDeploymentProvider.<RunPowerShellScript>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.TeamFoundation.Release.EnvironmentProvider.OnPrem.Implementation.OnPremDeploymentProvider.<RunScript>d__0.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.TeamFoundation.Release.MonitorServices.Dsc.OnPrem.OnPremDeploymentActions.InvokePlatform(String activityId, MachineSpecification machineSpecification, StorageSpecification storageSpecification, String scriptPath, String configurationPath, Dictionary`2 configurationVariables)
   at Microsoft.TeamFoundation.Release.MonitorServices.Dsc.OnPrem.OnPremDeploymentActions.RunScript(DscComponent dscComponentParameters, String serverName, String userName, String password, String componentName, String scriptPath, String configurationPath, String useCredSecuritySupportProvider, String useHttps, String skipCACheck)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.TeamFoundation.Release.DeploymentAgent.Services.Deployer.Dsc.DscComponentInstaller.InvokeMethodByReflection(String methodArguments)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s