Hi,
I have a basic DSC script to create IIS AppPools and i’m try to create a foreach loop from Data within a CSV file.
# Nodes $Nodes = @( @{NodeName = "HQWEBSERVER01";Role = "IIS";PSDscAllowPlainTextPassword = $true}, @{NodeName = "HQAPPSERVER01";Role = "APP";PSDscAllowPlainTextPassword = $true}, @{Nodename = "*";Features = "Web-Mgmt-Tools","WEb-Scripting-Tools" , "Web-Mgmt-Service";AppPools = Import-Csv C:\ScriptOutput\groups.csv} ) $Configuration = @{AllNodes = $Nodes;PSDscAllowPlainTextPassword = $true} Configuration DSC_WebServer_Build { param() Import-DscResource -ModuleName "PSDesiredStateConfiguration" Import-DscResource -ModuleName "xSecEdit" Import-DscResource -ModuleName "xSMBShare" Import-DscResource -ModuleName "cNtfsAccessControl" Import-DscResource -ModuleName "xWebAdministration" Node $AllNodes.Where({$_.Role -EQ "IIS"}).NodeName { $Node.Features.Foreach({ WindowsFeature $_ { Name = $_ Ensure = "Present" } # END of WindowsFeatures #END of Foreach Node configuration })# END of all Nodes feature configuration $Node.AppPools.AppPool.foreach({ xWebAppPool $_ { Name = $_ Ensure = "Present" State = "Started" identityType = "SpecificUser" Credential = $DocCreds } }) } } DSC_WebServer_Build -ConfigurationData $Configuration -OutPutPath "C:\ScriptOutput\DSC\WebServer_Build"
So within the CSV is a load of data, with one column containing AppPool names. So i want to get the name of the app pool and create xWebAppPool entry for every AppPool in the CSV.
But when i run the the build it errors:
An exception was raised while processing Node ‘HQWEBSERVER01’: Index operation failed; the array index evaluated to null.
I cant see where i’m going wrong?
Hope this makes sense?
Cheers
TommyQ