Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Import-Csv with multiple rows and columns

$
0
0

I have tried to sift through the forums for answers but I am unable to find anything or I am not understanding.

 

I have a CSV file... Example:

Server,Memory,DiskGB
DC-DAL-01,16,250
DC-DAL-02,16,250
PFS-DAL-01,32,1500

 

My Script is:

 

$strData=Import-Csv-Path'C:\Scripts\input\New Servers.csv'
$strData | foreach {Write-Output"Set-VM -VM $_.Server -NumCpu $_.Memory -MemoryGB $_.DiskGB -WhatIf"}

 

 

The output:

Set-VM -VM @{Server=DC-DAL-01; Memory=16; DiskGB=250}.Server -NumCpu @{Server=DC-DAL-01; Memory=16; DiskGB=250}.Memory -MemoryGB @{Server=DC-DAL-01; Memory=16; DiskGB=250}.DiskGB -Wh
atIf
Set-VM -VM @{Server=DC-DAL-02; Memory=16; DiskGB=250}.Server -NumCpu @{Server=DC-DAL-02; Memory=16; DiskGB=250}.Memory -MemoryGB @{Server=DC-DAL-02; Memory=16; DiskGB=250}.DiskGB -Wh
atIf
Set-VM -VM @{Server=PFS-DAL-01; Memory=32; DiskGB=1500}.Server -NumCpu @{Server=PFS-DAL-01; Memory=32; DiskGB=1500}.Memory -MemoryGB @{Server=PFS-DAL-01; Memory=32; DiskGB=1500}.Disk
GB -WhatIf

 

I have not been able to shake the Column title off of the output.  What am I doing wrong, this seems like it should be pretty simple. ha.

 

This file can grow in rows and columns in the future.


Viewing all articles
Browse latest Browse all 8583

Trending Articles