<# Read-only inventory of a VMware vCenter for Vast Elite AI Copilot. Changes nothing. Needs: VMware PowerCLI (Install-Module VMware.PowerCLI -Scope CurrentUser) and a vCenter account with the built-in Read-only role. Run from a machine that can reach vCenter (for example the customer's Vast probe), then send the JSON file to Vast: python3 add_customer.py import-onprem --customer "" --file .json Usage: .\collect-vmware.ps1 -Server vcenter.customer.local [-OutFile vcenter.json] (prompts for the credential; nothing is stored) #> param([Parameter(Mandatory)][string]$Server, [string]$OutFile = "vcenter-inventory.json", [switch]$SkipCertCheck) $ErrorActionPreference = 'Stop' Import-Module VMware.VimAutomation.Core if ($SkipCertCheck) { Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false -Scope Session | Out-Null } $cred = Get-Credential -Message "Read-only vCenter account" $vc = Connect-VIServer -Server $Server -Credential $cred try { $vmhosts = Get-VMHost | ForEach-Object { [pscustomobject]@{ name=$_.Name; version="$($_.Version) build $($_.Build)"; cpu_cores=$_.NumCpu; mem_gb=[math]::Round($_.MemoryTotalGB,0) state="$($_.ConnectionState)"; cluster="$($_.Parent.Name)"; vm_count=@(Get-VM -Location $_).Count } } $vms = Get-VM | ForEach-Object { $g = $_.Guest [pscustomobject]@{ name=$_.Name; state="$($_.PowerState)"; os=$(if ($g.OSFullName) { $g.OSFullName } else { $_.ExtensionData.Config.GuestFullName }) cpus=$_.NumCpu; mem_gb=[math]::Round($_.MemoryGB,1); disk_gb=[math]::Round(($_.ProvisionedSpaceGB),0) host="$($_.VMHost.Name)"; tools="$($g.ExtensionData.ToolsRunningStatus)"; ip=@($g.IPAddress | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' })[0] } } $ds = Get-Datastore | ForEach-Object { [pscustomobject]@{ name=$_.Name; type=$_.Type; capacity_gb=[math]::Round($_.CapacityGB,0); free_gb=[math]::Round($_.FreeSpaceGB,0) } } $nets = Get-VirtualPortGroup -Standard -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name -Unique $doc = [ordered]@{ type="vmware"; name=$Server; version="$($vc.Version) build $($vc.Build)"; collected_at=(Get-Date).ToUniversalTime().ToString("s")+"Z" hosts=@($vmhosts); vms=@($vms); datastores=@($ds); networks=@($nets) } $doc | ConvertTo-Json -Depth 5 | Set-Content -Path $OutFile -Encoding UTF8 Write-Host "Wrote $OutFile : $(@($vms).Count) VMs, $(@($vmhosts).Count) hosts, $(@($ds).Count) datastores" } finally { Disconnect-VIServer -Server $vc -Confirm:$false | Out-Null }