Fix for #77 and add activated as parameter

This commit is contained in:
Petri Asikainen 2021-02-11 15:23:34 +02:00
parent 6828244dfa
commit d3fb9762ab

View file

@ -68,11 +68,11 @@ function New-User() {
[string]$lastName, [string]$lastName,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$userName, [string]$username,
[string]$password, [string]$password,
[string]$jobTitle, [string]$jobtitle,
[string]$email, [string]$email,
@ -90,33 +90,27 @@ function New-User() {
[bool]$ldap_user = $false, [bool]$ldap_user = $false,
[bool]$activated = $false,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
$Values= @{}
$Values = @{ $Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
first_name = $firstName if($Values.ContainsKey('firstname')) {
last_name = $lastName $Values['first_name']=$Values['firstname']
username = $userName $Values.Remove('firstname')
}
email = $email if($Values.ContainsKey('lastname')) {
phone = $phone $Values['last_name']=$Values['lastname']
company_id = $company_id $Values.Remove('lastname')
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
} }
if ($ldap_user -eq $false) { if ($ldap_user -eq $false) {
$ldap = @{ $ldap = @{
password = $password
password_confirmation = $password password_confirmation = $password
ldap_import = 0 ldap_import = 0
} }