mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-14 02:12:29 +00:00
Merge pull request #98 from snazy2000/develop
Develop to master , first 1.1.x version
This commit is contained in:
commit
75fb4caad9
38 changed files with 1190 additions and 167 deletions
|
|
@ -21,23 +21,21 @@ function Get-ParameterValue {
|
|||
# }
|
||||
[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,
|
||||
# Pass $MyInvocation.MyCommand.Parameters to function, powershell 7 seems to only populate variables with dot sourcing
|
||||
[parameter(mandatory = $true)]
|
||||
$Parameters
|
||||
,
|
||||
|
||||
[string[]]$DefaultExcludeParameter = @("id", "url", "apiKey", 'Debug', 'Verbose')
|
||||
[string[]]$DefaultExcludeParameter = @("id", "url", "apiKey", 'Debug', 'Verbose','RequestType','customfields')
|
||||
)
|
||||
|
||||
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"
|
||||
throw "Get-ParameterValue must be dot-sourced, like this: . Get-ParameterValues"
|
||||
}
|
||||
|
||||
|
||||
$ParameterValues = @{}
|
||||
foreach ($parameter in $Invocation.MyCommand.Parameters.GetEnumerator()) {
|
||||
foreach ($parameter in $Parameters.GetEnumerator()) {
|
||||
# gm -in $parameter.Value | Out-Default
|
||||
try {
|
||||
$key = $parameter.Key
|
||||
|
|
@ -48,9 +46,6 @@ function Get-ParameterValue {
|
|||
}
|
||||
}
|
||||
|
||||
if ($BoundParameters.ContainsKey($key)) {
|
||||
$ParameterValues[$key] = $BoundParameters[$key]
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,35 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Accessories
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Accessory data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Accessory
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.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-Accessory -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Accessory -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "HP" }
|
||||
|
||||
#>
|
||||
function Get-Accessory() {
|
||||
Param(
|
||||
[string]$search,
|
||||
|
|
@ -19,6 +51,8 @@ function Get-Accessory() {
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -26,7 +60,7 @@ function Get-Accessory() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories"
|
||||
|
|
@ -35,9 +69,25 @@ function Get-Accessory() {
|
|||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Accessory @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@
|
|||
.PARAMETER search
|
||||
A text string to search the assets data
|
||||
|
||||
.PARAMETER id
|
||||
A text string to search the assets data
|
||||
|
||||
.PARAMETER asset_tag
|
||||
Specify exact asset tag to query
|
||||
|
||||
.PARAMETER asset_serial
|
||||
Specify exact asset serial to query
|
||||
|
||||
.PARAMETER order_number
|
||||
Optionally restrict asset results to this order number
|
||||
|
||||
|
|
@ -36,11 +45,14 @@ Specify the column name you wish to sort by
|
|||
Specify the order (asc or desc) you wish to order by on your sort column
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50.
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -48,18 +60,27 @@ URL of Snipeit system, can be set using Set-Info command
|
|||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -url "https://assets.example.com" -token "token..."
|
||||
Get-Asset -url "https://assets.example.com"-token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -search "myMachine" -url "https://assets.example.com" -token "token..."
|
||||
Get-Asset -search "myMachine"-url "https://assets.example.com"-token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -search "myMachine" -url "https://assets.example.com" -token "token..."
|
||||
Get-Asset -search "myMachine"-url "https://assets.example.com"-token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
|
||||
#>
|
||||
function Get-Asset() {
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[string]$asset_tag,
|
||||
|
||||
[string]$asset_serial,
|
||||
|
||||
[int]$order_number,
|
||||
|
||||
[int]$model_id,
|
||||
|
|
@ -89,6 +110,7 @@ function Get-Asset() {
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -96,18 +118,64 @@ function Get-Asset() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
|
||||
$apiurl = "$url/api/v1/hardware"
|
||||
|
||||
if ($search -and ($asset_tag -or $asset_serial -or $id)) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
if ( $search -or $asset_serial -or $asset_tag) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
|
||||
}
|
||||
$apiurl= "$url/api/v1/hardware/$id"
|
||||
}
|
||||
|
||||
if ($asset_tag) {
|
||||
if ( $search -or $asset_serial -or $id) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
|
||||
}
|
||||
$apiurl= "$url/api/v1/hardware/bytag/$asset_tag"
|
||||
}
|
||||
|
||||
if ($asset_serial) {
|
||||
if ( $search -or $asset_tag) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of-search , -asset_tag or -asset_serial parameter"
|
||||
}
|
||||
$apiurl= "$url/api/v1/hardware/byserial/$asset_serial"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Asset @callargs
|
||||
$res
|
||||
if ( $res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@ Specify the column name you wish to sort by
|
|||
Specify the order (asc or desc) you wish to order by on your sort column
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50.
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -48,6 +51,8 @@ function Get-AssetMaintenance() {
|
|||
|
||||
[int]$limit = 50,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[int]$offset,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
|
|
@ -57,7 +62,7 @@ function Get-AssetMaintenance() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/maintenances"
|
||||
|
|
@ -66,9 +71,25 @@ function Get-AssetMaintenance() {
|
|||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-AssetMaintenance @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Categories
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Categories data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Category
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Category()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Category()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,16 +54,42 @@ function Get-Category()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/categories"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/categories/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Category @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Companies
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Companies data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Company
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Company()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Company()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,16 +54,42 @@ function Get-Company()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/companies"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/companies/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/companies"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Company @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Components
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Components data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Component
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -20,6 +35,8 @@ function Get-Component() {
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[int]$category_id,
|
||||
|
||||
[int]$company_id,
|
||||
|
|
@ -36,6 +53,8 @@ function Get-Component() {
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -43,16 +62,42 @@ function Get-Component() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/components"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/components/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Component @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ function Get-CustomField()
|
|||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Departments
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Departments data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Department
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Department()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Department()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[ValidateSet('id', 'name', 'image', 'users_count', 'created_at')]
|
||||
[string]$sort = "created_at",
|
||||
|
||||
|
|
@ -38,17 +57,43 @@ function Get-Department()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/departments"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/departments/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/departments"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Department @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,22 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Licenses
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Licenses data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific License
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -20,6 +36,8 @@ function Get-License() {
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[string]$name,
|
||||
|
||||
[int] $company_id,
|
||||
|
|
@ -52,6 +70,8 @@ function Get-License() {
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -59,17 +79,43 @@ function Get-License() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/licenses"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/licenses/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-License @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Manufacturers
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Manufactures data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Manufactuter
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Manufacturer()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Manufacturer()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,16 +54,42 @@ function Get-Manufacturer()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/manufacturers"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/manufacturers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Manufacturer @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Models
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Models data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific model
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -9,10 +24,10 @@ URL of Snipeit system, can be set using Set-Info command
|
|||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Models -url "https://assets.example.com" -token "token..."
|
||||
Get-Model -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Models -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "DL380" }
|
||||
Get-Model -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "DL380" }
|
||||
|
||||
#>
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Model()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[int]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Model()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,16 +54,42 @@ function Get-Model()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/models"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/models/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Model @callargs
|
||||
$res
|
||||
if ($res.count -ne $limit ) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Locations
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Locations data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Location
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-SnipeitLocation()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-SnipeitLocation()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,17 +54,43 @@ function Get-SnipeitLocation()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/locations"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/locations/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLocation @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Status Labels
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Status Labels data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Status Label
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Status()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Status()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,16 +54,42 @@ function Get-Status()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/statuslabels"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/statuslabels/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/statuslabels"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Status @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Suppliers
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Supliers data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific Suplier
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -21,6 +36,8 @@ function Get-Supplier()
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -28,6 +45,8 @@ function Get-Supplier()
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -35,17 +54,43 @@ function Get-Supplier()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/suppliers"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/suppliers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/suppliers"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-Supplier @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,21 @@
|
|||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Users
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the User data
|
||||
|
||||
.PARAMETER id
|
||||
A id of specific User
|
||||
|
||||
.PARAMETER limit
|
||||
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
|
||||
|
||||
.PARAMETER offset
|
||||
Offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -19,6 +34,8 @@ function Get-User() {
|
|||
Param(
|
||||
[string]$search,
|
||||
|
||||
[string]$id,
|
||||
|
||||
[int]$company_id,
|
||||
|
||||
[int]$location_id,
|
||||
|
|
@ -27,6 +44,10 @@ function Get-User() {
|
|||
|
||||
[int]$department_id,
|
||||
|
||||
[string]$username,
|
||||
|
||||
[string]$email,
|
||||
|
||||
[ValidateSet("asc", "desc")]
|
||||
[string]$order = "desc",
|
||||
|
||||
|
|
@ -34,6 +55,8 @@ function Get-User() {
|
|||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -41,16 +64,41 @@ function Get-User() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$SearchParameter = . Get-ParameterValue
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$apiurl = "$url/api/v1/users"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$apiurl= "$url/api/v1/users/$id"
|
||||
}
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users"
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
$result
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-User @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function New-Accessory() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
|
|
@ -5,17 +5,42 @@
|
|||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER Tag
|
||||
Asset Tag for the Asset
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Asset
|
||||
.PARAMETER status_id
|
||||
Required Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
.PARAMETER Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
.PARAMETER model_id
|
||||
Required Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
.PARAMETER Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
.PARAMETER name
|
||||
Optional Name of the Asset
|
||||
|
||||
.PARAMETER asset_tag
|
||||
Asset Tag for the Asset, not required when snipe asset_tag autogeneration is on.
|
||||
|
||||
.PARAMETER serial
|
||||
Optional Serial number of the Asset
|
||||
|
||||
.PARAMETER company_id
|
||||
Optional Company id
|
||||
|
||||
.PARAMETER order_number
|
||||
Optional Order number
|
||||
|
||||
.PARAMETER notes
|
||||
Optional Notes
|
||||
|
||||
.PARAMETER warranty_monhts
|
||||
Optional Warranty lenght of the Asset in months
|
||||
|
||||
.PARAMETER purchase_cost
|
||||
Optional Purchase cost of the Asset
|
||||
|
||||
.PARAMETER purchase_date
|
||||
Optional Purchase cost of the Asset
|
||||
|
||||
.PARAMETER rtd_location_id
|
||||
Optional Default location id for the asset
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
|
@ -41,16 +66,46 @@ function New-Asset()
|
|||
)]
|
||||
|
||||
Param(
|
||||
[string]$tag,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Name,
|
||||
[int]$status_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$Status_id,
|
||||
[int]$model_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$Model_id,
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[Alias('tag')]
|
||||
[string]$asset_tag,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$serial,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$company_id,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$order_number,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$notes,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$warranty_months,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$purchase_cost,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$purchase_date,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$supplier_id,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$rtd_location_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
|
@ -61,16 +116,8 @@ function New-Asset()
|
|||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('tag'))
|
||||
{
|
||||
$Values += @{"asset_tag" = $tag}
|
||||
}
|
||||
|
||||
if ($customfields)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ function New-AssetMaintenance() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['start_date']) {
|
||||
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
82
SnipeitPS/Public/New-Category.ps1
Normal file
82
SnipeitPS/Public/New-Category.ps1
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Create a new Snipe-IT Category
|
||||
.PARAMETER name
|
||||
Name of new category to be created
|
||||
.PARAMETER type
|
||||
Type of new category to be created (asset, accessory, consumable, component, license)
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
.PARAMETER apiKey
|
||||
User's API Key for Snipeit, can be set using Set-Info command
|
||||
.PARAMETER use_default_eula
|
||||
If switch is present, use the primary default EULA
|
||||
.PARAMETER require_acceptance
|
||||
If switch is present, require users to confirm acceptance of assets in this category
|
||||
.PARAMETER checkin_email
|
||||
If switch is present, send email to user on checkin/checkout
|
||||
.EXAMPLE
|
||||
New-Category -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..."
|
||||
#>
|
||||
|
||||
function New-Category()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[ValidateSet("asset", "accessory", "consumable", "component", "license")]
|
||||
[string]$category_type,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey,
|
||||
|
||||
[switch]$use_default_eula,
|
||||
|
||||
[switch]$require_acceptance,
|
||||
|
||||
[switch]$checkin_email
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $name
|
||||
"category_type" = $category_type
|
||||
}
|
||||
|
||||
if ($use_default_eula) {
|
||||
$Values += @{"use_default_eula" = $true}
|
||||
}
|
||||
|
||||
if ($require_acceptance) {
|
||||
$Values += @{"require_acceptance" = $true}
|
||||
}
|
||||
|
||||
if ($checkin_email) {
|
||||
$Values += @{"checkin_email" = $true}
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ function New-Company()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ function New-Component() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function New-CustomField()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
#Convert Values to JSON format
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function New-Department() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function New-License() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['expiration_date']) {
|
||||
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,39 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Model to Snipe-it asset system
|
||||
Add a new Location to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER name
|
||||
Name of the Asset Model
|
||||
Name of the Location
|
||||
|
||||
.PARAMETER category_id
|
||||
Category ID that the asset belongs to this can be got using Get-Category
|
||||
.PARAMETER address
|
||||
Address line 1 of the location
|
||||
|
||||
.PARAMETER manufacturer_id
|
||||
Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer
|
||||
.PARAMETER address2
|
||||
Address line 2 of the location
|
||||
|
||||
.PARAMETER fieldset_id
|
||||
Fieldset ID that the asset uses (Custom fields)
|
||||
.PARAMETER state
|
||||
Address State of the location
|
||||
|
||||
.PARAMETER country
|
||||
Country of the location
|
||||
|
||||
.PARAMETER zip
|
||||
The zip code of the location
|
||||
|
||||
.PARAMETER ldap_ou
|
||||
The LDAP OU of the location
|
||||
|
||||
.PARAMETER parent_id
|
||||
Parent location ID for the location
|
||||
|
||||
.PARAMETER currency
|
||||
Currency used at the location
|
||||
|
||||
.PARAMETER manager_id
|
||||
The manager ID of the location
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
|
@ -24,7 +42,7 @@
|
|||
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
|
||||
New-Location -name "Room 1" -address "123 Asset Street" -parent_id 14
|
||||
#>
|
||||
|
||||
function New-Location() {
|
||||
|
|
@ -47,6 +65,8 @@ function New-Location() {
|
|||
|
||||
[string]$zip,
|
||||
|
||||
[int]$parent_id,
|
||||
|
||||
[int]$manager_id,
|
||||
|
||||
[string]$ldap_ou,
|
||||
|
|
@ -58,7 +78,7 @@ function New-Location() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,22 @@
|
|||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER firstName
|
||||
.PARAMETER first_name
|
||||
Parameter description
|
||||
|
||||
.PARAMETER lastName
|
||||
.PARAMETER last_name
|
||||
Parameter description
|
||||
|
||||
.PARAMETER userName
|
||||
.PARAMETER username
|
||||
Parameter description
|
||||
|
||||
.PARAMETER jobTitle
|
||||
.PARAMETER active
|
||||
Parameter description
|
||||
|
||||
.PARAMETER notes
|
||||
Parameter description
|
||||
|
||||
.PARAMETER jobtitle
|
||||
Parameter description
|
||||
|
||||
.PARAMETER email
|
||||
|
|
@ -38,8 +44,8 @@
|
|||
.PARAMETER employee_num
|
||||
Parameter description
|
||||
|
||||
.PARAMETER ldap_user
|
||||
Parameter description
|
||||
.PARAMETER ldap_import
|
||||
Mark user as import from ldap
|
||||
|
||||
.PARAMETER url
|
||||
Parameter description
|
||||
|
|
@ -62,17 +68,21 @@ function New-User() {
|
|||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$firstName,
|
||||
[string]$first_name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$lastName,
|
||||
[string]$last_name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$userName,
|
||||
[string]$username,
|
||||
|
||||
[string]$password,
|
||||
|
||||
[string]$jobTitle,
|
||||
[bool]$activated = $false,
|
||||
|
||||
[string]$notes,
|
||||
|
||||
[string]$jobtitle,
|
||||
|
||||
[string]$email,
|
||||
|
||||
|
|
@ -88,7 +98,8 @@ function New-User() {
|
|||
|
||||
[string]$employee_num,
|
||||
|
||||
[bool]$ldap_user = $false,
|
||||
[bool]$ldap_import = $false,
|
||||
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
|
@ -97,36 +108,10 @@ function New-User() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
first_name = $firstName
|
||||
last_name = $lastName
|
||||
username = $userName
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
email = $email
|
||||
phone = $phone
|
||||
company_id = $company_id
|
||||
location_id = $location_id
|
||||
department_id = $department_id
|
||||
manager_id = $manager_id
|
||||
jobtitle = $jobTitle
|
||||
employee_num = $employee_num
|
||||
notes = "Imported using SnipeitPS Script"
|
||||
activated = 1
|
||||
}
|
||||
|
||||
if ($ldap_user -eq $false) {
|
||||
$ldap = @{
|
||||
password = $password
|
||||
password_confirmation = $password
|
||||
ldap_import = 0
|
||||
}
|
||||
$Values += $ldap
|
||||
}
|
||||
else {
|
||||
$ldap = @{
|
||||
ldap_import = 1
|
||||
}
|
||||
$Values += $ldap
|
||||
if ($password ) {
|
||||
$Values['password_confirmation'] = $password
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
|
|
|||
52
SnipeitPS/Public/Remove-AssetMaintenance.ps1
Normal file
52
SnipeitPS/Public/Remove-AssetMaintenance.ps1
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
function Remove-AssetMaintenance {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Remove asset maintenance from Snipe-it asset system
|
||||
.DESCRIPTION
|
||||
Removes asset maintenance event from Snipe-it asset system by ID
|
||||
.PARAMETER ID
|
||||
Unique ID of the asset maintenance to be removed
|
||||
.EXAMPLE
|
||||
Remove-AssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose
|
||||
#>
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
param (
|
||||
# Asset maintenance ID
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$ID,
|
||||
|
||||
# SnipeIt URL
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$url,
|
||||
|
||||
# SnipeIt ApiKey
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"ID" = $ID
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/maintenances/$ID"
|
||||
Method = 'Delete'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
48
SnipeitPS/Public/Remove-User.ps1
Normal file
48
SnipeitPS/Public/Remove-User.ps1
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Removes User from Snipe-it asset system
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
.PARAMETER ID
|
||||
Unique ID For User to be removed
|
||||
.EXAMPLE
|
||||
Remove-User -ID 44 -url $url -apiKey $secret -Verbose
|
||||
#>
|
||||
|
||||
function Remove-User ()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$ID,
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$URL,
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$APIKey
|
||||
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"ID" = $ID
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$ID"
|
||||
Method = 'Delete'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ function Set-Accessory() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Update a Asset in the Snipe-it asset system
|
||||
Update a specific Asset in the Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
ID of the Asset
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Asset
|
||||
Asset name
|
||||
|
||||
.PARAMETER Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
|
|
@ -17,6 +17,39 @@
|
|||
.PARAMETER Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
.PARAMETER last_checkout
|
||||
Date the asset was last checked out
|
||||
|
||||
.PARAMETER assigned_to
|
||||
The id of the user the asset is currently checked out to
|
||||
|
||||
.PARAMETER company_id
|
||||
The id of an associated company id
|
||||
|
||||
.PARAMETER serial
|
||||
Serial number of the asset
|
||||
|
||||
.PARAMETER order_number
|
||||
Order number for the asset
|
||||
|
||||
.PARAMETER warranty_months
|
||||
Number of months for the asset warranty
|
||||
|
||||
.PARAMETER purchase_cost
|
||||
Purchase cost of the asset, without a currency symbol
|
||||
|
||||
.PARAMETER purchase_date
|
||||
Date of asset purchase
|
||||
|
||||
.PARAMETER requestable
|
||||
Whether or not the asset can be requested by users with the permission to request assets
|
||||
|
||||
.PARAMETER archived
|
||||
Whether or not the asset is archived. Archived assets cannot be checked out and do not show up in the deployable asset screens
|
||||
|
||||
.PARAMETER rtd_location_id
|
||||
The id that corresponds to the location where the asset is usually located when not checked out
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
|
|
@ -50,6 +83,28 @@ function Set-Asset()
|
|||
|
||||
[string]$Model_id,
|
||||
|
||||
[DateTime]$last_checkout,
|
||||
|
||||
[int]$assigned_to,
|
||||
|
||||
[int]$company_id,
|
||||
|
||||
[string]$serial,
|
||||
|
||||
[string]$order_number,
|
||||
|
||||
[int]$warranty_months,
|
||||
|
||||
[double]$purchase_cost,
|
||||
|
||||
[DateTime]$purchase_date,
|
||||
|
||||
[bool]$requestable,
|
||||
|
||||
[bool]$archived,
|
||||
|
||||
[int]$rtd_location_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -59,11 +114,9 @@ function Set-Asset()
|
|||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($model_id) { $Values.Add('model_id',$model_id)}
|
||||
|
||||
if ($customfields)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ function Set-AssetOwner()
|
|||
)
|
||||
|
||||
$Values = @{
|
||||
"id" = $assigned_id
|
||||
"id" = $id
|
||||
"checkout_to_type" = $checkout_to_type
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function Set-Component()
|
|||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Uri = "$url/api/v1/components/$id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ function Set-License() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($values['expiration_date']) {
|
||||
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ function Set-Model() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
|
|
|
|||
102
SnipeitPS/Public/Set-SnipeitLocation.ps1
Normal file
102
SnipeitPS/Public/Set-SnipeitLocation.ps1
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Updates Location in Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER name
|
||||
Name of Location
|
||||
|
||||
.PARAMETER address
|
||||
Address line 1
|
||||
|
||||
.PARAMETER address2
|
||||
Address line 2
|
||||
|
||||
.PARAMETER state
|
||||
Address State
|
||||
|
||||
.PARAMETER country
|
||||
Address Contry
|
||||
|
||||
.PARAMETER zip
|
||||
Address zipcode
|
||||
|
||||
.PARAMETER state
|
||||
Address State
|
||||
|
||||
.PARAMETER manager_id
|
||||
Location manager as id
|
||||
|
||||
.PARAMETER ldap_ou
|
||||
LDAP OU of Location
|
||||
|
||||
.PARAMETER parent_id
|
||||
Parent location as id
|
||||
|
||||
.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
|
||||
Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100
|
||||
|
||||
|
||||
#>
|
||||
function Set-SnipeitLocation() {
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$id,
|
||||
|
||||
[ValidateLength(3, 255)]
|
||||
[string]$name,
|
||||
|
||||
[string]$address,
|
||||
|
||||
[string]$address2,
|
||||
|
||||
[string]$state,
|
||||
|
||||
[string]$country,
|
||||
|
||||
[string]$zip,
|
||||
|
||||
[int]$manager_id,
|
||||
|
||||
[string]$ldap_ou,
|
||||
|
||||
[int]$parent_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations/$id"
|
||||
Method = 'PUT'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
Binary file not shown.
|
|
@ -14,7 +14,7 @@ environment:
|
|||
PSGalleryAPIKey:
|
||||
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
|
||||
|
||||
version: 1.0.{build}
|
||||
version: 1.1.{build}
|
||||
|
||||
# Don't rebuild when I tag a release on GitHub
|
||||
skip_tags: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue