That seems to indicate the one of the users you specified in the Users column in the CSV does not exist.
The $user variable at the beginning is used to connect.
The $user variable in the foreach loop is used to retrieve the user(s) you specified in the CSV.
If you want you can rename one of these variables.
Original Message:
Sent: Nov 06, 2024 03:43 AM
From: the1960
Subject: I need a script to Import Groups with User of csv-file in vCenter
Hi Luc,
Thanks for the script.
I got an error message:
Add-UserToSsoGroup: Y:\Areas\...\import_groups.ps1:57:50 Line | 57 | Add-UserToSsoGroup -TargetGroup $group -User $user
| Cannot bind argument to parameter 'User' because it is null.
I'm a bit confused by the variable $user! It is defined at the beginning with the admin account, but appears again at the bottom of the script and is overwritten again with $user = Get-SsoPersonUser -Name $account -Domain $domain
The script still ran through and created the groups, but the users were only partially added to the groups. I was able to clean that up manually, though.
Thanks for your help.
Br the1960
Original Message:
Sent: Nov 05, 2024 12:44 PM
From: LucD
Subject: I need a script to Import Groups with User of csv-file in vCenter
Assuming that these users are defined in the SSO domain, and considering that your CSV looks something like this
Group;Description;UsersTestGroup;Test Group;Administrator@vsphere.local,user@vsphere.localTestGroup2;Second Test Group;user@vsphere.local
you could do something like this
#Requires -Modules 'VMware.vSphere.SsoAdmin'$vcsaName = 'vcsa.local.lab'$user = 'administrator@vsphere.local'$pswd = 'VMware1!'$ssoSrv = Connect-SsoAdminServer -Server $vcsaName -User $user -Password $pswd -SkipCertificateCheckImport-Csv -Path .\groups.csv -Delimiter ';' -PipelineVariable row |ForEach-Object -Process { $group = New-SsoGroup -Name $row.Group -Description $row.Description $row.Users.Split(',') | ForEach-Object -Process { $account,$domain = $_.Split('@') $user = Get-SsoPersonUser -Name $account -Domain $domain Add-UserToSsoGroup -TargetGroup $group -User $user }}Disconnect-SsoAdminServer -Server $ssoSrv
This script requires the VMware.vSphere.SsoAdmin module written by Dimitar Milov
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 05, 2024 10:40 AM
From: LucD
Subject: I need a script to Import Groups with User of csv-file in vCenter
Do you mean a local user account on the VCSA?
Like this one Create a Local User Account in vCenter Server
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 05, 2024 01:47 AM
From: the1960
Subject: I need a script to Import Groups with User of csv-file in vCenter
Hi Luc,
The groups and members should be imported into the vCenter 5.7. It's not about AD groups.
The csv is in the format: Group;Description;Users
Original Message:
Sent: Nov 04, 2024 01:21 PM
From: LucD
Subject: I need a script to Import Groups with User of csv-file in vCenter
What kind of users, and import into what?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 04, 2024 04:36 AM
From: the1960
Subject: I need a script to Import Groups with User of csv-file in vCenter
How can I use a PCLI script to import the groups with the users from a csv file?
I have already tried using the Get-Group command, but I get an error message "Command not found in cmdlet..."
vCenter version 7.5