Hi guys,
I'm having a bit of difficulty turning a script of mine into a re distributable tool and I've spent the best part of two days on it so here I am looking for some guidance.
Basically I am using Quest-AD cmdlets to copy users whilst adding unique information to them as they are created.
When I attempt to turn this into a parametrised cmdlet I have an issue in getting the get-qaduser cmdlet to recognise the "modelID" argument supplied by import-csv.
#Create function
function new-bulkaduser {
[CmdletBinding()]
#Setup Import and Set Variable
#Make sure path is reachable
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[string[]]$userlist='localhost'
)
Begin {
#import AD and Quest Snap-In
import-module activedirectory
Add-PSSnapin Quest.ActiveRoles.ADManagement
}
Process {
ForEach ($User in $Userlist)
{
$source=$User.ModelID
$fn=$User.FirstName
$ln=$User.LastName
$pw=$User.UserPassword
$un=$User.SamAccountName
$ip=$User.IpPhone
$gn=$User.Group
$pc = (Get-QADUser -identity $source).parentcontainer
$domain = 'PINKE.NET'
get-qaduser -includeallproperties -identity $source
}
}
}And a .csv example below:
ModelID,Name,SamAccountName,DisplayName,FirstName,LastName,IPPhone,UserPassword,group
cmnaa,TestUserx1,TUserx1,Test Userx1,Testx1,Userx1,6661,B1xgBuxxx01,UK Service Desk
Any help would be appreciated!
Thanks!