Need to create users on Office 365 from a csv file

This came in very usefull the other day.

[CmdletBinding()]
param(
    [string] $inputCsvFile = "users.csv"
)
 
# Reference to site code originated from
#
# http://philwicklund.com/blog/Pages/Using-remote-PowerShell-to-manage-Office-365-identities.aspx
 
Import-Module MSOnline -ErrorAction silentlycontinue
connect-MsolService
 
$csvRows = import-csv $inputCsvFile
# Csv file format expected is
# column headings
# data rows
#
# where data rows are quote comma delimited fields
# agreeing with column headings
# e.g.
#
# "UserPrincipalName","DisplayName","FirstName","LastName","Password"
# "brian999@xyz.onmicrosoft.com","Brian T 999","Brian","T 999","p@%^*()"
 
$row = 0
$csvRows | % {
    $csvRow = $_
    $row++
 
    write-host "row:" $row $csvRow.UserPrincipalName
 
    #New-MsolUser    -UserPrincipalName $csvRow.UserPrincipalName `
    #                -DisplayName $csvRow.DisplayName `
    #                -FirstName $csvRow.FirstName `
    #                -LastName $csvRow.LastName `
    #                -Password $csvRow.Password
 
    #Set-MsolUser    -UserPrincipalName $csvRow.UserPrincipalName `
    #                -PasswordNeverExpires $true
 
    #Set-MsolUserLicence -UserPrincipalName $csvRow.UserPrincipalName `
    #                    -AddLicenses "xyz:ENTERPRISEPACK"
                        # -RemoveLicenses ""
 
    # Remove-MsolUser -UserPrincipalName $csvRow.UserPrincipalName
    # New-MsolGroup -DisplayName "Sales Executives" -Description "All sales staff"
    # $salesGroup = Get-MsolGroup | where-object { $_.DisplayName -eq "Sales Executives"}
    # $user = Get-MsolUser | where-object { $_.DisplayName -eq "Phil" }
    # Add-MsolGroupMember -GroupObjectId $salesGroup.ObjectId -GroupMemberType "User" -GroupMemberObjectId $user.ObjectId
    # Remove-MsolGroup -objectid $salesGroup.ObjectId
}