# Import-PowerShellDataFile not returning a hashtable of ConfigurationData

**URL:** <https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818>\
**Category:** DSC\
**Created:** [December 7, 2017, 7:05am UTC](https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818 "2017-12-07T07:05:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![woter324](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@woter324](https://forums.powershell.org/u/woter324)\
**Post date:** [December 7, 2017, 7:05am UTC](https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818/1 "2017-12-07T07:05:19Z")

</div>

I’m assuming I’m doing something wrong here. I have the following (stripped down) ConfigurationData.psd1 file as follows:

```
@{
    AllNodes = @(
                     @{
                         NodeName = "*"
                         PSDscAllowPlainTextPassword = $true
                         PSDscAllowDomainUser = $true
                     }
                     @{
                         NodeName = "test"
                         Role = "Blah"
                     }
                 )
}
```

When I run:

```
$ConfigurationData = Import-PowerShellDataFile -Path C:\Temp\ConfigurationData.psd1
```

My understanding is that $ConfigurationData should be a hashtable, but it is returning as an array:

```
PS C:\> $ConfigurationData

Name Value                                                                                                                                                                                                                                                                         
---- -----                                                                                                                                                                                                                                                                         
AllNodes {System.Collections.Hashtable, System.Collections.Hashtable}                                                                                                                                                                                                                  

PS C:\> $ConfigurationData.GetType()

IsPublic IsSerial Name BaseType                                                                                                                                                                                                                                          
-------- -------- ---- --------                                                                                                                                                                                                                                          
True True Object[] System.Array
```

The few examples of I can find, my ConfigurationData.psd1 is correct. I did read a note on here about not using commas between each hash element - contrary to the MS examples.

I am assuming this is the problem, because when I compile my DSC with

```
-ConfigurationData $ConfigurationData
```
, I get the error:

```
Cannot process argument transformation on parameter 'ConfigurationData'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Collections.Hashtable".
```

To add to my confusion further, if I set

```
-ConfigurationData C:\Temp\ConfigurationData.psd1
```
, the DSC compiles without issue, suggesting the problem is not in the ConfigurationData.psd1 file.

Assuming I’m not being an idiot, I wonder if there is a bug in Import-PowerShellDataFile. Therefore, this is running on Windows Server 2012 R2, with PS version 5.1.14409.1005.

Any pointer will be gratefully received.

TIA

---

<div class="post-metadata">

**Author:** ![gaelcolas](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/gaelcolas/32/46_2.png) [@gaelcolas](https://forums.powershell.org/u/gaelcolas)\
**Post date:** [December 7, 2017, 5:25pm UTC](https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818/2 "2017-12-07T17:25:45Z")

</div>

Copy pasting your code (mostly) give me the following:

```
PS C:\Users\Gael> cd C:\src\test

PS C:\src\test> $ConfigurationData = Import-PowerShellDataFile -Path C:\src\test\test.psd1

PS C:\src\test> $ConfigurationData.GetType()

IsPublic IsSerial Name BaseType            
-------- -------- ---- --------            
True True Hashtable System.Object       

PS C:\src\test> $PSVersionTable

Name Value                                           
---- -----                                           
PSVersion 5.1.17046.1000                                  
PSEdition Desktop                                         
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion 10.0.17046.1000                                 
CLRVersion 4.0.30319.42000                                 
WSManStackVersion 3.0                                             
PSRemotingProtocolVersion 2.3                                             
SerializationVersion 1.1.0.1                                         

PS C:\src\test>
```

I’ll try on a server tomorrow, but you should try somewhere else… that’s weird.

---

<div class="post-metadata">

**Author:** ![woter324](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@woter324](https://forums.powershell.org/u/woter324)\
**Post date:** [December 8, 2017, 10:40am UTC](https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818/3 "2017-12-08T10:40:47Z")

</div>

Well, you know what they say, never assume! I was being an idiot.

There was a pending reboot after I manually updated the box.

It works fine now:

```
PS C:\> $configData = Import-PowerShellDataFile -path C:\Temp\ConfigurationData.psd1

$configData.GetType()

IsPublic IsSerial Name BaseType                                                                                                                                                                                                                                          
-------- -------- ---- --------                                                                                                                                                                                                                                          
True True Hashtable System.Object                                                                                                                                                                                                                                     

PS C:\> $PSVersionTable

Name Value                                                                                                                                                                                                                                                                         
---- -----                                                                                                                                                                                                                                                                         
PSVersion 5.1.14409.1005                                                                                                                                                                                                                                                                
PSEdition Desktop                                                                                                                                                                                                                                                                       
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                                                                       
BuildVersion 10.0.14409.1005                                                                                                                                                                                                                                                               
CLRVersion 4.0.30319.42000                                                                                                                                                                                                                                                               
WSManStackVersion 3.0                                                                                                                                                                                                                                                                           
PSRemotingProtocolVersion 2.3                                                                                                                                                                                                                                                                           
SerializationVersion 1.1.0.1
```

Thank you and sorry for being an idiot.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:16pm UTC](https://forums.powershell.org/t/import-powershelldatafile-not-returning-a-hashtable-of-configurationdata/9818/4 "2024-05-16T21:16:36Z")

</div>

Closed on May 16, 2024, 9:16pm UTC


