Hi.
I have several houndreds of groups where description and info fields are empty or false. Therefore, I'm trying to create script that can automate the following for me, however I cannot put it together:
1) Replace Description and Info
2) Create log in c:\logs
3) I have to do it in 3 domains in the same forest, however I do not know how to make the script search in 3 domains. I can reach them all by -server domain1, -server domain2, -server domain3
Sample of txt-file:
SamAccountName,Description,Owner
CRITest,This is an test description,Owner: SIK/CRI`r`nAccess: Sales Dept.
My script so far:
# Import AD Module
Import-Module ActiveDirectory
# Import CSV into variable $fdigroups
#$fdigroups = import-csv "c:\fdigroups.csv"
$groups = Import-Csv -Path "c:\fdigroups.csv" -Delimiter "," -Encoding "UTF8"
# Loop through CSV and update groups if name like groupname in CVS file
foreach ($group in $groups) {
#Search in specified Server and Update existing attributes
Get-ADGroup -Filter {Name -like "$($Group.samaccountname)"} -server mgt000t -Properties * -SearchBase "ou=Groups,DC=domain,DC=net" |
Set-ADGroup -Description $($Group.Description) -Replace @{info=$group.Owner}
}
Can anyone help me to get this working?
Regards
Carsten