Skip to content

Instantly share code, notes, and snippets.

@vannmangel
Last active October 17, 2016 07:19
Show Gist options
  • Save vannmangel/41f5eb5bd935f9245335 to your computer and use it in GitHub Desktop.
Save vannmangel/41f5eb5bd935f9245335 to your computer and use it in GitHub Desktop.
Fetches all servers in AD, filters only VMware nodes and writes the computer names to a text file.
Get-ADComputer -Filter {OperatingSystem -like "*Server*"} -properties * -OutVariable nodes
foreach ($node in $nodes.Name)
{
if (Test-Connection -Quiet -Count 1 -ComputerName $node)
{
if ((gwmi Win32_BIOS -ComputerName $node).serialnumber -match "VMware")
{
Add-Content "\\path-to-txt\txt.txt" "`r$node is running VMmware" -PassThru
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment