Link to home
Start Free TrialLog in
Avatar of JCJohnson76
JCJohnson76

asked on

How to create custom attributes using powershell

Hello,

I'm having difficulty creating bulk users; using a custom attribute.

Please note: The custom attribute is already listed or installed in the Schema; I have created a csv column file that identify the columns listed below

My Goal,
Is to create bulk users that l have the custom attribute (IISID) listed.

The script that I run will create bulk users; but if I insert the column header for custom attribute (IISID) and try to run the bulk user script it fails.  

How do I add bulk users while using custom attribute (IISID) to my script.

Import-Csv "c:\scripts\usersTST.csv" | ForEach-Object {
$userPrincipal = $_."samAccountName" + "@iis.com"
New-ADUser -Name $_.Name -PasswordNeverExpires $true `
-Path $_."ParentOU" `
-GivenName $_."GivenName" `
-Surname $_."Surname" `
-DisplayName $_."DisplayName" `
-SamAccountName $_."SamAccountName" `
-Initials $_."initials" `
-IISID $_."IISID"`
-UserPrincipalName $userPrincipal `
-AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) `
-ChangePasswordAtLogon $false `
-Enabled $true
 }

Please note: I also know how to oneliner this command but it does not help me using bulk.
Set-ADUser -Identity "userid" -Add @{IISID = "12345"}
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JCJohnson76
JCJohnson76

ASKER

Thanks
For the info,  learn something new.

Works great now