Create Remove-User

Would you consider adding function for deleting users from snipe-it?
This commit is contained in:
gvoynov 2020-12-14 11:53:02 +02:00 committed by GitHub
parent 54043c68e4
commit 1c31e67419
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}