# Set vCenter Server credentials
$vCenterServer = "your vcenter ip or hostname"
$username = "your_vcenter_username"
$password = "your_vcenter_password"
$outputFile = "C:\Temp\groups.csv" # Specify path to save the CSV file
# Connect to the vCenter Server
$secPassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential($username, $secPassword)
Connect-VIServer -Server $vCenterServer -Credential $credentials
# Get all the groups from the vCenter SSO (Single Sign-On)
$groups = Get-VIAccount -Group -Domain vsphere.local | Select-Object Name, Description | Export-Csv -Path $outputFile -NoTypeInformation
# Export groups to a CSV file
$groups | Select-Object @{Name="Name";Expression={$_.Principal}} | Export-Csv -Path $outputFile -NoTypeInformation
# Confirm export completion
Write-Host "Groups have been exported to: $outputFile"
# Disconnect from the vCenter Server
Disconnect-VIServer -Server $vCenterServer -Confirm:$false
Original Message:
Sent: Nov 19, 2024 07:51 AM
From: the1960
Subject: Users/Groups
I am looking for a script that lists all groups from vCenter 8.0 with their members and exports them to a csv file.