From 1c31e67419ffdc44c5227e6a59a04378caacab46 Mon Sep 17 00:00:00 2001 From: gvoynov <72854456+gvoynov@users.noreply.github.com> Date: Mon, 14 Dec 2020 11:53:02 +0200 Subject: [PATCH] Create Remove-User Would you consider adding function for deleting users from snipe-it? --- SnipeitPS/Public/Remove-User | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SnipeitPS/Public/Remove-User diff --git a/SnipeitPS/Public/Remove-User b/SnipeitPS/Public/Remove-User new file mode 100644 index 0000000..69148c2 --- /dev/null +++ b/SnipeitPS/Public/Remove-User @@ -0,0 +1,48 @@ +<# + .SYNOPSIS + Removes User from Snipe-it asset system + .DESCRIPTION + Long description + .PARAMETER ID + Unique ID For User to be removed + .EXAMPLE + Remove-User -ID 44 -url $url -apiKey $secret -Verbose +#> + +function Remove-User () +{ + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true)] + [string]$ID, + [parameter(mandatory = $true)] + [string]$URL, + [parameter(mandatory = $true)] + [string]$APIKey + + ) + + $Values = @{ + "ID" = $ID + } + + $Body = $Values | ConvertTo-Json + + $Parameters = @{ + Uri = "$url/api/v1/users/$ID" + Method = 'Delete' + Body = $Body + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) + { + $result = Invoke-SnipeitMethod @Parameters + } + + $result +}