set-snipeitstatus

This commit is contained in:
Petri Asikainen 2021-06-13 18:54:12 +03:00
parent e8d52ab59c
commit 3a0b1d853a
2 changed files with 113 additions and 23 deletions

View file

@ -0,0 +1,83 @@
<#
.SYNOPSIS
Sets Snipe-it Status Labels
.PARAMETER id
A id of specific Status Label
.PARAMETER color
Hex code showing what color the status label should be on the pie chart in the dashboard
.PARAMETER show_in_nav
1 or 0 - determine whether the status label should show in the left-side nav of the web GUI
.PARAMETER default_label
1 or 0 - determine whether it should be bubbled up to the top of the list of available statuses
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy"
.EXAMPLE
Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending
#>
function Set-SnipeitStatus()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[string]$name,
[parameter(Mandatory=$true)]
[ValidateSet('deployable','undeployable','pending','archived')]
[string]$type,
[string]$notes,
[string]$color,
[bool]$show_in_nav,
[bool]$default_label,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json
}
process {
foreach($status_id in $id) {
$Parameters = @{
Uri = "$url/api/v1/statuslabels/$status_id"
Method = 'Put'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}

View file

@ -70,6 +70,9 @@ PowerShellVersion = '3.0'
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @( FunctionsToExport = @(
'Get-SnipeitAccessory',
'Get-SnipeitAccessoryOwner',
'Get-SnipeitActivity',
'Get-SnipeitAsset', 'Get-SnipeitAsset',
'Get-SnipeitAssetMaintenance', 'Get-SnipeitAssetMaintenance',
'Get-SnipeitCategory', 'Get-SnipeitCategory',
@ -78,45 +81,30 @@ FunctionsToExport = @(
'Get-SnipeitCustomField', 'Get-SnipeitCustomField',
'Get-SnipeitDepartment', 'Get-SnipeitDepartment',
'Get-SnipeitFieldset', 'Get-SnipeitFieldset',
'Get-SnipeitLicense',
'Get-SnipeitLicenseSeat',
'Get-SnipeitLocation', 'Get-SnipeitLocation',
'Get-SnipeitManufacturer', 'Get-SnipeitManufacturer',
'Get-SnipeitModel', 'Get-SnipeitModel',
'Get-SnipeitStatus', 'Get-SnipeitStatus',
'Get-SnipeitSupplier', 'Get-SnipeitSupplier',
'Get-SnipeitUser', 'Get-SnipeitUser',
'New-SnipeitAccessory',
'New-SnipeitAsset', 'New-SnipeitAsset',
'New-SnipeitAssetMaintenance', 'New-SnipeitAssetMaintenance',
'New-SnipeItAudit',
'New-SnipeitCategory', 'New-SnipeitCategory',
'New-SnipeitComponent', 'New-SnipeitComponent',
'New-SnipeitCustomField', 'New-SnipeitCustomField',
'New-SnipeitDepartment', 'New-SnipeitDepartment',
'New-SnipeitLicense', 'New-SnipeitLicense',
'Set-SnipeitLicense',
'Get-SnipeitLicense',
'Get-SnipeitLicenseSeat',
'Set-SnipeitLicenseSeat',
'New-SnipeitLocation', 'New-SnipeitLocation',
'New-SnipeitManufacturer', 'New-SnipeitManufacturer',
'New-SnipeitModel', 'New-SnipeitModel',
'New-SnipeitUser', 'New-SnipeitUser',
'Set-SnipeitAsset',
'Set-SnipeitAssetOwner',
'Set-SnipeitComponent',
'Set-SnipeitModel',
'Set-SnipeitInfo',
'Set-SnipeitUser',
'Set-SnipeitLocation',
'Add-SnipeitAccessory',
'Set-SnipeitAccessory',
'Get-SnipeitAccessory',
'Remove-SnipeitAsset',
'Remove-SnipeitUser',
'Update-SnipeitAlias',
'Set-SnipeitAccessoryOwner',
'Get-SnipeitAccessoryOwner',
'Reset-SnipeitAccessoryOwner',
'Get-SnipeitActivity',
'Remove-SnipeitAccessory', 'Remove-SnipeitAccessory',
'Remove-SnipeitAsset',
'Remove-SnipeitAssetMaintenance',
'Remove-SnipeitCategory', 'Remove-SnipeitCategory',
'Remove-SnipeitCompany', 'Remove-SnipeitCompany',
'Remove-SnipeitComponent', 'Remove-SnipeitComponent',
@ -125,8 +113,27 @@ FunctionsToExport = @(
'Remove-SnipeitLicense', 'Remove-SnipeitLicense',
'Remove-SnipeitLocation', 'Remove-SnipeitLocation',
'Remove-SnipeitManufacturer', 'Remove-SnipeitManufacturer',
'Remove-SnipeitModel' 'Remove-SnipeitModel',
'Remove-SnipeitUser',
'Reset-SnipeitAccessoryOwner',
'Reset-SnipeitAssetOwner',
'Set-SnipeitAccessory',
'Set-SnipeitAccessoryOwner',
'Set-SnipeitAsset',
'Set-SnipeitAssetOwner',
'Set-SnipeitCategory'
'Set-SnipeitCompany'
'Set-SnipeitComponent',
'Set-SnipeitCustomField',
'Set-SnipeitDepartment',
'Set-SnipeitInfo',
'Set-SnipeitLicense',
'Set-SnipeitLicenseSeat',
'Set-SnipeitLocation',
'Set-SnipeitModel',
'Set-SnipeitStatus',
'Set-SnipeitUser',
'Update-SnipeitAlias'
) )
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.