Hi Mickey,
The user account before update:
If I selecte NIS Domain, the image is updated to:
Anything is realized with GUI, I notice that the GUI also updated the fields:
uid, uidnumber, unixUserPassword and msSFUName
But if I used powershell to set another fields, this listed fields do not updated. It seem like anything that is executed (SelectedIndexChange on the combobox NIS Domain ou event in a OK button), that update the fields
uid, uidnumber, unixUserPassword and msSFUName.
This is the code that I used.
Clear-Host
Remove-Variable -Name * -Force -ErrorAction SilentlyContinue
Import-Module ActiveDirectory
Write-Host "$(get-date) Start of script"
$usuarios = Get-ADUser -Filter * -SearchBase "OU=Users,OU=City,OU=Region,DC=domain,DC=com"
-Properties:*
foreach($usr in $usuarios)
{
# NIS Domain
if ($usr.mssfu30nisdomain -eq $null)
{
Set-ADUser -Identity "$($usr.SamAccountName)" -Replace @{mssfu30nisdomain = "domain"}
Write-Host "$(get-date) Alter user ($($usr.SamAccountName)) [NIS Domain] from 'NULL' to domain"
}
# Login Shell
if ($usr.loginshell -eq $null)
{
Set-ADUser -Identity "$($usr.SamAccountName)" -Replace @{loginshell="/bin/ksh"}
Write-Host "$(get-date) Alter user ($($usr.SamAccountName)) [Login Shell] from $($usr.loginshell) to /bin/ksh"
}
# Home Directory
if ($usr.unixhomedirectory -eq $null)
{
Set-ADUser -Identity "$($usr.SamAccountName)" -Replace @{unixhomedirectory="/home/$($usr.SamAccountName.ToLower())"}
Write-Host "$(get-date) Alter user ($($usr.SamAccountName)) [Home Directory] from 'NULL' to /home/$($usr.SamAccountName.ToLower())"
}
# Primary group name/GID
if ($usr.gidnumber -ne $null)
{
if ($usr.gidnumber -ne 200)
{
Set-ADUser -Identity "$($usr.SamAccountName)" -Replace @{gidnumber="200"}
Write-Host "$(get-date) Alter user ($($usr.SamAccountName)) [Primary group name/GID] from $($usr.gidnumber) to 200"
}
}
else
{
Set-ADUser -Identity "$($usr.SamAccountName)" -Replace @{gidnumber="200"}
Write-Host "$(get-date) Alter user ($($usr.SamAccountName)) [Primary group name/GID] from 'NULL' to 200"
}
}
Write-Host "$(get-date) End of script"
The field uidnumber is the most importante to mee, but I don't know the value that is stored in the Active Directory, and I can't see the value in the powershell properties.