mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Add New-Audit.ps1
Add New-Audit.ps1 to add a audit to an asset through the API.
This commit is contained in:
parent
2ec48c67a1
commit
217ca45578
1 changed files with 64 additions and 0 deletions
64
SnipeitPS/Public/New-Audit.ps1
Normal file
64
SnipeitPS/Public/New-Audit.ps1
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Add a new Audit to Snipe-it asset system
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Long description
|
||||||
|
|
||||||
|
.PARAMETER Tag
|
||||||
|
The asset tag of the asset you wish to audit
|
||||||
|
|
||||||
|
.PARAMETER Location_id
|
||||||
|
ID of the location you want to associate with the audit
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-Audit -tag 1 -location_id "Location of Audit"
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
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 = @{
|
||||||
|
Uri = "$url/api/v1/hardware"
|
||||||
|
Method = 'Post'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
|
{
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue