Powershell Excel Script

Experts,

I am looking for a script to do the following :


CSV1
Server, IP address, Role, Address, Reboot Policy

CSV2
Server, Chassis Address, management IP,

I would like the final CSV to have the following Columns and rows
CSV3
Server, IP Address, Chassis, Management Address, Reboot Policy, Role

I would like to Merge the two CSV's using the server field from CSV2.

This is a little above my scripting level at the moment.
LVL 16
ITguy565Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Try it like that; it creates a hash table of csv2 as lookup, and inserts them as calculated properties into csv1:
$servers2 = @{}
Import-Csv -Path C:\Temp\Servers2.csv | ForEach-Object {$servers2[$_.Server] = $_}
Import-Csv -Path C:\Temp\Servers1.csv |
	Select-Object -Property `
		Server, 'IP address', Role, Address, 'Reboot Policy',
		@{n='Chassis Address'; e={$servers2[$_.Server].'Chassis Address'}},
		@{n='Management IP'; e={$servers2[$_.Server].'Management IP'}} |
	Export-Csv -NoTypeInformation -Path C:\Temp\Servers3.csv

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITguy565Author Commented:
That was exactly what I needed. Thanks!
Senior IT System EngineerIT ProfessionalCommented:
Wow, that's cool, so the hash table can be used just like SQL table to join the two table based on certain criteria ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.