2019-12-05 19:55:51 -05:00
|
|
|
<#
|
2021-05-19 15:51:49 +03:00
|
|
|
.SYNOPSIS
|
|
|
|
|
Add a new Audit to Snipe-it asset system
|
2019-12-05 19:55:51 -05:00
|
|
|
|
2021-05-19 15:51:49 +03:00
|
|
|
.DESCRIPTION
|
|
|
|
|
Long description
|
2019-12-05 19:55:51 -05:00
|
|
|
|
2021-05-19 15:51:49 +03:00
|
|
|
.PARAMETER Tag
|
|
|
|
|
The asset tag of the asset you wish to audit
|
2019-12-05 19:55:51 -05:00
|
|
|
|
2021-05-19 15:51:49 +03:00
|
|
|
.PARAMETER Location_id
|
|
|
|
|
ID of the location you want to associate with the audit
|
2019-12-05 19:55:51 -05:00
|
|
|
|
2021-05-19 15:51:49 +03:00
|
|
|
.EXAMPLE
|
|
|
|
|
New-Audit -tag 1 -location_id 1
|
2019-12-05 19:55:51 -05:00
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
function New-Audit()
|
|
|
|
|
{
|
|
|
|
|
[CmdletBinding(
|
|
|
|
|
SupportsShouldProcess = $true,
|
|
|
|
|
ConfirmImpact = "Low"
|
|
|
|
|
)]
|
|
|
|
|
|
|
|
|
|
Param(
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$tag,
|
|
|
|
|
|
|
|
|
|
[int]$location_id,
|
|
|
|
|
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$url,
|
|
|
|
|
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$apiKey
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$Values = @{
|
|
|
|
|
"location_id" = $location_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($PSBoundParameters.ContainsKey('tag'))
|
|
|
|
|
{
|
|
|
|
|
$Values += @{"asset_tag" = $tag}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Body = $Values | ConvertTo-Json;
|
|
|
|
|
|
|
|
|
|
$Parameters = @{
|
2019-12-05 20:26:54 -05:00
|
|
|
Uri = "$url/api/v1/hardware/audit"
|
2019-12-05 19:55:51 -05:00
|
|
|
Method = 'Post'
|
|
|
|
|
Body = $Body
|
|
|
|
|
Token = $apiKey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
|
|
|
|
{
|
|
|
|
|
$result = Invoke-SnipeitMethod @Parameters
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result
|
|
|
|
|
}
|