Hallo zusammen,
wir würden eigentlich gerne Daten vom RabbitMQ mit Powershell ins AD übertragen. Das funktioniert im Prinzip, jedoch nicht mit allen Attributen auf einmal. Falls jemand eine Idee hat, wäre ich dankbar....
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$OU_Path = "OU=ABC_USERS,OU=XX_ABC,DC=domain,DC=meine,DC=de"
$profilePath = "\\meine.domain.de\Profil\Profildaten\$SamAccountName"
$homeDrive = "H"
$homeDirectory = "\\meine.domain.de\Daten\Userdaten\$SamAccountName"
$Params = @{
BaseUri = "https://rabbitmq.meine.domain.de:47111"
Credential = $credRabbit
}
$QueueName = 'pstestqueue'
$Incoming = Get-RabbitMQMessage @params -VirtualHost / -Name $QueueName -count 1
$IncomingData = $Incoming.payload | ConvertFrom-Json
#AD User:
#AD User anlegen wenn noch nicht vorhanden:
if (@(Get-ADUser -Filter { SamAccountName -eq $SamAccountName }).Count -eq 0) {
$newUser = @{
Path = $OU_Path
UserPrincipalName = "$SamAccountName@ads.katsh.de"
SamAccountName = $SamAccountName
profilePath = $profilePath
homeDrive = $homeDrive
homeDirectory = $homeDirectory
name = $DisplayName
}
New-ADUser @newUser
}
$changeUser = $IncomingData.changeUser
#AD User Änderungen:
Get-ADUser -Identity $IncomingData.SamAccountName | Rename-ADObject -NewName $IncomingData.changeUser.DisplayName
Get-ADUser -Identity $IncomingData.SamAccountName | Set-ADUser -GivenName $IncomingData.changeUser.GivenName
#AD User: Change PW:
if ($IncomingData.Password -ne "") {
Set-ADAccountPassword -Identity $IncomingData.SamAccountName -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $IncomingData.Password -Force)
}
Get-ADUser -Identity $IncomingData.SamAccountName | Set-ADUser -GivenName $IncomingData.changeUser.GivenName
So geht es (aber eben nur mit GivenName)
Get-ADUser -Identity $IncomingData.SamAccountName | Set-ADUser -GivenName $IncomingData.changeUser.GivenName
FG
Helmut