From 217ca455782133ea288002fef56c5f7238c130dd Mon Sep 17 00:00:00 2001 From: K9 Barry Date: Thu, 5 Dec 2019 19:55:51 -0500 Subject: [PATCH] Add New-Audit.ps1 Add New-Audit.ps1 to add a audit to an asset through the API. --- SnipeitPS/Public/New-Audit.ps1 | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 SnipeitPS/Public/New-Audit.ps1 diff --git a/SnipeitPS/Public/New-Audit.ps1 b/SnipeitPS/Public/New-Audit.ps1 new file mode 100644 index 0000000..79b00a5 --- /dev/null +++ b/SnipeitPS/Public/New-Audit.ps1 @@ -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 +}