Link to home
Start Free TrialLog in
Avatar of String :-)
String :-)Flag for Australia

asked on

Powershell - combine output from get-vm and get-adcomputer into the same CSV.

Wondering how to combine output from get-vm and get-adcomputer into the same CSV.

I am doing a project where I need to update VMWare Tools, but only dev domain joined Windows servers.

I am hoping to combine the outputs from get-vm and get-adcomputer into a master list, and matches records based on "Name".

For example:

$ADServers = Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")}
$VMs = get-vm

CSV includes $VMs.Name, $ADServers.Name, $ADServers.DistinguishedName, $VMs.PowerState

$ADServers.Name and $VMs.Name should match in theory, however not all VMS will be joined to the domain so $ADServers.Name and  $ADServers.DistinguishedName may be empty on some records.

Is this possible?.

Cheers
String :-)
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of String :-)

ASKER

Thanks to both reply's. Both really useful and helpful.  

Dear oBdA, thanks for the help again mate you really are a life saver. This script worked a treat, Currently half way through Jeff Hicks month of lunches book, so Im hoping Ill be able create my own hash tables and arrays soon :-)

Dear Sebastian, thanks for the tip - useful to know!
Cheers
Tom