# DBNull Help

**URL:** <https://forums.powershell.org/t/dbnull-help/249>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/dbnull-help/249 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/dbnull-help/249/1 "2011-12-31T18:30:00Z")

</div>

by sqlspy at 2012-10-12 04:26:53

> Hi,  
>   
> I’m getting a DBNull error message when trying to load data into a DataTable object. Can anyone suggest a fix? Many Thanks!  
>   
> `$os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Server$table = New-Object system.Data.DataTable â€œ$Serverâ€$col01 = New-Object system.Data.DataColumn BootDevice,([string])$col02 = New-Object system.Data.DataColumn BuildNumber,([string])$col03 = New-Object system.Data.DataColumn PAEEnabled,([Boolean])$table.columns.add($col01)$table.columns.add($col02)$table.columns.add($col03)$row = $table.NewRow();$row.BootDevice = $os.BootDevice;$row.BuildNumber = $os.BuildNumber;$row.PAEEnabled = $os.PAEEnabled;`  
> Exception setting "PAEEnabled": "Cannot set Column ‘PAEEnabled’ to be null. Please use DBNull instead."  
> At C:\Users\kdal321\AppData\Local\Temp\2\2134e5f7-6c9c-47d8-804a-b26a0b1b929c.ps1:19 char:6  
> + $row. \<\<\<\< PAEEnabled = $os.PAEEnabled;  
> + CategoryInfo : InvalidOperation: (🙂 , RuntimeException  
> + FullyQualifiedErrorId : PropertyAssignmentException

by JeffH at 2012-10-12 04:49:37

> The problem is most likely that the PAEEnabled property is empty in WMI. You will need to test it first.  
>   
> `if ($os.PAEEnabled) { $row.PAEEnabled = $os.PAEEnabled}else { $row.PAEEnabled = $False}`

by sqlspy at 2012-10-12 05:40:57

> Perfect, thanks Jeff.

---

<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, 8:58pm UTC](https://forums.powershell.org/t/dbnull-help/249/2 "2024-05-16T20:58:08Z")

</div>

Closed on May 16, 2024, 8:58pm UTC


