I am attempting to write a script that will import a list of AD groups, and then update the owner (managed by) field as well as append to the notes field, however, I am not able to make this work. The CSV file I'm testing with has just the one AD group with no header.
$Username = Read-Host -prompt "Enter Username"
$Ticket = Read-Host -prompt "Enter Ticket Number"
$Groups = Import-CSV Group_UpdateOwner.csv
$Notes = ForEach ($Group in $Groups) {
Get-ADGroup -Identity $Group -Properties Info
}
$Note = $Notes.Info
$Note += "; $Ticket"
$Manager = Get-ADUser -Identity $Username
ForEach ($Line in $Groups) {
Set-ADGroup $Line.Group -ManagedBy ($Manager.DistinguishedName) -Replace @{Info=$Note}
}
As you can probably tell from this script, I am a beginner with PowerShell. I mostly just pieced together from other scripts I found online. The best I have come up with is updating the owner and replacing the notes, but I need to add to the notes rather than replace what is already there. If you're able to provide any guidance, that would be much appreciated.