mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Added more commands and changed way parameters work, also added more parameters to bring it inline with recent api changed
This commit is contained in:
parent
4f22833342
commit
56852d863e
28 changed files with 501 additions and 233 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
function ConvertTo-GetParameter {
|
function ConvertTo-GetParameter {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Generate the GET parameter string for an URL from a hashtable
|
Generate the GET parameter string for an URL from a hashtable
|
||||||
|
|
@ -14,6 +15,8 @@ function ConvertTo-GetParameter {
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS {
|
PROCESS {
|
||||||
|
Add-Type -AssemblyName System.Web
|
||||||
|
|
||||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Making HTTP get parameter string out of a hashtable"
|
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Making HTTP get parameter string out of a hashtable"
|
||||||
foreach ($key in $InputObject.Keys) {
|
foreach ($key in $InputObject.Keys) {
|
||||||
$parameters += "$key=$([System.Web.HttpUtility]::UrlEncode($InputObject[$key]))&"
|
$parameters += "$key=$([System.Web.HttpUtility]::UrlEncode($InputObject[$key]))&"
|
||||||
|
|
|
||||||
59
SnipeitPS/Private/Get-ParameterValue.ps1
Normal file
59
SnipeitPS/Private/Get-ParameterValue.ps1
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
function Get-ParameterValue {
|
||||||
|
#.Synopsis
|
||||||
|
# Get the actual values of parameters which have manually set (non-null) default values or values passed in the call
|
||||||
|
#.Description
|
||||||
|
# Unlike $PSBoundParameters, the hashtable returned from Get-ParameterValues includes non-empty default parameter values.
|
||||||
|
# NOTE: Default values that are the same as the implied values are ignored (e.g.: empty strings, zero numbers, nulls).
|
||||||
|
#.Example
|
||||||
|
# function Test-Parameters {
|
||||||
|
# [CmdletBinding()]
|
||||||
|
# param(
|
||||||
|
# $Name = $Env:UserName,
|
||||||
|
# $Age
|
||||||
|
# )
|
||||||
|
# $Parameters = . Get-ParameterValues
|
||||||
|
#
|
||||||
|
# # This WILL ALWAYS have a value...
|
||||||
|
# Write-Host $Parameters["Name"]
|
||||||
|
#
|
||||||
|
# # But this will NOT always have a value...
|
||||||
|
# Write-Host $PSBoundParameters["Name"]
|
||||||
|
# }
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
# The $MyInvocation for the caller -- DO NOT pass this (dot-source Get-ParameterValues instead)
|
||||||
|
$Invocation = $MyInvocation,
|
||||||
|
# The $PSBoundParameters for the caller -- DO NOT pass this (dot-source Get-ParameterValues instead)
|
||||||
|
$BoundParameters = $PSBoundParameters,
|
||||||
|
|
||||||
|
[string[]]$DefaultExcludeParameter = @("id", "url", "apiKey", 'Debug', 'Verbose')
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($MyInvocation.Line[($MyInvocation.OffsetInLine - 1)] -ne '.') {
|
||||||
|
throw "Get-ParameterValues must be dot-sourced, like this: . Get-ParameterValues"
|
||||||
|
}
|
||||||
|
if ($PSBoundParameters.Count -gt 0) {
|
||||||
|
throw "You should not pass parameters to Get-ParameterValues, just dot-source it like this: . Get-ParameterValues"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ParameterValues = @{}
|
||||||
|
foreach ($parameter in $Invocation.MyCommand.Parameters.GetEnumerator()) {
|
||||||
|
# gm -in $parameter.Value | Out-Default
|
||||||
|
try {
|
||||||
|
$key = $parameter.Key
|
||||||
|
if ($key -notin $DefaultExcludeParameter) {
|
||||||
|
if ($null -ne ($value = Get-Variable -Name $key -ValueOnly -ErrorAction Ignore )) {
|
||||||
|
if ($value -ne ($null -as $parameter.Value.ParameterType)) {
|
||||||
|
$ParameterValues[$key] = $value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($BoundParameters.ContainsKey($key)) {
|
||||||
|
$ParameterValues[$key] = $BoundParameters[$key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {}
|
||||||
|
}
|
||||||
|
return $ParameterValues
|
||||||
|
}
|
||||||
47
SnipeitPS/Public/Get-Accessory.ps1
Normal file
47
SnipeitPS/Public/Get-Accessory.ps1
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
function Get-Accessory() {
|
||||||
|
Param(
|
||||||
|
[string]$search,
|
||||||
|
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[int]$supplier_id,
|
||||||
|
|
||||||
|
[string]$sort = "created_at",
|
||||||
|
|
||||||
|
[ValidateSet("asc", "desc")]
|
||||||
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
[int]$limit = 50,
|
||||||
|
|
||||||
|
[int]$offset,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/accessories"
|
||||||
|
Method = 'Get'
|
||||||
|
GetParameters = $SearchParameter
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -51,7 +51,10 @@ Users API Key for Snipeit, can be set using Set-Info command
|
||||||
Get-Asset -url "https://assets.example.com" -token "token..."
|
Get-Asset -url "https://assets.example.com" -token "token..."
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "MyMachine" }
|
Get-Asset -search "myMachine" -url "https://assets.example.com" -token "token..."
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-Asset -search "myMachine" -url "https://assets.example.com" -token "token..."
|
||||||
#>
|
#>
|
||||||
function Get-Asset() {
|
function Get-Asset() {
|
||||||
Param(
|
Param(
|
||||||
|
|
@ -69,6 +72,10 @@ function Get-Asset() {
|
||||||
|
|
||||||
[int]$location_id,
|
[int]$location_id,
|
||||||
|
|
||||||
|
[int]$depreciation_id,
|
||||||
|
|
||||||
|
[bool]$requestable = $false,
|
||||||
|
|
||||||
[string]$status,
|
[string]$status,
|
||||||
|
|
||||||
[int]$status_id,
|
[int]$status_id,
|
||||||
|
|
@ -89,23 +96,7 @@ function Get-Asset() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('model_id')) { $SearchParameter.Add("model_id", $model_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('category_id')) { $SearchParameter.Add("category_id", $category_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('manufacturer_id')) { $SearchParameter.Add("manufacturer_id", $manufacturer_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('location_id')) { $SearchParameter.Add("location_id", $location_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('status_id')) { $SearchParameter.Add("status_id", $order_number) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('status')) { $SearchParameter.Add("status", $order_number) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/hardware"
|
Uri = "$url/api/v1/hardware"
|
||||||
|
|
|
||||||
|
|
@ -57,15 +57,7 @@ function Get-AssetMaintenance() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('asset_id')) { $SearchParameter.Add("asset_id", $asset_id) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/maintenances"
|
Uri = "$url/api/v1/maintenances"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Category()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/categories"
|
Uri = "$url/api/v1/categories"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Company()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/companies"
|
Uri = "$url/api/v1/companies"
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,14 @@ function Get-Component() {
|
||||||
|
|
||||||
[int]$company_id,
|
[int]$company_id,
|
||||||
|
|
||||||
|
[int]$location_id,
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
[ValidateSet('id', 'name', 'min_amt', 'order_number', 'serial', 'purchase_date', 'purchase_cost', 'company', 'category', 'qty', 'location', 'image', 'created_at')]
|
||||||
|
[string]$sort = "created_at",
|
||||||
|
|
||||||
[int]$limit = 50,
|
[int]$limit = 50,
|
||||||
|
|
||||||
[int]$offset,
|
[int]$offset,
|
||||||
|
|
@ -38,16 +43,7 @@ function Get-Component() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('category_id')) { $SearchParameter.Add("category_id", $category_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/components"
|
Uri = "$url/api/v1/components"
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ function Get-Department()
|
||||||
|
|
||||||
[int]$offset,
|
[int]$offset,
|
||||||
|
|
||||||
|
[ValidateSet('id', 'name', 'image', 'users_count', 'created_at')]
|
||||||
|
[string]$sort = "created_at",
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
||||||
|
|
@ -35,14 +38,7 @@ function Get-Department()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/departments"
|
Uri = "$url/api/v1/departments"
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ function Get-License() {
|
||||||
|
|
||||||
[string]$license_name,
|
[string]$license_name,
|
||||||
|
|
||||||
[string]$license_email,
|
[mailaddress]$license_email,
|
||||||
|
|
||||||
[int]$manufacturer_id,
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
|
@ -40,9 +40,14 @@ function Get-License() {
|
||||||
|
|
||||||
[int]$depreciation_id,
|
[int]$depreciation_id,
|
||||||
|
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
[ValidateSet('id', 'name', 'purchase_cost', 'expiration_date', 'purchase_order', 'order_number', 'notes', 'purchase_date', 'serial', 'company', 'category', 'license_name', 'license_email', 'free_seats_count', 'seats', 'manufacturer', 'supplier')]
|
||||||
|
[string]$sort = "created_at",
|
||||||
|
|
||||||
[int]$limit = 50,
|
[int]$limit = 50,
|
||||||
|
|
||||||
[int]$offset,
|
[int]$offset,
|
||||||
|
|
@ -54,24 +59,7 @@ function Get-License() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('name')) { $SearchParameter.Add("name", $name) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('product_key')) { $SearchParameter.Add("product_key", $product_key) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('purchase_order')) { $SearchParameter.Add("purchase_order", $purchase_order) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('license_name')) { $SearchParameter.Add("license_name", $license_name) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('license_email')) { $SearchParameter.Add("license_email", $license_email) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('manufacturer_id')) { $SearchParameter.Add("manufacturer_id", $manufacturer_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('supplier_id')) { $SearchParameter.Add("supplier_id", $supplier_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('depreciation_id')) { $SearchParameter.Add("depreciation_id", $depreciation_id) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/licenses"
|
Uri = "$url/api/v1/licenses"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Location()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/locations"
|
Uri = "$url/api/v1/locations"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Manufacturer()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/manufacturers"
|
Uri = "$url/api/v1/manufacturers"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Model()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/models"
|
Uri = "$url/api/v1/models"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Status()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/statuslabels"
|
Uri = "$url/api/v1/statuslabels"
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,7 @@ function Get-Supplier()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/suppliers"
|
Uri = "$url/api/v1/suppliers"
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,7 @@ function Get-User() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$SearchParameter = @{
|
$SearchParameter = . Get-ParameterValue
|
||||||
sort = $sort
|
|
||||||
order = $order
|
|
||||||
limit = $limit
|
|
||||||
offset = $offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('location_id')) { $SearchParameter.Add("location_id", $location_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('group_id')) { $SearchParameter.Add("group_id", $group_id) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('department_id')) { $SearchParameter.Add("department_id", $department_id) }
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/users"
|
Uri = "$url/api/v1/users"
|
||||||
|
|
|
||||||
65
SnipeitPS/Public/New-Accessory.ps1
Normal file
65
SnipeitPS/Public/New-Accessory.ps1
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
function New-Accessory() {
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Low"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[ValidateLength(3, 255)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$qty,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[string]$order_number,
|
||||||
|
|
||||||
|
[float]$purchase_cost,
|
||||||
|
|
||||||
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
|
[bool]$requestable,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$supplier_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue
|
||||||
|
|
||||||
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/accessories"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ function New-AssetMaintenance() {
|
||||||
[parameter(mandatory = $false)]
|
[parameter(mandatory = $false)]
|
||||||
[datetime]$completionDate,
|
[datetime]$completionDate,
|
||||||
|
|
||||||
[switch]$is_warranty=$false,
|
[bool]$is_warranty = $false,
|
||||||
|
|
||||||
[decimal]$cost,
|
[decimal]$cost,
|
||||||
|
|
||||||
|
|
@ -71,18 +71,15 @@ function New-AssetMaintenance() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue
|
||||||
"asset_id" = $asset_id
|
|
||||||
"supplier_id" = $supplier_id
|
if ($values['start_date']) {
|
||||||
"asset_maintenance_type" = $asset_maintenance_type
|
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
|
||||||
"title" = $title
|
|
||||||
"start_date" = $startDate.ToString("yyyy-MM-dd")
|
|
||||||
"is_warranty" = [Bool]::Parse($is_warranty)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('completionDate')) { $Values.Add("completion_date", $completionDate.ToString("yyyy-MM-dd")) }
|
if ($values['completionDate']) {
|
||||||
if ($PSBoundParameters.ContainsKey('cost')) { $Values.Add("cost", $cost) }
|
$values['completionDate'] = $values['completionDate'].ToString("yyyy-MM-dd")
|
||||||
if ($PSBoundParameters.ContainsKey('notes')) { $Values.Add("notes", $notes) }
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,7 @@ function New-Company()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue
|
||||||
"name" = $name
|
|
||||||
}
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@
|
||||||
General notes
|
General notes
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function New-Component()
|
function New-Component() {
|
||||||
{
|
|
||||||
[CmdletBinding(
|
[CmdletBinding(
|
||||||
SupportsShouldProcess = $true,
|
SupportsShouldProcess = $true,
|
||||||
ConfirmImpact = "Low"
|
ConfirmImpact = "Low"
|
||||||
|
|
@ -39,11 +38,19 @@ function New-Component()
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$category_id,
|
[int]$category_id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$qty,
|
[string]$qty,
|
||||||
|
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[int]$location_id,
|
||||||
|
|
||||||
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
|
[float]$purchase_cost,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
||||||
|
|
@ -51,10 +58,10 @@ function New-Component()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue
|
||||||
"name" = $name
|
|
||||||
"category_id" = $category_id
|
if ($values['purchase_date']) {
|
||||||
"qty" = $qty
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
@ -66,8 +73,7 @@ function New-Component()
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
{
|
|
||||||
$result = Invoke-SnipeitMethod @Parameters
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ function New-CustomField()
|
||||||
|
|
||||||
[string]$Format = "ANY",
|
[string]$Format = "ANY",
|
||||||
|
|
||||||
|
[bool]$field_encrypted,
|
||||||
|
|
||||||
[string]$CustomFormat,
|
[string]$CustomFormat,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
|
|
@ -44,14 +46,7 @@ function New-CustomField()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue
|
||||||
$Values = @{
|
|
||||||
"name" = $Name
|
|
||||||
"help_text" = $HelpText
|
|
||||||
"element" = $Element
|
|
||||||
"format" = $Format
|
|
||||||
"custom_format" = $CustomFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
#Convert Values to JSON format
|
#Convert Values to JSON format
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@
|
||||||
General notes
|
General notes
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function New-Department()
|
function New-Department() {
|
||||||
{
|
|
||||||
[CmdletBinding(
|
[CmdletBinding(
|
||||||
SupportsShouldProcess = $true,
|
SupportsShouldProcess = $true,
|
||||||
ConfirmImpact = "Low"
|
ConfirmImpact = "Low"
|
||||||
|
|
@ -38,11 +37,13 @@ function New-Department()
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
[string]$company_id,
|
[int]$company_id,
|
||||||
|
|
||||||
[string]$location_id,
|
[int]$location_id,
|
||||||
|
|
||||||
[string]$manager_id,
|
[int]$manager_id,
|
||||||
|
|
||||||
|
[string]$notes,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
@ -51,12 +52,7 @@ function New-Department()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue
|
||||||
"name" = $name
|
|
||||||
"company_id" = $company_id
|
|
||||||
"location_id" = $location_id
|
|
||||||
"manager_id" = $manager_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
|
@ -67,8 +63,7 @@ function New-Department()
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
{
|
|
||||||
$result = Invoke-SnipeitMethod @Parameters
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
88
SnipeitPS/Public/New-License.ps1
Normal file
88
SnipeitPS/Public/New-License.ps1
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
function New-License() {
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Low"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[ValidateLength(3, 255)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$seats,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[datetime]$expiration_date,
|
||||||
|
|
||||||
|
[ValidateLength(1, 120)]
|
||||||
|
[mailaddress]$license_email,
|
||||||
|
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$license_name,
|
||||||
|
|
||||||
|
[bool]$maintained,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[string]$notes,
|
||||||
|
|
||||||
|
[string]$order_number,
|
||||||
|
|
||||||
|
[float]$purchase_cost,
|
||||||
|
|
||||||
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
|
[bool]$reassignable,
|
||||||
|
|
||||||
|
[string]$serial,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$supplier_id,
|
||||||
|
|
||||||
|
[datetime]$termination_date,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue
|
||||||
|
|
||||||
|
if ($values['expiration_date']) {
|
||||||
|
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['termination_date']) {
|
||||||
|
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/licenses"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -47,6 +47,10 @@ function New-Location() {
|
||||||
|
|
||||||
[string]$zip,
|
[string]$zip,
|
||||||
|
|
||||||
|
[int]$manager_id,
|
||||||
|
|
||||||
|
[string]$ldap_ou,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
||||||
|
|
@ -54,14 +58,7 @@ function New-Location() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue
|
||||||
name = $name
|
|
||||||
address = $address
|
|
||||||
address2 = $address2
|
|
||||||
state = $state
|
|
||||||
country = $country
|
|
||||||
zip = $zip
|
|
||||||
}
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
|
|
||||||
65
SnipeitPS/Public/Set-Accessory.ps1
Normal file
65
SnipeitPS/Public/Set-Accessory.ps1
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
function Set-Accessory() {
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Low"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$id,
|
||||||
|
|
||||||
|
[ValidateLength(3, 255)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[int]$qty,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[string]$order_number,
|
||||||
|
|
||||||
|
[float]$purchase_cost,
|
||||||
|
|
||||||
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
|
[bool]$requestable,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$supplier_id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue
|
||||||
|
|
||||||
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/accessories/$id"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
90
SnipeitPS/Public/Set-License.ps1
Normal file
90
SnipeitPS/Public/Set-License.ps1
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
function Set-License() {
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Low"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$id,
|
||||||
|
|
||||||
|
[ValidateLength(3, 255)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$seats,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$category_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[datetime]$expiration_date,
|
||||||
|
|
||||||
|
[ValidateLength(1, 120)]
|
||||||
|
[mailaddress]$license_email,
|
||||||
|
|
||||||
|
[ValidateLength(1, 100)]
|
||||||
|
[string]$license_name,
|
||||||
|
|
||||||
|
[bool]$maintained,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[string]$notes,
|
||||||
|
|
||||||
|
[string]$order_number,
|
||||||
|
|
||||||
|
[float]$purchase_cost,
|
||||||
|
|
||||||
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
|
[bool]$reassignable,
|
||||||
|
|
||||||
|
[string]$serial,
|
||||||
|
|
||||||
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
|
[int]$supplier_id,
|
||||||
|
|
||||||
|
[datetime]$termination_date,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue
|
||||||
|
|
||||||
|
if ($values['expiration_date']) {
|
||||||
|
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values['termination_date']) {
|
||||||
|
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/licenses/$id"
|
||||||
|
Method = 'PUT'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,38 +1,3 @@
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Updates a Model within the Snipe-it asset system
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Long description
|
|
||||||
|
|
||||||
.PARAMETER name
|
|
||||||
Name of the Asset Model
|
|
||||||
|
|
||||||
.PARAMETER model_number
|
|
||||||
Part or model number of the model
|
|
||||||
|
|
||||||
.PARAMETER category_id
|
|
||||||
Category ID that the asset belongs to this can be got using Get-Category
|
|
||||||
|
|
||||||
.PARAMETER manufacturer_id
|
|
||||||
Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer
|
|
||||||
|
|
||||||
.PARAMETER eol
|
|
||||||
Number of months until this model's assets are considered EOL
|
|
||||||
|
|
||||||
.PARAMETER fieldset_id
|
|
||||||
Fieldset ID that the asset uses (Custom fields)
|
|
||||||
|
|
||||||
.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
|
|
||||||
New-Model -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
|
|
||||||
#>
|
|
||||||
|
|
||||||
function Set-Model() {
|
function Set-Model() {
|
||||||
[CmdletBinding(
|
[CmdletBinding(
|
||||||
SupportsShouldProcess = $true,
|
SupportsShouldProcess = $true,
|
||||||
|
|
@ -41,20 +6,23 @@ function Set-Model() {
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
|
[int]$id,
|
||||||
|
|
||||||
|
[ValidateLength(1, 255)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
|
[ValidateLength(1, 255)]
|
||||||
[string]$model_number,
|
[string]$model_number,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
|
||||||
[int]$category_id,
|
[int]$category_id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
|
||||||
[int]$manufacturer_id,
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[ValidateRange(1, 240)]
|
||||||
[int]$eol,
|
[int]$eol,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[Alias("fieldset_id")]
|
||||||
[int]$fieldset_id,
|
[int]$custom_fieldset_id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
@ -63,20 +31,12 @@ function Set-Model() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
$Values = @{
|
$Values = Copy-Parameters -InputObject $PSBoundParameters
|
||||||
name = $name
|
|
||||||
category_id = $category_id
|
|
||||||
manufacturer_id = $manufacturer_id
|
|
||||||
fieldset_id = $fieldset_id
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
|
|
||||||
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
|
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/models"
|
Uri = "$url/api/v1/models/$id"
|
||||||
Method = 'put'
|
Method = 'put'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue