PoshCode Archive  Artifact [2c0f68a4e9]

Artifact 2c0f68a4e98f862b72c8ff1f4c935e522a319abcb852797232cd07b7113148e6:

  • File This-script-will-recursively-enumerate-.ps1 — part of check-in [3c1dd41d36] at 2018-06-10 12:56:28 on branch trunk — This script will recursively enumerate your entire server objects, if they all reside under an OU and get the service tag via WMI for each one of them excluding the VMWare guest servers. This is good if you have a lot of servers and don’t want to spend the time having to go to each one of them to manually get the information. (user: unknown size: 1455)

# encoding: ascii
# api: powershell
# title: 
# description: This script will recursively enumerate your entire “server” objects, if they all reside under an OU and get the service tag via WMI for each one of them excluding the VMWare guest servers.  This is good if you have a lot of servers and don’t want to spend the time having to go to each one of them to manually get the information.
# version: 0.1
# license: CC0
# x-poshcode-id: 1122
# x-archived: 2009-05-27T16:32:25
#
#
#You Need Quest AD Powershell Plugin
#You Need VMWare VI Toolkit

$Null = Connect-VIServer Your-VM-Server-Here;

$Servers = New-Object System.Collections.ArrayList

$Null = Get-QADComputer -SearchRoot 'your.domain.com/Path/To/Server/OU' |  Select-Object -property Name | Format-Table -HideTableHeaders| Out-String -Stream | ForEach-Object{$Servers.Add($_.ToString().ToUpper())}
$Null = Get-VM | Select-Object -property Name | Format-Table -HideTableHeaders | Out-String -Stream | ForEach-Object{$Servers.Remove($_.ToString().ToUpper())}


foreach ($Server in $Servers | Sort-Object )
{
	ServiceTag = (Get-WmiObject Win32_BIOS -comp ($Server.ToString().Split(' '))[0]).SerialNumber;
	$Result = New-Object -TypeName psobject;
	$Result | Add-Member -MemberType NoteProperty -Name "Server Name" ($Server.ToString().Split(' '))[0];
	$Result | Add-Member -MemberType NoteProperty -Name "Service Tag" $ServiceTag;
	 
	Write-Output $Result;
	
	
}