Skip to content

Commit d14244d

Browse files
authored
Merge pull request #283 from snazy2000/develop
Merge Develop Support for more search fields and updated documentation @mattcarras
2 parents 7582b0f + fadfa2d commit d14244d

12 files changed

+289
-3
lines changed

SnipeitPS/Public/Get-SnipeitAccessory.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,24 @@ Gets a list of Snipe-it Accessories
88
.PARAMETER search
99
A text string to search the Accessory data
1010
11+
.PARAMETER user_id
12+
Return Accessories checked out to user id
13+
1114
.PARAMETER id
1215
A id of specific Accessory
1316
17+
.PARAMETER company_id
18+
Optionally restrict Accessory results to this company_id field
19+
20+
.PARAMETER category_id
21+
Optionally restrict Accessory results to this category_id field
22+
23+
.PARAMETER manufacturer_id
24+
Optionally restrict Accessory results to this manufacturer_id field
25+
26+
.PARAMETER supplier_id
27+
Optionally restrict Accessory results to this supplier_id field
28+
1429
.PARAMETER limit
1530
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1631

SnipeitPS/Public/Get-SnipeitAsset.ps1

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@ Retrieve a list of assets that are due for auditing soon.
2020
.PARAMETER audit_overdue
2121
Retrieve a list of assets that are overdue for auditing.
2222
23+
.PARAMETER user_id
24+
Retrieve a list of assets checked out to user id.
25+
26+
.PARAMETER component_id
27+
Retrieve a list of assets assigned this component id.
28+
29+
.PARAMETER name
30+
Optionally restrict asset results to this asset name
31+
2332
.PARAMETER order_number
2433
Optionally restrict asset results to this order number
2534
2635
.PARAMETER model_id
2736
Optionally restrict asset results to this asset model ID
28-
37+
2938
.PARAMETER category_id
3039
Optionally restrict asset results to this category ID
3140
@@ -38,12 +47,22 @@ Optionally restrict asset results to this company ID
3847
.PARAMETER location_id
3948
Optionally restrict asset results to this location ID
4049
50+
.PARAMETER depreciation_id
51+
Optionally restrict asset results to this depreciation ID
52+
53+
.PARAMETER requestable
54+
Optionally restrict asset results to those set as requestable
55+
4156
.PARAMETER status
4257
Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable
4358
4459
.PARAMETER status_id
4560
Optionally restrict asset results to this status label ID
4661
62+
.PARAMETER customfields
63+
Hastable of custom fields and extra fields for searching assets in Snipe-It.
64+
Use internal field names from Snipe-It. You can use Get-CustomField to get internal field names.
65+
4766
.PARAMETER sort
4867
Specify the column name you wish to sort by
4968
@@ -132,6 +151,9 @@ function Get-SnipeitAsset() {
132151
[parameter(ParameterSetName='Assets with component id')]
133152
[int]$component_id,
134153

154+
[parameter(ParameterSetName='Search')]
155+
[string]$name,
156+
135157
[parameter(ParameterSetName='Search')]
136158
[string]$order_number,
137159

@@ -162,6 +184,9 @@ function Get-SnipeitAsset() {
162184
[parameter(ParameterSetName='Search')]
163185
[int]$status_id,
164186

187+
[parameter(ParameterSetName='Search')]
188+
[hashtable]$customfields,
189+
165190
[parameter(ParameterSetName='Search')]
166191
[parameter(ParameterSetName='Assets due auditing soon')]
167192
[parameter(ParameterSetName='Assets overdue for auditing')]
@@ -211,6 +236,15 @@ function Get-SnipeitAsset() {
211236

212237
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
213238

239+
# Add in custom fields.
240+
if ($customfields.Count -gt 0) {
241+
foreach ($pair in $customfields.GetEnumerator()) {
242+
if (-Not $SearchParameter.ContainsKey($pair.Name)) {
243+
$SearchParameter.Add($pair.Name, $pair.Value)
244+
}
245+
}
246+
}
247+
214248
switch ($PsCmdlet.ParameterSetName) {
215249
'Search' { $api = "/api/v1/hardware" }
216250
'Get with id' {$api= "/api/v1/hardware/$id"}

SnipeitPS/Public/Get-SnipeitCategory.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ A text string to search the Categories data
88
.PARAMETER id
99
A id of specific Category
1010
11+
.PARAMETER name
12+
Optionally restrict Category results to this Category name.
13+
1114
.PARAMETER limit
1215
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1316
@@ -40,6 +43,9 @@ function Get-SnipeitCategory() {
4043
[parameter(ParameterSetName='Get with ID')]
4144
[int]$id,
4245

46+
[parameter(ParameterSetName='Search')]
47+
[string]$name,
48+
4349
[parameter(ParameterSetName='Search')]
4450
[ValidateSet("asc", "desc")]
4551
[string]$order = "desc",

SnipeitPS/Public/Get-SnipeitCompany.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ A text string to search the Companies data
88
.PARAMETER id
99
A id of specific Company
1010
11+
.PARAMETER name
12+
Optionally restrict company results to this company name.
13+
1114
.PARAMETER limit
1215
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1316
@@ -41,6 +44,9 @@ function Get-SnipeitCompany() {
4144
[parameter(ParameterSetName='Get with ID')]
4245
[int]$id,
4346

47+
[parameter(ParameterSetName='Search')]
48+
[string]$name,
49+
4450
[parameter(ParameterSetName='Search')]
4551
[ValidateSet("asc", "desc")]
4652
[string]$order = "desc",

SnipeitPS/Public/Get-SnipeitComponent.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ A text string to search the Components data
88
.PARAMETER id
99
A id of specific Component
1010
11+
.PARAMETER name
12+
Optionally restrict Component results to this name field
13+
14+
.PARAMETER company_id
15+
Optionally restrict Component results to this company_id field
16+
17+
.PARAMETER category_id
18+
Optionally restrict Component results to this category_id field
19+
20+
.PARAMETER location_id
21+
Optionally restrict Component results to this location_id field
22+
1123
.PARAMETER limit
1224
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1325
@@ -45,6 +57,9 @@ function Get-SnipeitComponent() {
4557
[parameter(ParameterSetName='Get with ID')]
4658
[int]$id,
4759

60+
[parameter(ParameterSetName='Search')]
61+
[string]$name,
62+
4863
[parameter(ParameterSetName='Search')]
4964
[int]$category_id,
5065

SnipeitPS/Public/Get-SnipeitConsumable.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ A text string to search the consumables
88
.PARAMETER id
99
A id of specific consumable
1010
11+
.PARAMETER name
12+
Optionally restrict consumable results to this name field
13+
1114
.PARAMETER company_id
1215
Id number of company
1316
@@ -63,6 +66,9 @@ function Get-SnipeitConsumable() {
6366
[parameter(ParameterSetName='Get with ID')]
6467
[int[]]$id,
6568

69+
[parameter(ParameterSetName='Search')]
70+
[string]$name,
71+
6672
[parameter(ParameterSetName='Search')]
6773
[int]$category_id,
6874

SnipeitPS/Public/Get-SnipeitDepartment.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ A text string to search the Departments data
88
.PARAMETER id
99
A id of specific Department
1010
11+
.PARAMETER name
12+
Optionally restrict department results to this department name.
13+
14+
.PARAMETER manager_id
15+
Optionally restrict department results to this manager ID.
16+
17+
.PARAMETER company_id
18+
Optionally restrict department results to this company ID.
19+
20+
.PARAMETER location_id
21+
Optionally restrict department results to this location ID.
22+
1123
.PARAMETER limit
1224
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1325
@@ -43,6 +55,18 @@ function Get-SnipeitDepartment() {
4355
[parameter(ParameterSetName='Get with ID')]
4456
[int]$id,
4557

58+
[parameter(ParameterSetName='Search')]
59+
[string]$name,
60+
61+
[parameter(ParameterSetName='Search')]
62+
[int]$manager_id,
63+
64+
[parameter(ParameterSetName='Search')]
65+
[int]$company_id,
66+
67+
[parameter(ParameterSetName='Search')]
68+
[int]$location_id,
69+
4670
[parameter(ParameterSetName='Search')]
4771
[ValidateSet("asc", "desc")]
4872
[string]$order = "desc",

SnipeitPS/Public/Get-SnipeitLocation.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ A text string to search the Locations data
88
.PARAMETER id
99
A id of specific Location
1010
11+
.PARAMETER name
12+
Optionally restrict Location results to this Location name.
13+
14+
.PARAMETER address
15+
Optionally restrict Location results to this Location address.
16+
17+
.PARAMETER address2
18+
Optionally restrict Location results to this Location address2.
19+
20+
.PARAMETER city
21+
Optionally restrict Location results to this Location city.
22+
23+
.PARAMETER zip
24+
Optionally restrict Location results to this Location zip.
25+
26+
.PARAMETER country
27+
Optionally restrict Location results to this Location country.
28+
1129
.PARAMETER limit
1230
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1331
@@ -40,6 +58,24 @@ function Get-SnipeitLocation() {
4058
[parameter(ParameterSetName='Get with ID')]
4159
[int]$id,
4260

61+
[parameter(ParameterSetName='Search')]
62+
[string]$name,
63+
64+
[parameter(ParameterSetName='Search')]
65+
[string]$address,
66+
67+
[parameter(ParameterSetName='Search')]
68+
[string]$address2,
69+
70+
[parameter(ParameterSetName='Search')]
71+
[string]$city,
72+
73+
[parameter(ParameterSetName='Search')]
74+
[string]$zip,
75+
76+
[parameter(ParameterSetName='Search')]
77+
[string]$country,
78+
4379
[parameter(ParameterSetName='Search')]
4480
[ValidateSet("asc", "desc")]
4581
[string]$order = "desc",

SnipeitPS/Public/Get-SnipeitManufacturer.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
.PARAMETER id
99
A id of specific Manufactuter
1010
11+
.PARAMETER name
12+
Optionally restrict Manufacturer results to this name field
13+
1114
.PARAMETER limit
1215
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1316
@@ -41,6 +44,9 @@ function Get-SnipeitManufacturer() {
4144
[parameter(ParameterSetName='Get with ID')]
4245
[int]$id,
4346

47+
[parameter(ParameterSetName='Search')]
48+
[string]$name,
49+
4450
[parameter(ParameterSetName='Search')]
4551
[ValidateSet("asc", "desc")]
4652
[string]$order = "desc",

SnipeitPS/Public/Get-SnipeitStatus.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ A text string to search the Status Labels data
88
.PARAMETER id
99
A id of specific Status Label
1010
11+
.PARAMETER name
12+
Optionally restrict Status Label results to this name field
13+
1114
.PARAMETER limit
1215
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
1316
@@ -40,6 +43,9 @@ function Get-SnipeitStatus() {
4043
[parameter(ParameterSetName='Get with ID')]
4144
[int]$id,
4245

46+
[parameter(ParameterSetName='Search')]
47+
[string]$name,
48+
4349
[parameter(ParameterSetName='Search')]
4450
[ValidateSet("asc", "desc")]
4551
[string]$order = "desc",

0 commit comments

Comments
 (0)