From 981e90e1037cfe1359cf43273e684c6ed725d8b1 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Sun, 16 May 2021 13:13:23 +0300 Subject: [PATCH] fix for #35, get-user by email or username --- SnipeitPS/Public/Get-User.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SnipeitPS/Public/Get-User.ps1 b/SnipeitPS/Public/Get-User.ps1 index 2c3f9d3..934a6d0 100644 --- a/SnipeitPS/Public/Get-User.ps1 +++ b/SnipeitPS/Public/Get-User.ps1 @@ -33,7 +33,7 @@ Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_. function Get-User() { Param( [string]$search, - + [string]$id, [int]$company_id, @@ -44,6 +44,10 @@ function Get-User() { [int]$department_id, + [string]$username, + + [string]$email, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -61,15 +65,15 @@ function Get-User() { ) $SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters - + $apiurl = "$url/api/v1/users" if ($search -and $id ) { Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " } - + if ($id) { - $apiurl= "$url/api/v1/users/$id" + $apiurl= "$url/api/v1/users/$id" } $Parameters = @{ Uri = $apiurl @@ -85,8 +89,8 @@ function Get-User() { while ($true) { $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-User @callargs + $callargs['limit'] = $limit + $res=Get-User @callargs $res if ($res.count -lt $limit) { break