functions/Import-UsersFromCSV.ps1

<#
.SYNOPSIS
Create users based on a CSV file to be imported.
  
.DESCRIPTION
Used to create users, based upon an imported CSV file.
  
.EXAMPLE
Import-UsersFromCSV .\myfile.csv
  
#>


Function Import-UsersFromCSV
{
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string]$CSVFilePath ,   
        [Parameter(Mandatory=$false)]
        [string]$UserType   
    )
    
    If($UserType -eq "") {
        $UserType = "local"
    }
    
    $CSVArray = Import-Csv $CSVFilePath
    
    $CSVArray | ForEach-Object{
        If($_.IsAdmin.ToLower() -eq "true") {
            $IsAdmin = "true"
        } Else {
            $IsAdmin = "false"
        }
        $CreateUser = Add-User $_.UserName $_.Password $UserType $IsAdmin
        Write-Verbose ( $CreateUser | Format-Table | Out-String )
    }

}