Pete
asked on
Powershell - Pulling a single users info from a .csv
I am creating some AD and MSOL users from a CSV using powershell. The users get created fine using ‘import’ and then ‘for each’ commands.
-------------------------- ---------- ---------- ------
$UserCSV = Import-Csv -Path "C:\Path.csv"
foreach ($User in $UserCSV)
{
$FirstName = $User.Firstname
$LastName = $User.Lastname
$UserName = $User.Username.ToUpper()
$Password = $User.Password
# Create User Commands
New-ADUser -Name $UserName etc etc
}
-------------------------- ---------- --
But then once the users are created I want to sync them to MSOL, and as this tends to take a while check one of the users exists before moving on to the next lot of commands.
How can I pull just one of the users details from the .csv and set variables based on that single users info?
ie:
$Username = ‘The last user in the .csv username’
$emailaddress = ‘The last user in the .csv email address’
--------------------------
$UserCSV = Import-Csv -Path "C:\Path.csv"
foreach ($User in $UserCSV)
{
$FirstName = $User.Firstname
$LastName = $User.Lastname
$UserName = $User.Username.ToUpper()
$Password = $User.Password
# Create User Commands
New-ADUser -Name $UserName etc etc
}
--------------------------
But then once the users are created I want to sync them to MSOL, and as this tends to take a while check one of the users exists before moving on to the next lot of commands.
How can I pull just one of the users details from the .csv and set variables based on that single users info?
ie:
$Username = ‘The last user in the .csv username’
$emailaddress = ‘The last user in the .csv email address’
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.