diff --git a/SnipeitPS/Public/Get-Asset.ps1 b/SnipeitPS/Public/Get-Asset.ps1 index cbcff27..1a84f4e 100644 --- a/SnipeitPS/Public/Get-Asset.ps1 +++ b/SnipeitPS/Public/Get-Asset.ps1 @@ -5,6 +5,9 @@ .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 @@ -69,6 +72,8 @@ function Get-Asset() { Param( [string]$search, + [string]$id, + [string]$asset_tag, [string]$asset_serial, @@ -114,20 +119,27 @@ function Get-Asset() { $apiuri = "$url/api/v1/hardware" - if ($search -and ($asset_tag -or $asset_serial)) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " + 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" + } + $apiuri= "$url/api/v1/hardware/$id" } if ($asset_tag) { if ( $search -or $asset_serial) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter" } $apiuri= "$url/api/v1/hardware/bytag/$asset_tag" } if ($asset_serial) { if ( $search -or $asset_tag) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of-search , -asset_tag or -asset_serial parameter" } $apiuri= "$url/api/v1/hardware/byserial/$asset_serial" } diff --git a/SnipeitPS/Public/Get-Category.ps1 b/SnipeitPS/Public/Get-Category.ps1 index 0c697c9..e9cc736 100644 --- a/SnipeitPS/Public/Get-Category.ps1 +++ b/SnipeitPS/Public/Get-Category.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Category() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -36,9 +44,19 @@ function Get-Category() ) $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) { + $apiuri= "$url/api/v1/categories/$id" + } $Parameters = @{ - Uri = "$url/api/v1/categories" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Company.ps1 b/SnipeitPS/Public/Get-Company.ps1 index 1f20ba2..98c6244 100644 --- a/SnipeitPS/Public/Get-Company.ps1 +++ b/SnipeitPS/Public/Get-Company.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Company() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -37,8 +45,18 @@ function Get-Company() $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) { + $apiuri= "$url/api/v1/companies/$id" + } + $Parameters = @{ - Uri = "$url/api/v1/companies" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Component.ps1 b/SnipeitPS/Public/Get-Component.ps1 index e55616d..8f7d510 100644 --- a/SnipeitPS/Public/Get-Component.ps1 +++ b/SnipeitPS/Public/Get-Component.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -19,6 +25,8 @@ Get-Component -url "https://assets.example.com" -token "token..." | Where-Object function Get-Component() { Param( [string]$search, + + [string]$id, [int]$category_id, @@ -45,8 +53,18 @@ function Get-Component() { $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) { + $apiuri= "$url/api/v1/components/$id" + } + $Parameters = @{ - Uri = "$url/api/v1/components" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Department.ps1 b/SnipeitPS/Public/Get-Department.ps1 index 840409e..aed2394 100644 --- a/SnipeitPS/Public/Get-Department.ps1 +++ b/SnipeitPS/Public/Get-Department.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Department() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -39,9 +47,19 @@ function Get-Department() ) $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) { + $apiuri= "$url/api/v1/departments/$id" + } $Parameters = @{ - Uri = "$url/api/v1/departments" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-License.ps1 b/SnipeitPS/Public/Get-License.ps1 index fccb45e..78020a9 100644 --- a/SnipeitPS/Public/Get-License.ps1 +++ b/SnipeitPS/Public/Get-License.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -20,6 +26,8 @@ function Get-License() { Param( [string]$search, + [string]$id, + [string]$name, [int] $company_id, @@ -60,9 +68,19 @@ function Get-License() { ) $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) { + $apiuri= "$url/api/v1/licenses/$id" + } $Parameters = @{ - Uri = "$url/api/v1/licenses" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Manufacturer.ps1 b/SnipeitPS/Public/Get-Manufacturer.ps1 index b55798e..c4c9433 100644 --- a/SnipeitPS/Public/Get-Manufacturer.ps1 +++ b/SnipeitPS/Public/Get-Manufacturer.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Manufacturer() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -37,8 +45,18 @@ function Get-Manufacturer() $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) { + $apiuri= "$url/api/v1/manufacturers/$id" + } + $Parameters = @{ - Uri = "$url/api/v1/manufacturers" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Model.ps1 b/SnipeitPS/Public/Get-Model.ps1 index c15d7c7..8c2396d 100644 --- a/SnipeitPS/Public/Get-Model.ps1 +++ b/SnipeitPS/Public/Get-Model.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Model() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -36,9 +44,19 @@ function Get-Model() ) $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) { + $apiuri= "$url/api/v1/models/$id" + } $Parameters = @{ - Uri = "$url/api/v1/models" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-SnipeitLocation.ps1 b/SnipeitPS/Public/Get-SnipeitLocation.ps1 index 0030a89..ce95e2b 100644 --- a/SnipeitPS/Public/Get-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Get-SnipeitLocation.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -20,6 +26,8 @@ function Get-SnipeitLocation() { Param( [string]$search, + + [string]$id, [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -37,8 +45,18 @@ function Get-SnipeitLocation() $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) { + $apiuri= "$url/api/v1/locations/$id" + } + $Parameters = @{ - Uri = "$url/api/v1/locations" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Status.ps1 b/SnipeitPS/Public/Get-Status.ps1 index a5f4f89..21eecff 100644 --- a/SnipeitPS/Public/Get-Status.ps1 +++ b/SnipeitPS/Public/Get-Status.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Status() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -36,9 +44,19 @@ function Get-Status() ) $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) { + $apiuri= "$url/api/v1/statuslabels/$id" + } $Parameters = @{ - Uri = "$url/api/v1/statuslabels" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-Supplier.ps1 b/SnipeitPS/Public/Get-Supplier.ps1 index f556cd4..c0874eb 100644 --- a/SnipeitPS/Public/Get-Supplier.ps1 +++ b/SnipeitPS/Public/Get-Supplier.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -21,6 +27,8 @@ function Get-Supplier() Param( [string]$search, + [string]$id, + [ValidateSet("asc", "desc")] [string]$order = "desc", @@ -36,9 +44,19 @@ function Get-Supplier() ) $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) { + $apiuri= "$url/api/v1/suppliers/$id" + } $Parameters = @{ - Uri = "$url/api/v1/suppliers" + Uri = $apiurl Method = 'Get' Token = $apiKey GetParameters = $SearchParameter diff --git a/SnipeitPS/Public/Get-User.ps1 b/SnipeitPS/Public/Get-User.ps1 index 00132fd..f3c4c7d 100644 --- a/SnipeitPS/Public/Get-User.ps1 +++ b/SnipeitPS/Public/Get-User.ps1 @@ -2,6 +2,12 @@ .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 url URL of Snipeit system, can be set using Set-Info command @@ -18,6 +24,8 @@ Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_. function Get-User() { Param( [string]$search, + + [string]$id, [int]$company_id, @@ -41,10 +49,19 @@ function Get-User() { [string]$apiKey ) - $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) { + $apiuri= "$url/api/v1/users/$id" + } $Parameters = @{ - Uri = "$url/api/v1/users" + Uri = $apiurl Method = 'Get' GetParameters = $SearchParameter Token = $apiKey