# Writing numeric value and decimals to WMI

**URL:** <https://forums.powershell.org/t/writing-numeric-value-and-decimals-to-wmi/15120>\
**Category:** PowerShell Help\
**Created:** [October 21, 2020, 7:48am UTC](https://forums.powershell.org/t/writing-numeric-value-and-decimals-to-wmi/15120 "2020-10-21T07:48:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![siocnarf](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@siocnarf](https://forums.powershell.org/u/siocnarf)\
**Post date:** [October 21, 2020, 7:48am UTC](https://forums.powershell.org/t/writing-numeric-value-and-decimals-to-wmi/15120/1 "2020-10-21T07:48:03Z")

</div>

Hi,

I am tying to get the file size of the Outlook OST file, convert it to GB and storing it in WMI. I may store it in string and it will be working. But I am trying to store it with decimals. And I am losing the decimals.

```
If ($classOST -ine $null) {Remove-WmiObject -Class $Str_ClassNameOST}

[String]$Str_ClassNameOST="Outlook_OST" #Nom de la classe
$WMI_ClassOST = ""
$WMI_ClassOST = New-Object System.Management.ManagementClass("Root\cimv2", $null, $null)
$WMI_ClassOST.name = $Str_ClassNameOST
$classOST = Get-WmiObject -Class $Str_ClassNameOST -List -Namespace 'root\cimv2';

#OST
$colItemsOST = $null
$colItemsOST = (Get-ChildItem "$env:systemdrive\Users\racfr13\AppData\Local\Microsoft\Outlook" -Include *.OST -recurse -Force -ErrorAction SilentlyContinue)
If ($colItemsOST -ine $null) {

Foreach ($OST in $colItemsOST) {

$arglistOST = @{
Name = $($_.Name) #Profile name
OST = $($OST.name).ToString() #Name of the OST
#Size = [math]::Round($OST.length / 1GB,3).ToString() #Size of the OST
Size = [math]::Round($OST.length / 1GB,3) #Size of the OST
LastWrite=$($ost.LastWriteTime).tostring('yyyy-MM-dd hh:mm') #When that profil was evaluate?
}

$WMI_ClassOST.Properties.Add("Name", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["Name"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Properties.Add("OST", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["OST"].Qualifiers.Add("key", $true)

#$WMI_ClassOST.Properties.Add("Size", [System.Management.CimType]:: String, $false)
$WMI_ClassOST.Properties.Add("Size", [System.Management.CimType]:: String, $false)
$WMI_ClassOST.Properties["Size"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Properties.Add("LastWrite", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["LastWrite"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Put()

Set-WmiInstance -Class $Str_ClassNameOST -Puttype CreateOnly -Argument $arglistOST

}
}
```

In this example, arglistOST has a size value of 1,025:

```
[DBG]: PS C:\WINDOWS\system32>> $arglistOSThttps://powershell.org/forums/topic/guide-to-posting-code-2/#post-261015

Name Value

<hr />

OST xxx.ost
LastWrite 2020-10-21 01:01
Name If ($classOST -ine $null) {Remove-WmiObject -Class $Str_ClassNameOST}

[String]$Str_ClassNameOST="Outlook_OST" #Nom de la classe
$WMI_ClassOST = ""
$WMI_ClassOST = New-Object System.Management.ManagementClass("Root\cimv2", $null, $null)
$WMI_ClassOST.name = $Str_ClassNameOST
$classOST = Get-WmiObject -Class $Str_ClassNameOST -List -Namespace 'root\cimv2';

#OST
$colItemsOST = $null
$colItemsOST = (Get-ChildItem "$env:systemdrive\Users\racfr13\AppData\Local\Microsoft\Outlook" -Include *.OST -recurse -Force -ErrorAction SilentlyContinue)
If ($colItemsOST -ine $null) {

Foreach ($OST in $colItemsOST) {

$arglistOST = @{
Name = $($_.Name) #Profile name
OST = $($OST.name).ToString() #Name of the OST
#Size = [math]::Round($OST.length / 1GB,3).ToString() #Size of the OST
Size = [math]::Round($OST.length / 1GB,3) #Size of the OST
LastWrite=$($ost.LastWriteTime).tostring('yyyy-MM-dd hh:mm') #When that profil was evaluate?
}

$WMI_ClassOST.Properties.Add("Name", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["Name"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Properties.Add("OST", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["OST"].Qualifiers.Add("key", $true)

#$WMI_ClassOST.Properties.Add("Size", [System.Management.CimType]:: String, $false)
$WMI_ClassOST.Properties.Add("Size", [System.Management.CimType]:: String, $false)
$WMI_ClassOST.Properties["Size"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Properties.Add("LastWrite", [System.Management.CimType]::String, $false)
$WMI_ClassOST.Properties["LastWrite"].Qualifiers.Add("key", $true)

$WMI_ClassOST.Put()

Set-WmiInstance -Class $Str_ClassNameOST -Puttype CreateOnly -Argument $arglistOST

}
}
```

In this example, arglistOST has a size value of 1,025:

```
[DBG]: PS C:\WINDOWS\system32>> $arglistOST

Name Value

<hr />

OST xxx.ost
LastWrite 2020-10-21 01:01
Name
```

Size 1,025 and keeping the decimals.

How may I store the size in numerical value and keeping the decimals?

---

<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:28pm UTC](https://forums.powershell.org/t/writing-numeric-value-and-decimals-to-wmi/15120/2 "2024-05-16T20:28:44Z")

</div>

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


