From d3fb9762abc52e50e33af1f43f32e277dc75b52b Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Thu, 11 Feb 2021 15:23:34 +0200 Subject: [PATCH] Fix for #77 and add activated as parameter --- SnipeitPS/Public/New-User.ps1 | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/SnipeitPS/Public/New-User.ps1 b/SnipeitPS/Public/New-User.ps1 index d18e21c..23eb3b0 100644 --- a/SnipeitPS/Public/New-User.ps1 +++ b/SnipeitPS/Public/New-User.ps1 @@ -68,11 +68,11 @@ function New-User() { [string]$lastName, [parameter(mandatory = $true)] - [string]$userName, + [string]$username, [string]$password, - [string]$jobTitle, + [string]$jobtitle, [string]$email, @@ -90,33 +90,27 @@ function New-User() { [bool]$ldap_user = $false, + [bool]$activated = $false, + [parameter(mandatory = $true)] [string]$url, [parameter(mandatory = $true)] [string]$apiKey ) - - $Values = @{ - first_name = $firstName - last_name = $lastName - username = $userName - - email = $email - phone = $phone - company_id = $company_id - location_id = $location_id - department_id = $department_id - manager_id = $manager_id - jobtitle = $jobTitle - employee_num = $employee_num - notes = "Imported using SnipeitPS Script" - activated = 1 + $Values= @{} + $Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters + if($Values.ContainsKey('firstname')) { + $Values['first_name']=$Values['firstname'] + $Values.Remove('firstname') } - + if($Values.ContainsKey('lastname')) { + $Values['last_name']=$Values['lastname'] + $Values.Remove('lastname') + } + if ($ldap_user -eq $false) { $ldap = @{ - password = $password password_confirmation = $password ldap_import = 0 }