Hi all,
I was hoping for some advice.
I want to create users base on a CSV file and some clever Powershelling, but I also want to type as little as possible.
Let's say I have a CSV file with these fields:
Name,OU,FI,Surname,Firstname
In the olden days, I could use DSADD and combine different fields, so in this case, I could do this:
DSADD user "CN=%e %d,OU=Users,OU=%b,DC=Comp,DC=com" -samid %c_%d
Now, with Powershell, I would use these variables (If I understand everything correctly):
$_.Name
$_.OU
$_.FI
$_.Surname
$_.Firstname
However, I don't seem to be able to do this:
Import-CSV .\input.csv | %{ New-Mailbox -Displayname '$_.Firstname $_.Surname' -SamAccountName $_.FI_$_.Surname -UserPrincipalName $_.FI_$_.Surname@company.com }
Do I really need to manually enter the Samid, full OU, UPN and so on in their own fields in the CSV file?
For example:
Name,FI,LI,Firstname,Surname,SamID,UserPrincipalName
Joe Bloggs,J,B,Joe,Bloggs,J_Bloggs,J_Bloggs@company.com
It seems that if this is the case, I will not be saving any time at all compared to using the ADUC GUI to create users.
I was hoping for some advice.
I want to create users base on a CSV file and some clever Powershelling, but I also want to type as little as possible.
Let's say I have a CSV file with these fields:
Name,OU,FI,Surname,Firstname
In the olden days, I could use DSADD and combine different fields, so in this case, I could do this:
DSADD user "CN=%e %d,OU=Users,OU=%b,DC=Comp,DC=com" -samid %c_%d
Now, with Powershell, I would use these variables (If I understand everything correctly):
$_.Name
$_.OU
$_.FI
$_.Surname
$_.Firstname
However, I don't seem to be able to do this:
Import-CSV .\input.csv | %{ New-Mailbox -Displayname '$_.Firstname $_.Surname' -SamAccountName $_.FI_$_.Surname -UserPrincipalName $_.FI_$_.Surname@company.com }
Do I really need to manually enter the Samid, full OU, UPN and so on in their own fields in the CSV file?
For example:
Name,FI,LI,Firstname,Surname,SamID,UserPrincipalName
Joe Bloggs,J,B,Joe,Bloggs,J_Bloggs,J_Bloggs@company.com
It seems that if this is the case, I will not be saving any time at all compared to using the ADUC GUI to create users.