mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
set and remove snipeitdepartment
This commit is contained in:
parent
83eb363889
commit
cd86c6749d
2 changed files with 86 additions and 1 deletions
|
|
@ -37,7 +37,7 @@ function Remove-SnipeitDepartment ()
|
||||||
begin {
|
begin {
|
||||||
}
|
}
|
||||||
process {
|
process {
|
||||||
foreach($depatment_id in $id){
|
foreach($department_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/departments/$department_id"
|
Uri = "$url/api/v1/departments/$department_id"
|
||||||
Method = 'Delete'
|
Method = 'Delete'
|
||||||
|
|
|
||||||
85
SnipeitPS/Public/Set-SnipeitDepartment.ps1
Normal file
85
SnipeitPS/Public/Set-SnipeitDepartment.ps1
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Updates a department
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Updates the department on Snipe-It system
|
||||||
|
|
||||||
|
.PARAMETER id
|
||||||
|
Id number of Department
|
||||||
|
|
||||||
|
.PARAMETER name
|
||||||
|
Department Name
|
||||||
|
|
||||||
|
.PARAMETER company_id
|
||||||
|
ID number of company
|
||||||
|
|
||||||
|
.PARAMETER location_id
|
||||||
|
ID number of location
|
||||||
|
|
||||||
|
.PARAMETER manager_id
|
||||||
|
ID number of manager
|
||||||
|
|
||||||
|
.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
|
||||||
|
Set-SnipeitDepartment -id 4 -manager_id 3
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
function Set-SnipeitDepartment() {
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Low"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
|
[int[]]$id,
|
||||||
|
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[int]$location_id,
|
||||||
|
|
||||||
|
[int]$manager_id,
|
||||||
|
|
||||||
|
[string]$notes,
|
||||||
|
|
||||||
|
[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 ($department_id in $id) {
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/departments/$department_id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue