This Script give Hardware info on which VM is running.
Import-Csv -Path <File Path>| foreach {
get-vm $_.VirtualServer | Get-VMHost |Sort Name |Get-View |`
Select Name, `
@{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},`
@{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},`
@{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} } | export-csv <File Path>
Output Example
| VirtualServer |
ESXi |
Hardware |
Processor Details |
Memory |
| SRV-P-VM01 |
esx01 |
HP ProLiant BL460c G7 |
PROC:2 CORES:12 MHZ: 3067 |
192 GB |
| SRV-P-VM02 |
esx02 |
HP ProLiant BL460c G6 |
PROC:2 CORES:8 MHZ: 2800 |
192 GB |
###################################################################################################
#List of Variables:NameScript, OSType, FullName, OrgName, ChangeSid, Type, DnsServer, DnsSuffix, #
# TimeZone, GuiRunOnce, NamingScheme, NamingPrefix, ProductKey, Description, #
# IpMode, IpAddress,SubnetMask, DefaultGateway, AlternateGateway, Dns, Template, #
# EsxHost, Datastore, NumCpu,MemoryMB, NetworkName #
###################################################################################################
#load PowerCLI snap-in
Add-PSSnapin VMware.VimAutomation.Core
#Connect the vCenter
Connect-VIServer -Server <IP Address> -User <UserName> -Password <Password>
#Import the file. Please select the Path
Import-Csv <File Path of the Source CSV> | foreach {
#New-OSCustomizationSpec Creation of new OS Customization spec
New-OSCustomizationSpec -Name $_.NameScript -OSType $_.OSType -Description “$_.Description” -NamingScheme $_.NamingScheme -NamingPrefix $_.NamingPrefix -FullName $_.FullName -OrgName $_.OrgName -ChangeSid -Type $_.type -DnsServer $_.DnsServer -DnsSuffix $_.DnsSuffix -TimeZone $_.TimeZone -Workgroup “Workgroup” -AdminPassword “<Password for Admin>”
Get-OSCustomizationSpec $_.NameScript | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.IPAddress -SubnetMask $_.SubnetMask -DefaultGateway $_.DefaultGateway -Dns $_.Dns -AlternateGateway $_.AlternateGateway
New-VM -Name $_.NamingPrefix -Template $_.Template -VMHost $_.EsxHost -Datastore $_.Datastore -OSCustomizationSpec $_.NameScript -Confirm:$false -Location “<Folder Name>”
}