'How to handle an expression when input is taken from a csv
Beginner with powershell and looking for some help with the @{Label='ID'; expression={??} section please:-
$ID = @()
Import-Csv C:\computers2.csv | ForEach-Object {$ID += $_.ID}
Get-WmiObject -Class Win32_LogicalDisk -ComputerName $ID |
Select-Object -Property DeviceID, @{Label='ID'; expression=
{$ID}},
@{Label='Total (Gb)'; expression={($_.Size/1GB).ToString('F2')}},
@{Label='Free (Gb)'; expression=
{($_.FreeSpace/1GB).ToString('F2')}},
@{label='Percent'; expression={[Math]::Round(($_.freespace /
$_.size) * 100, 2)}} | Format-Table
The output I get is this:-
What I'm trying to achieve would be this:-
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
