✨ Add optional Delimiter flag
Signed-off-by: Luke Tainton <luke@tainton.uk>
This commit is contained in:
@@ -13,6 +13,9 @@ Function Import-TeamsUsers {
|
|||||||
.PARAMETER Create
|
.PARAMETER Create
|
||||||
If specified, create a new Group first, then add the users from the CSV file.
|
If specified, create a new Group first, then add the users from the CSV file.
|
||||||
|
|
||||||
|
.PARAMETER Delimiter
|
||||||
|
If specified, overrides the default CSV delimiter of ','.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Import-TeamsUsers -File "users.csv"
|
Import-TeamsUsers -File "users.csv"
|
||||||
|
|
||||||
@@ -24,14 +27,20 @@ Function Import-TeamsUsers {
|
|||||||
[parameter(Mandatory=$true, position=1, ParameterSetName='Params', HelpMessage="Specify CSV file")]
|
[parameter(Mandatory=$true, position=1, ParameterSetName='Params', HelpMessage="Specify CSV file")]
|
||||||
[string]$File,
|
[string]$File,
|
||||||
[parameter(Mandatory=$false, position=2, ParameterSetName='Params', HelpMessage="Create new Teams group")]
|
[parameter(Mandatory=$false, position=2, ParameterSetName='Params', HelpMessage="Create new Teams group")]
|
||||||
[switch]$Create
|
[switch]$Create,
|
||||||
|
[parameter(Mandatory=$false, position=3, ParameterSetName='Params', HelpMessage="Override default CSV delimiter")]
|
||||||
|
[string]$Delimiter
|
||||||
)
|
)
|
||||||
|
|
||||||
Begin {
|
Begin {
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
##### IMPORT CSV FILE #####
|
##### IMPORT CSV FILE #####
|
||||||
Try {
|
Try {
|
||||||
|
If ($Delimiter) {
|
||||||
|
$Users = Import-CSV $File -Delimiter $Delimiter
|
||||||
|
} Else {
|
||||||
$Users = Import-CSV $File
|
$Users = Import-CSV $File
|
||||||
|
}
|
||||||
} Catch {
|
} Catch {
|
||||||
Write-Host -ForegroundColor Red "$File is not a valid CSV file."
|
Write-Host -ForegroundColor Red "$File is not a valid CSV file."
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user