I have a CSV that has the following column headings:
UserID | Name | GroupName | LogonRestrictions |
UserID is the sAMAccountName.
GroupName is the name of an AD group
LogonRestrictions is a machine name.
My current script is as follows:
$inputFile = "\\NP1SECR016v\SECRpt\LogonRestrictionConfig\SSLVPN_Users.csv"
$complist = Import-Csv -Path $inputFile | ForEach-Object {$_.Logonrestrictions}
foreach($comp in $complist){
$comparray += ","+$comp
}
Set-ADUser -Identity "H139616" -LogonWorkstations $comparray
#End Script
this works great if all the records are for the same UserID. However, the csv that I am given has multiple user accounts. In other words the first 10 records will be for userA with a unique logonrestriction value (10 unique computer names). The next 20 records will be for user B with an entirely different list of computer names. I have like 27 unique user IDs and the total record count is 1800.
Is there a clever way to built the $comparray for the first unique user ID then run the set-aduser command and then build the $comparray for the next unique user ID and so on and so on?