Hi All
Below is the existing data I have in my csv file
"Server","Disk ###","Status","Size","Free"
"s1","Disk 0","Online","100 GB","1024 KB"
"s1","Disk 1","Online","6144 MB","1024 KB"
"s1","Disk 2","Online","200 GB","1024 KB"
"s1","Disk 3","Online","10 GB","1024 KB"
and below is the additional column which I want to append getting from get-disk command need to add at the end after
Free column
TotalSize
---------
100.00 GB
6.00 GB
200.00 GB
10.00 GB
Getting output like
<pre>"Server","Disk ###","Status","Size","Free","TotalSize"
"s1","Disk 0","Online","100 GB","1024 KB","Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData"
"s1","Disk 1","Online","6144 MB","1024 KB","Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData"
"s1","Disk 2","Online","200 GB","1024 KB","Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData"
"s1","Disk 3","Online","10 GB","1024 KB","Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData"
Please let me know what I am missing here
What I have tried:
$dataa= Get-Disk | Select-Object -Property @{n="TotalSize";e={'{0:n2} GB' -f ($_.Size / 1GB)}} | ft
Import-Csv -path c:\infile.csv |
Select-Object *,@{Name='TotalSize';Expression={$dataa}} |
Select-Object "Server","Disk ###","Status","Size","Free", "TotalSize" |
Export-Csv -path C:\Outfile.csv -NoTypeInformation