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

Assigning output of two Get commands to a single variable

$
0
0

Hello, 

I am trying to build a list of servers based on results from AD and vSphere and combine them to a single variable to use later in my script.

I just cant figure how to process booth in a loop to create an array variable $Computers

 

$ADComps = Get-ADComputer  -Filter {OperatingSystem -like "*Server*"} | select -expandproperty DNSHostname

$VMComps = Get-VM | Get-VMGuest | ? {$_.OSFullName -notlike "*Server*"} | ? {$_.OSFullName -notlike "*Linux*"} | ? {$_.OSFullName -notlike "*Cent*"} | ? {$_.OSFullName -notlike "*other*"} | ? {$_.OSFullName -notlike $Null} |? {$_.State -notlike "*NOT*"} | Select HostName

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles