SnipeitPS/SnipeitPS/Public/Remove-SnipeitUser.ps1
2021-08-22 22:23:08 +03:00

64 lines
1.8 KiB
PowerShell

<#
.SYNOPSIS
Removes User from Snipe-it asset system
.DESCRIPTION
Removes Uuser or users from Snipe-it asset system
.PARAMETER ID
Unique ID For User to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#>
function Remove-SnipeitUser () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin{
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
}
process {
foreach($user_id in $id) {
$Parameters = @{
Api = "/api/v1/users/$user_id"
Method = 'Delete'
}
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}