Hi All,
I need your help with my script which is data gathering of my storage
I running function which show great data:
function Disktype {
$diskReport = @{}
Get-NcDisk | %{
$diskCapacity = ConvertTo-FormattedNumber ($_.DiskInventoryInfo.BytesPerSector * $_.DiskInventoryInfo.RightSizeSectors)
$id = "$($_.DiskInventoryInfo.DiskType)_$($diskCapacity)"
if ($diskReport.Keys -notcontains $id) {
$diskReport.$($id) = @{ 'Capacity' = 0; 'Count' = 0; }
}
$diskReport.$($id).Capacity += $_.Capacity
$diskReport.$($id).Count++
}
$diskReport.GetEnumerator() | Select @{'N'="DiskType";'E'={ $_.Name }}, @{'N'="TotalRawCapacity";'E'={ ConvertTo-FormattedNumber $_.Value.Capacity }},@{'N'="Count";'E'={ ConvertTo-FormattedNumber $_.Value.Count }}
}
Disktype
I used on [pscustomobject] and trying to add this function to my array, the problem is that i got @{} and in the result it tangles up the context.</p>
my code:
function Disktype {
$diskReport = @{}
Get-NcDisk | %{
$diskCapacity = ConvertTo-FormattedNumber ($_.DiskInventoryInfo.BytesPerSector * $_.DiskInventoryInfo.RightSizeSectors)
$id = "$($_.DiskInventoryInfo.DiskType)_$($diskCapacity)"
if ($diskReport.Keys -notcontains $id) {
$diskReport.$($id) = @{ 'Capacity' = 0; 'Count' = 0; }
}
$diskReport.$($id).Capacity += $_.Capacity
$diskReport.$($id).Count++
}
$diskReport.GetEnumerator() | Select @{'N'="DiskType";'E'={ $_.Name }}, @{'N'="TotalRawCapacity";'E'={ ConvertTo-FormattedNumber $_.Value.Capacity }},@{'N'="Count";'E'={ ConvertTo-FormattedNumber $_.Value.Count }}
}
[pscustomobject]@{
"Volumes count" =$AllVol.count
"Volumes total capacity Size" ="$volsumTBDecimal$TB"
"Volumes total used Size" ="$volusedsumTBDecimal$TB"
"VMware DS free Space" ="$VMwareDSFreeSpaceDecimal$TB out of $VMwareDSFreeSpaceDecimalcapacity$TB"
#"Aggr Used" = Get-NcAggr | Where-Object {$_.state -eq "online"} | select Name,TotalSize,used
"Controllers names and modules" = $qaz -replace '{','' -replace '}','' -replace '@','' -replace ';'," is "
"NetApp OnTAP version:" = $NetApp_OnTAP_version.get-type
"Disk Type and Size" = Disktype
}
Results:
I also got it on “Controllers names and modules”, but I’ve overcome it using “replaces” which were also not easy, how can I show the “disk type and size” in normal table view into my [pscustomobject]array?
to be honest, one property comes with more then 1 value it make my life harder how can add two properties to my array without playing with replace?
