From 3a5d951cb9af21de687b7726e42f65252632389c Mon Sep 17 00:00:00 2001 From: Matthew Carras Date: Wed, 31 Aug 2022 14:30:45 -0400 Subject: [PATCH] Update Get Functions * Add additional parameters to Get functions, especially -name wherever possible. * Add some missing function help --- SnipeitPS/Public/Get-SnipeitAccessory.ps1 | 15 ++++ SnipeitPS/Public/Get-SnipeitAsset.ps1 | 36 ++++++++- SnipeitPS/Public/Get-SnipeitCategory.ps1 | 6 ++ SnipeitPS/Public/Get-SnipeitCompany.ps1 | 6 ++ SnipeitPS/Public/Get-SnipeitComponent.ps1 | 15 ++++ SnipeitPS/Public/Get-SnipeitConsumable.ps1 | 6 ++ SnipeitPS/Public/Get-SnipeitDepartment.ps1 | 24 ++++++ SnipeitPS/Public/Get-SnipeitLocation.ps1 | 36 +++++++++ SnipeitPS/Public/Get-SnipeitManufacturer.ps1 | 6 ++ SnipeitPS/Public/Get-SnipeitStatus.ps1 | 6 ++ SnipeitPS/Public/Get-SnipeitSupplier.ps1 | 54 +++++++++++++ SnipeitPS/Public/Get-SnipeitUser.ps1 | 82 +++++++++++++++++++- 12 files changed, 289 insertions(+), 3 deletions(-) diff --git a/SnipeitPS/Public/Get-SnipeitAccessory.ps1 b/SnipeitPS/Public/Get-SnipeitAccessory.ps1 index 0edea67..f392832 100644 --- a/SnipeitPS/Public/Get-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAccessory.ps1 @@ -8,9 +8,24 @@ Gets a list of Snipe-it Accessories .PARAMETER search A text string to search the Accessory data +.PARAMETER user_id +Return Accessories checked out to user id + .PARAMETER id A id of specific Accessory +.PARAMETER company_id +Optionally restrict Accessory results to this company_id field + +.PARAMETER category_id +Optionally restrict Accessory results to this category_id field + +.PARAMETER manufacturer_id +Optionally restrict Accessory results to this manufacturer_id field + +.PARAMETER supplier_id +Optionally restrict Accessory results to this supplier_id field + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all diff --git a/SnipeitPS/Public/Get-SnipeitAsset.ps1 b/SnipeitPS/Public/Get-SnipeitAsset.ps1 index 1082a20..1d68f8f 100644 --- a/SnipeitPS/Public/Get-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAsset.ps1 @@ -20,12 +20,21 @@ Retrieve a list of assets that are due for auditing soon. .PARAMETER audit_overdue Retrieve a list of assets that are overdue for auditing. +.PARAMETER user_id +Retrieve a list of assets checked out to user id. + +.PARAMETER component_id +Retrieve a list of assets assigned this component id. + +.PARAMETER name +Optionally restrict asset results to this asset name + .PARAMETER order_number Optionally restrict asset results to this order number .PARAMETER model_id Optionally restrict asset results to this asset model ID - + .PARAMETER category_id Optionally restrict asset results to this category ID @@ -38,12 +47,22 @@ Optionally restrict asset results to this company ID .PARAMETER location_id Optionally restrict asset results to this location ID +.PARAMETER depreciation_id +Optionally restrict asset results to this depreciation ID + +.PARAMETER requestable +Optionally restrict asset results to those set as requestable + .PARAMETER status Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable .PARAMETER status_id Optionally restrict asset results to this status label ID +.PARAMETER customfields +Hastable of custom fields and extra fields for searching assets in Snipe-It. +Use internal field names from Snipe-It. You can use Get-CustomField to get internal field names. + .PARAMETER sort Specify the column name you wish to sort by @@ -132,6 +151,9 @@ function Get-SnipeitAsset() { [parameter(ParameterSetName='Assets with component id')] [int]$component_id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [string]$order_number, @@ -162,6 +184,9 @@ function Get-SnipeitAsset() { [parameter(ParameterSetName='Search')] [int]$status_id, + [parameter(ParameterSetName='Search')] + [hashtable]$customfields, + [parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Assets due auditing soon')] [parameter(ParameterSetName='Assets overdue for auditing')] @@ -211,6 +236,15 @@ function Get-SnipeitAsset() { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + # Add in custom fields. + if ($customfields.Count -gt 0) { + foreach ($pair in $customfields.GetEnumerator()) { + if (-Not $SearchParameter.ContainsKey($pair.Name)) { + $SearchParameter.Add($pair.Name, $pair.Value) + } + } + } + switch ($PsCmdlet.ParameterSetName) { 'Search' { $api = "/api/v1/hardware" } 'Get with id' {$api= "/api/v1/hardware/$id"} diff --git a/SnipeitPS/Public/Get-SnipeitCategory.ps1 b/SnipeitPS/Public/Get-SnipeitCategory.ps1 index ac240f7..b2134b4 100644 --- a/SnipeitPS/Public/Get-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Get-SnipeitCategory.ps1 @@ -8,6 +8,9 @@ A text string to search the Categories data .PARAMETER id A id of specific Category +.PARAMETER name +Optionally restrict Category results to this Category name. + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -40,6 +43,9 @@ function Get-SnipeitCategory() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitCompany.ps1 b/SnipeitPS/Public/Get-SnipeitCompany.ps1 index a01edcb..94f6169 100644 --- a/SnipeitPS/Public/Get-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Get-SnipeitCompany.ps1 @@ -8,6 +8,9 @@ A text string to search the Companies data .PARAMETER id A id of specific Company +.PARAMETER name +Optionally restrict company results to this company name. + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -41,6 +44,9 @@ function Get-SnipeitCompany() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitComponent.ps1 b/SnipeitPS/Public/Get-SnipeitComponent.ps1 index 7c7ef7d..46f123d 100644 --- a/SnipeitPS/Public/Get-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Get-SnipeitComponent.ps1 @@ -8,6 +8,18 @@ A text string to search the Components data .PARAMETER id A id of specific Component +.PARAMETER name +Optionally restrict Component results to this name field + +.PARAMETER company_id +Optionally restrict Component results to this company_id field + +.PARAMETER category_id +Optionally restrict Component results to this category_id field + +.PARAMETER location_id +Optionally restrict Component results to this location_id field + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -45,6 +57,9 @@ function Get-SnipeitComponent() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [int]$category_id, diff --git a/SnipeitPS/Public/Get-SnipeitConsumable.ps1 b/SnipeitPS/Public/Get-SnipeitConsumable.ps1 index 9424261..9b400af 100644 --- a/SnipeitPS/Public/Get-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Get-SnipeitConsumable.ps1 @@ -8,6 +8,9 @@ A text string to search the consumables .PARAMETER id A id of specific consumable +.PARAMETER name +Optionally restrict consumable results to this name field + .PARAMETER company_id Id number of company @@ -63,6 +66,9 @@ function Get-SnipeitConsumable() { [parameter(ParameterSetName='Get with ID')] [int[]]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [int]$category_id, diff --git a/SnipeitPS/Public/Get-SnipeitDepartment.ps1 b/SnipeitPS/Public/Get-SnipeitDepartment.ps1 index e9dd7d7..4c61e4a 100644 --- a/SnipeitPS/Public/Get-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Get-SnipeitDepartment.ps1 @@ -8,6 +8,18 @@ A text string to search the Departments data .PARAMETER id A id of specific Department +.PARAMETER name +Optionally restrict department results to this department name. + +.PARAMETER manager_id +Optionally restrict department results to this manager ID. + +.PARAMETER company_id +Optionally restrict department results to this company ID. + +.PARAMETER location_id +Optionally restrict department results to this location ID. + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -43,6 +55,18 @@ function Get-SnipeitDepartment() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + + [parameter(ParameterSetName='Search')] + [int]$manager_id, + + [parameter(ParameterSetName='Search')] + [int]$company_id, + + [parameter(ParameterSetName='Search')] + [int]$location_id, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitLocation.ps1 b/SnipeitPS/Public/Get-SnipeitLocation.ps1 index 91ebb05..2fba84e 100644 --- a/SnipeitPS/Public/Get-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Get-SnipeitLocation.ps1 @@ -8,6 +8,24 @@ A text string to search the Locations data .PARAMETER id A id of specific Location +.PARAMETER name +Optionally restrict Location results to this Location name. + +.PARAMETER address +Optionally restrict Location results to this Location address. + +.PARAMETER address2 +Optionally restrict Location results to this Location address2. + +.PARAMETER city +Optionally restrict Location results to this Location city. + +.PARAMETER zip +Optionally restrict Location results to this Location zip. + +.PARAMETER country +Optionally restrict Location results to this Location country. + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -40,6 +58,24 @@ function Get-SnipeitLocation() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + + [parameter(ParameterSetName='Search')] + [string]$address, + + [parameter(ParameterSetName='Search')] + [string]$address2, + + [parameter(ParameterSetName='Search')] + [string]$city, + + [parameter(ParameterSetName='Search')] + [string]$zip, + + [parameter(ParameterSetName='Search')] + [string]$country, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 index 594d7b2..9d7f8c3 100644 --- a/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 @@ -8,6 +8,9 @@ .PARAMETER id A id of specific Manufactuter + .PARAMETER name + Optionally restrict Manufacturer results to this name field + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -41,6 +44,9 @@ function Get-SnipeitManufacturer() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitStatus.ps1 b/SnipeitPS/Public/Get-SnipeitStatus.ps1 index b50e29d..a1b3521 100644 --- a/SnipeitPS/Public/Get-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Get-SnipeitStatus.ps1 @@ -8,6 +8,9 @@ A text string to search the Status Labels data .PARAMETER id A id of specific Status Label +.PARAMETER name +Optionally restrict Status Label results to this name field + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -40,6 +43,9 @@ function Get-SnipeitStatus() { [parameter(ParameterSetName='Get with ID')] [int]$id, + [parameter(ParameterSetName='Search')] + [string]$name, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc", diff --git a/SnipeitPS/Public/Get-SnipeitSupplier.ps1 b/SnipeitPS/Public/Get-SnipeitSupplier.ps1 index b3b7368..4dccaff 100644 --- a/SnipeitPS/Public/Get-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/Get-SnipeitSupplier.ps1 @@ -8,6 +8,33 @@ A text string to search the Supliers data .PARAMETER id A id of specific Suplier +.PARAMETER name +Optionally restrict Supplier results to this Supplier name. + +.PARAMETER address +Optionally restrict Supplier results to this Supplier address. + +.PARAMETER address2 +Optionally restrict Supplier results to this Supplier address2. + +.PARAMETER city +Optionally restrict Supplier results to this Supplier city. + +.PARAMETER zip +Optionally restrict Supplier results to this Supplier zip. + +.PARAMETER country +Optionally restrict Supplier results to this Supplier country. + +.PARAMETER fax +Optionally restrict Supplier results to this Supplier fax number. + +.PARAMETER email +Optionally restrict Supplier results to this Supplier email address. + +.PARAMETER notes +Optionally restrict Supplier results to this Supplier notes field. + .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -43,6 +70,33 @@ function Get-SnipeitSupplier() { [ValidateSet("asc", "desc")] [string]$order = "desc", + [parameter(ParameterSetName='Search')] + [string]$name, + + [parameter(ParameterSetName='Search')] + [string]$address, + + [parameter(ParameterSetName='Search')] + [string]$address2, + + [parameter(ParameterSetName='Search')] + [string]$city, + + [parameter(ParameterSetName='Search')] + [string]$zip, + + [parameter(ParameterSetName='Search')] + [string]$country, + + [parameter(ParameterSetName='Search')] + [string]$fax, + + [parameter(ParameterSetName='Search')] + [string]$email, + + [parameter(ParameterSetName='Search')] + [string]$notes, + [parameter(ParameterSetName='Search')] [int]$limit = 50, diff --git a/SnipeitPS/Public/Get-SnipeitUser.ps1 b/SnipeitPS/Public/Get-SnipeitUser.ps1 index 091f313..a84da1d 100644 --- a/SnipeitPS/Public/Get-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Get-SnipeitUser.ps1 @@ -8,11 +8,56 @@ A text string to search the User data .PARAMETER id A id of specific User +.PARAMETER accessory_id +Get users a specific accessory id has been checked out to + .PARAMETER username -Search string for username field +Optionally restrict User results to this username field .PARAMETER email -Search string for email field +Optionally restrict User results to this email field + +.PARAMETER employee_num +Optionally restrict User results to this employee_num field + +.PARAMETER state +Optionally restrict User results to this state field + +.PARAMETER country +Optionally restrict User results to this country field + +.PARAMETER zip +Optionally restrict User results to this zip field + +.PARAMETER company_id +Optionally restrict User results to this company_id field + +.PARAMETER location_id +Optionally restrict User results to this location_id field + +.PARAMETER department_id +Optionally restrict User results to this department_id field + +.PARAMETER deleted +Optionally restrict User results to deleted users only + +.PARAMETER ldap_import +Optionally restrict User results to those with specified ldap_import value + +.PARAMETER remote +Optionally restrict User results to those with specified remote worker value + +.PARAMETER assets_count +Optionally restrict User results to those with the specified assets count + +.PARAMETER licenses_count +Optionally restrict User results to those with the specified licenses count + +.PARAMETER accessories_count +Optionally restrict User results to those with the specified accessories count + +.PARAMETER consumables_count +Optionally restrict User results to those with the specified consumables count .PARAMETER limit Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all @@ -75,7 +120,40 @@ function Get-SnipeitUser() { [parameter(ParameterSetName='Search')] [string]$email, + + [parameter(ParameterSetName='Search')] + [string]$employee_num, + [parameter(ParameterSetName='Search')] + [string]$state, + + [parameter(ParameterSetName='Search')] + [string]$zip, + + [parameter(ParameterSetName='Search')] + [string]$country, + + [parameter(ParameterSetName='Search')] + [Nullable[bool]]$deleted, + + [parameter(ParameterSetName='Search')] + [Nullable[bool]]$ldap_import, + + [parameter(ParameterSetName='Search')] + [Nullable[bool]]$remote, + + [parameter(ParameterSetName='Search')] + [int]$assets_count, + + [parameter(ParameterSetName='Search')] + [int]$licenses_count, + + [parameter(ParameterSetName='Search')] + [int]$accessories_count, + + [parameter(ParameterSetName='Search')] + [int]$consumables_count, + [parameter(ParameterSetName='Search')] [ValidateSet("asc", "desc")] [string]$order = "desc",