mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Merge pull request #83 from snazy2000/revert-75-get-by-id
Revert "Get everything by id"
This commit is contained in:
commit
756223f7b7
14 changed files with 14 additions and 359 deletions
|
|
@ -5,15 +5,6 @@
|
||||||
.PARAMETER search
|
.PARAMETER search
|
||||||
A text string to search the assets data
|
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
|
.PARAMETER order_number
|
||||||
Optionally restrict asset results to this order number
|
Optionally restrict asset results to this order number
|
||||||
|
|
||||||
|
|
@ -64,20 +55,11 @@ Get-Asset -search "myMachine" -url "https://assets.example.com" -token "token...
|
||||||
|
|
||||||
.EXAMPLE
|
.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() {
|
function Get-Asset() {
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[string]$asset_tag,
|
|
||||||
|
|
||||||
[string]$asset_serial,
|
|
||||||
|
|
||||||
[int]$order_number,
|
[int]$order_number,
|
||||||
|
|
||||||
[int]$model_id,
|
[int]$model_id,
|
||||||
|
|
@ -116,36 +98,8 @@ function Get-Asset() {
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/hardware"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Categories
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Category()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-Category()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/categories"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Companies
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Company()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-Company()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/companies"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Components
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -26,8 +20,6 @@ function Get-Component() {
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[int]$category_id,
|
[int]$category_id,
|
||||||
|
|
||||||
[int]$company_id,
|
[int]$company_id,
|
||||||
|
|
@ -53,18 +45,8 @@ function Get-Component() {
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/components"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Departments
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Department()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -48,18 +40,8 @@ function Get-Department()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/departments"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Licenses
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -26,8 +20,6 @@ function Get-License() {
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
[int] $company_id,
|
[int] $company_id,
|
||||||
|
|
@ -69,18 +61,8 @@ function Get-License() {
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/licenses"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Manufacturers
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Manufacturer()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-Manufacturer()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/manufacturers"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Models
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Model()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[int]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,21 +37,11 @@ function Get-Model()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/models"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
#GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Invoke-SnipeitMethod @Parameters
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Locations
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-SnipeitLocation()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-SnipeitLocation()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/locations"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Status Labels
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Status()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-Status()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/statuslabels"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Suppliers
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -27,8 +21,6 @@ function Get-Supplier()
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[ValidateSet("asc", "desc")]
|
[ValidateSet("asc", "desc")]
|
||||||
[string]$order = "desc",
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
|
@ -45,18 +37,8 @@ function Get-Supplier()
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/suppliers"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
# Gets a list of Snipe-it Users
|
# 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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
|
@ -25,8 +19,6 @@ function Get-User() {
|
||||||
Param(
|
Param(
|
||||||
[string]$search,
|
[string]$search,
|
||||||
|
|
||||||
[string]$id,
|
|
||||||
|
|
||||||
[int]$company_id,
|
[int]$company_id,
|
||||||
|
|
||||||
[int]$location_id,
|
[int]$location_id,
|
||||||
|
|
@ -51,17 +43,8 @@ function Get-User() {
|
||||||
|
|
||||||
$SearchParameter = . Get-ParameterValue
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
$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 = @{
|
$Parameters = @{
|
||||||
Uri = $apiurl
|
Uri = "$url/api/v1/users"
|
||||||
Method = 'Get'
|
Method = 'Get'
|
||||||
GetParameters = $SearchParameter
|
GetParameters = $SearchParameter
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
<#
|
|
||||||
.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
|
|
||||||
|
|
||||||
$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.
Loading…
Add table
Reference in a new issue