mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-15 02:35:47 +00:00
change structure
This commit is contained in:
parent
4dface3fa7
commit
c860da790f
20 changed files with 409 additions and 249 deletions
|
|
@ -1,177 +0,0 @@
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
# Gets a list of Snipe-it Assets
|
|
||||||
|
|
||||||
.PARAMETER url
|
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
|
||||||
|
|
||||||
.PARAMETER apiKey
|
|
||||||
Users API Key for Snipeit, can be set using Set-Info command
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Get-Asset -url "https://assets.dip.co.uk" -token "token..."
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Get-Asset -url "https://assets.dip.co.uk" -token "token..." | Where-Object {$_.name -eq "SUPPORT23" }
|
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
function Get-Asset()
|
|
||||||
{
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey
|
|
||||||
)
|
|
||||||
|
|
||||||
$result = Invoke-Method -URi "$url/api/v1/hardware" `
|
|
||||||
-Method GET `
|
|
||||||
-Token $apiKey
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
|
||||||
|
|
||||||
function New-Asset()
|
|
||||||
{
|
|
||||||
[CmdletBinding(
|
|
||||||
SupportsShouldProcess=$true,
|
|
||||||
ConfirmImpact="High"
|
|
||||||
)]
|
|
||||||
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Status_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Model_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey,
|
|
||||||
|
|
||||||
[hashtable] $customfields
|
|
||||||
)
|
|
||||||
|
|
||||||
$Values = @{
|
|
||||||
"name" = $Name
|
|
||||||
"status_id" = $status_id
|
|
||||||
"model_id" = $model_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$Values += $customfields
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
|
||||||
|
|
||||||
$Parameters = @{
|
|
||||||
Uri = "$url/api/v1/hardware"
|
|
||||||
Method = 'Post'
|
|
||||||
Body = $Body
|
|
||||||
Token = $apiKey
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess()) {
|
|
||||||
$result = Invoke-Method @Parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-Asset()
|
|
||||||
{
|
|
||||||
[CmdletBinding(
|
|
||||||
SupportsShouldProcess=$true,
|
|
||||||
ConfirmImpact="High"
|
|
||||||
)]
|
|
||||||
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Status_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$Model_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey,
|
|
||||||
|
|
||||||
[hashtable] $customfields
|
|
||||||
)
|
|
||||||
|
|
||||||
$Values = @{
|
|
||||||
"name" = $Name
|
|
||||||
"status_id" = $status_id
|
|
||||||
"model_id" = $model_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$Values += $customfields
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
|
||||||
|
|
||||||
$Parameters = @{
|
|
||||||
Uri = "$url/api/v1/hardware/$id"
|
|
||||||
Method = 'Put'
|
|
||||||
Body = $Body
|
|
||||||
Token = $apiKey
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess()) {
|
|
||||||
$result = Invoke-Method @Parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-AssetOwner()
|
|
||||||
{
|
|
||||||
[CmdletBinding(
|
|
||||||
SupportsShouldProcess=$true,
|
|
||||||
ConfirmImpact="High"
|
|
||||||
)]
|
|
||||||
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$user_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey
|
|
||||||
)
|
|
||||||
|
|
||||||
$Values = @{
|
|
||||||
"user_id" = $user_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
|
||||||
|
|
||||||
$Parameters = @{
|
|
||||||
Uri = "$url/api/v1/hardware/$id/checkout"
|
|
||||||
Method = 'POST'
|
|
||||||
Body = $Body
|
|
||||||
Token = $apiKey
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess()) {
|
|
||||||
$result = Invoke-Method @Parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result
|
|
||||||
}
|
|
||||||
40
SnipeitPS/Public/Get-Asset.psd1
Normal file
40
SnipeitPS/Public/Get-Asset.psd1
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
# Gets a list of Snipe-it Assets
|
||||||
|
|
||||||
|
.PARAMETER url
|
||||||
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Users API Key for Snipeit, can be set using Set-Info command
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-Asset -url "https://assets.dip.co.uk" -token "token..."
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-Asset -url "https://assets.dip.co.uk" -token "token..." | Where-Object {$_.name -eq "SUPPORT23" }
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
function Get-Asset()
|
||||||
|
{
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory=$true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory=$true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$result = Invoke-Method -URi "$url/api/v1/hardware" `
|
||||||
|
-Method GET `
|
||||||
|
-Token $apiKey
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
16
SnipeitPS/Public/Get-Model.psd1
Normal file
16
SnipeitPS/Public/Get-Model.psd1
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
function Get-Model()
|
||||||
|
{
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$result = Invoke-Method -URi "$url/api/v1/models" `
|
||||||
|
-Method GET `
|
||||||
|
-Token $apiKey
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
|
|
||||||
function Get-Model()
|
|
||||||
{
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey
|
|
||||||
)
|
|
||||||
|
|
||||||
$result = Invoke-Method -URi "$url/api/v1/models" `
|
|
||||||
-Method GET `
|
|
||||||
-Token $apiKey
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function New-Model()
|
|
||||||
{
|
|
||||||
[CmdletBinding(
|
|
||||||
SupportsShouldProcess=$true,
|
|
||||||
ConfirmImpact="High"
|
|
||||||
)]
|
|
||||||
|
|
||||||
Param(
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$name,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$category_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$manufacturer_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[int]$fieldset_id,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$url,
|
|
||||||
|
|
||||||
[parameter(mandatory=$true)]
|
|
||||||
[string]$apiKey
|
|
||||||
)
|
|
||||||
|
|
||||||
$Values = @{
|
|
||||||
name = $name
|
|
||||||
category_id = $category_id
|
|
||||||
manufacturer_id = $manufacturer_id
|
|
||||||
fieldset_id = $fieldset_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
|
||||||
|
|
||||||
$Parameters = @{
|
|
||||||
Uri = "$url/api/v1/models"
|
|
||||||
Method = 'post'
|
|
||||||
Body = $Body
|
|
||||||
Token = $apiKey
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess()) {
|
|
||||||
$result = Invoke-Method @Parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
|
||||||
50
SnipeitPS/Public/New-Asset.psd1
Normal file
50
SnipeitPS/Public/New-Asset.psd1
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
function New-Asset()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Status_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Model_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey,
|
||||||
|
|
||||||
|
[hashtable] $customfields
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"name" = $Name
|
||||||
|
"status_id" = $status_id
|
||||||
|
"model_id" = $model_id
|
||||||
|
}
|
||||||
|
|
||||||
|
$Values += $customfields
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/hardware"
|
||||||
|
Method = 'Post'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
76
SnipeitPS/Public/New-Component.psd1
Normal file
76
SnipeitPS/Public/New-Component.psd1
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Short description
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Long description
|
||||||
|
|
||||||
|
.PARAMETER name
|
||||||
|
Parameter description
|
||||||
|
|
||||||
|
.PARAMETER category_id
|
||||||
|
Parameter description
|
||||||
|
|
||||||
|
.PARAMETER qty
|
||||||
|
Parameter description
|
||||||
|
|
||||||
|
.PARAMETER url
|
||||||
|
Parameter description
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Parameter description
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
An example
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
General notes
|
||||||
|
#>
|
||||||
|
|
||||||
|
function New-Component()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$category_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$qty,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"name" = $name
|
||||||
|
"category_id" = $category_id
|
||||||
|
"qty" = $qty
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/components"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
40
SnipeitPS/Public/New-Manufacturer.psd1
Normal file
40
SnipeitPS/Public/New-Manufacturer.psd1
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
function New-Manufacturer()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"name" = $Name
|
||||||
|
}
|
||||||
|
|
||||||
|
#Convert Values to JSON format
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/manufacturers"
|
||||||
|
Method = 'post'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
50
SnipeitPS/Public/New-Model.psd1
Normal file
50
SnipeitPS/Public/New-Model.psd1
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
function New-Model()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$fieldset_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
name = $name
|
||||||
|
category_id = $category_id
|
||||||
|
manufacturer_id = $manufacturer_id
|
||||||
|
fieldset_id = $fieldset_id
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/models"
|
||||||
|
Method = 'post'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
52
SnipeitPS/Public/Set-Asset.psd1
Normal file
52
SnipeitPS/Public/Set-Asset.psd1
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
function Set-Asset()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Status_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$Model_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey,
|
||||||
|
|
||||||
|
[hashtable] $customfields
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"name" = $Name
|
||||||
|
"status_id" = $status_id
|
||||||
|
"model_id" = $model_id
|
||||||
|
}
|
||||||
|
|
||||||
|
$Values += $customfields
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/hardware/$id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
41
SnipeitPS/Public/Set-AssetOwner.psd1
Normal file
41
SnipeitPS/Public/Set-AssetOwner.psd1
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
function Set-AssetOwner()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$user_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"user_id" = $user_id
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/hardware/$id/checkout"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result
|
||||||
|
}
|
||||||
41
SnipeitPS/Public/Set-Components.psd1
Normal file
41
SnipeitPS/Public/Set-Components.psd1
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
function Set-Component()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "High"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$qty,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = @{
|
||||||
|
"qty" = $qty
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/components/$component_id"
|
||||||
|
Method = 'Patch'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess())
|
||||||
|
{
|
||||||
|
$result = Invoke-Method @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
$scriptRoot = $PSScriptRoot + '\public'
|
$scriptRoot = $PSScriptRoot + '\public'
|
||||||
|
|
||||||
Get-ChildItem $scriptRoot *.psm1 | ForEach-Object {
|
Get-ChildItem $scriptRoot *.psd1 | ForEach-Object {
|
||||||
Import-Module $_.FullName
|
Import-Module $_.FullName
|
||||||
}
|
}
|
||||||
|
|
||||||
$scriptRoot = $PSScriptRoot + '\private'
|
$scriptRoot = $PSScriptRoot + '\private'
|
||||||
|
|
||||||
Get-ChildItem $scriptRoot *.psm1 | ForEach-Object {
|
Get-ChildItem $scriptRoot *.psd1 | ForEach-Object {
|
||||||
Import-Module $_.FullName
|
Import-Module $_.FullName
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ $manifestFile = "$moduleRoot\SnipeitPS.psd1"
|
||||||
$changelogFile = "$projectRoot\CHANGELOG.md"
|
$changelogFile = "$projectRoot\CHANGELOG.md"
|
||||||
$appveyorFile = "$projectRoot\appveyor.yml"
|
$appveyorFile = "$projectRoot\appveyor.yml"
|
||||||
$publicFunctions = "$moduleRoot\Public"
|
$publicFunctions = "$moduleRoot\Public"
|
||||||
$internalFunctions = "$moduleRoot\Internal"
|
|
||||||
|
|
||||||
Describe "SnipeitPS" {
|
Describe "SnipeitPS" {
|
||||||
Context "All required tests are present" {
|
Context "All required tests are present" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue