Thanks Bill for that, truly grateful.
With a little bit of adapting, I think the following will work (haven't tested fully yet). However, i would now like to add a bit of checking. (feel free to comment on my method of coding - i am still a beginner,
all constructive criticism welcome)
Below is what i have but where the comments are is where i would like the checking to take place. I was not sure if i could get it to check the groups members before or not?
Function SyncGroups
{
Write-Verbose -Message "Syncing Groups... " -Verbose
$csv = Import-Csv -Path $filePath
ForEach ($row in $csv){
$CSVID = ($row.extensionAttribute1)
$CSVGroup = ($row.GroupName)
if (#check to see if they need adding to the group listed next to them in the csv and if they do need adding...)
Get-ADUser -Filter {(extensionAttribute1 -eq $CSVID)} -Properties extensionAttribute1 | select SamAccountName, extensionAttribute1;
Add-ADGroupMember $csvGroup;
Write-Verbose -message ($row.ID + " has been added to " + $row.CSVGroup) -Verbose}
else
{
# Already a member of the group listed beside in csv - do nothing
}
}
This is just a small part of quite an extensive set of functions so all variables link back to a central config file to make changes simple :)
As always, Thanks in advance.
Kyra