'Powershell script for bulk action
I am in need of help making the below script import a csv of users firstname and last and then setting the same account expiration inside of AD using the DRA powershell extension. The section "CN=User\, Test" would be changed to CN=$LastName\, $FirstName and the account expiration date would need to be set to be the same for all users in the csv file.
Set-DRAUser -DRARestServer draserver.na.corp.domain.com -draHostServer draserver.na.corp.domain.com -Domain na.corp.domain.com -Identifier 'CN=User\, Test,OU=Users,OU=company,OU=site,OU=city,DC=na,DC=corp,DC=domain,DC=com' -IgnoreCertificateErrors -Force -Properties @{AccountExpirationDate="05/22/2022 23:59:00"}
Thank you for the assistance!
Solution 1:[1]
I was able to solve this with the following code.
foreach ($user in $fileinput){
$name=$user -split ","
$sn=$name[0]
$fn=$name[1]
$dn="CN=$sn\,$fn,OU=Users,OU=company,OU=site,OU=city,DC=na,DC=corp,DC=domain,DC=com"
$dn
Set-DRAUser -DRARestServer draserver.na.corp.domain.com -draHostServer draserver.na.corp.domain.com -Domain na.corp.domain.com -Identifier $dn -IgnoreCertificateErrors -Force -Properties @{AccountExpirationDate="05/24/2022 23:59:00"}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jordan Matthew Farmer |
