@{n='OS';e={($_ | get-view).config.guestfullname}}\n<\/code><\/pre>\nand you have to figure out the rest<\/p>","upvoteCount":0,"datePublished":"2021-12-17T16:26:09.000Z","url":"https://community.spiceworks.com/t/get-vm-inventory/819884/5","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
Thanks. I got the other ones but I could not figure out how to get vLAN info<\/p>","upvoteCount":0,"datePublished":"2021-12-17T17:29:15.000Z","url":"https://community.spiceworks.com/t/get-vm-inventory/819884/6","author":{"@type":"Person","name":"spiceuser-9q9iv","url":"https://community.spiceworks.com/u/spiceuser-9q9iv"}},{"@type":"Answer","text":"
I got the script going but it does not generate the MAC and Subnet. It just leaves the columns blank in the csv file. Any help to fix this would be greatly appreciated. Thanks<\/p>\n
==========================<\/p>\n
Connect-VIServer x.x.x.x \n$VMs = Get-VM (Get-Content c:\\temp\\computers.txt) \n$Output = foreach ($VM in $VMs){ \nGet-VM $VM | select Name, \n@{N=”FolderName”;E={ $.Folder.Name}}, NumCpu, MemoryGB, \n@{N=”CPUUsage”;E={ $<\/em>.ExtensionData.Summary.QuickStats.OverallCpuUsage}}, \n@{N=”MemoryUsage”;E={$.ExtensionData.Summary.QuickStats.GuestMemoryUsage}}, ProvisionedSpaceGB, UsedSpaceGB, PowerState, VMHost, \n@{N=”Datastore”;E={$<\/em>.ExtensionData.Config.DatastoreUrl.Name}}, \n@{N=”Network”;E={$.Guest.Nics[0]}}, \n@{N=”IPAddress”;E={$<\/em>.Guest.IPAddress[0]}}, \n@{N=”DNSName”;E={$.ExtensionData.Guest.Hostname}}, \n@{N=”OS”;E={($<\/em> | get-view).config.guestfullname}}, \n@{N=‘VLAN’;E={[string]::Join(‘,’,(Get-NetworkAdapter -Vm $vm | Select-Object -ExpandProperty NetworkName))}}, \n@{N=‘Tools’;E={$vm.ExtensionData.Guest.ToolsRunningStatus}}, \n@{N=‘Gateway’;E={[string]::Join(‘,’,($vm.ExtensionData.Guest.IpStack.IpRouteConfig.IpRoute | %{if($.Gateway.IpAddress){$<\/em>.Gateway.IpAddress}}))}}, \n@{N=‘Subnet Mask’;E={<\/p>\n$dec = [Convert]::ToUInt32($((‘1’ * $_.IpConfig.IpAddress[0].PrefixLength).PadRight(32, ‘0’)), 2)<\/p>\n
$DottedIP = $( For ($i = 3; $i -gt -1; $i–) {<\/p>\n
$Remainder = $dec % [Math]::Pow(256, $i)<\/p>\n
( $dec - $Remainder) / [Math]::Pow(256, $i)<\/p>\n
$dec = $Remainder<\/p>\n
} )<\/p>\n
[String]::Join(‘.’, $DottedIP)<\/p>\n
}},<\/p>\n
@{N=“DNS”;E={[string]::Join(‘,’,($vm.ExtensionData.Guest.IpStack.DnsConfig.IpAddress))}},<\/p>\n
@{N=‘MAC’;E={[string]::Join(‘,’,$_.MacAddress)}} \n} \n$Output | Export-Csv C:\\Temp\\Result.csv -NoTypeInformation<\/p>\n
=============<\/p>","upvoteCount":0,"datePublished":"2021-12-17T18:06:32.000Z","url":"https://community.spiceworks.com/t/get-vm-inventory/819884/7","author":{"@type":"Person","name":"spiceuser-9q9iv","url":"https://community.spiceworks.com/u/spiceuser-9q9iv"}}]}}
Neally
(Neally)
December 16, 2021, 2:30pm
2
Welcome.
Did you do some research?
What have you tried? Where are you stuck?
Have you installed powerCli and connected to your vecenter?
Following my previous post which took you through the install of PowerCLI I thought it was time to add another back to basics (B2B) post and show how to take the first step in using PowerCLI… Connecting to your vCenter or vSphere host. Yes, PowerCLI...
Est. reading time: 5 minutes
We’re happy to help but a script writing service.
If you have some actual code and you’re stuck, feel free to post and we’ll try to help from there
If you post code, please use the ‘Insert Code’ button. Please and thank you!
Hi, and welcome to the PowerShell forum!
Don’t apologize for being a “noob” or “newbie” or “n00b.” There’s just no need – nobody will think you’re stupid, and the forums are all about asking questions. Just ask!
Use a descriptive subject. Don't say "Need help" or "PowerShell Help", actually summarize what the problem is. It helps the rest of us keep track of which problem is which.
Don’t post massive scripts. We’re all volunteers and we don’t have time to read all that, nor will we copy, past…
1 Spice up