|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | +# Gets a list of Snipe-it Licenses |
| 4 | +
|
| 5 | +.PARAMETER url |
| 6 | +URL of Snipeit system, can be set using Set-Info command |
| 7 | +
|
| 8 | +.PARAMETER apiKey |
| 9 | +Users API Key for Snipeit, can be set using Set-Info command |
| 10 | +
|
| 11 | +.EXAMPLE |
| 12 | +Get-License -url "https://assets.example.com" -token "token..." |
| 13 | +
|
| 14 | +.EXAMPLE |
| 15 | +Get-License -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "License" } |
| 16 | +
|
| 17 | +#> |
| 18 | + |
| 19 | +function Get-License() { |
| 20 | + Param( |
| 21 | + [string]$search, |
| 22 | + |
| 23 | + [string]$name, |
| 24 | + |
| 25 | + [int] $company_id, |
| 26 | + |
| 27 | + [string]$product_key, |
| 28 | + |
| 29 | + [int]$order_number, |
| 30 | + |
| 31 | + [string]$purchase_order, |
| 32 | + |
| 33 | + [string]$license_name, |
| 34 | + |
| 35 | + [string]$license_email, |
| 36 | + |
| 37 | + [int]$manufacturer_id, |
| 38 | + |
| 39 | + [int]$supplier_id, |
| 40 | + |
| 41 | + [int]$depreciation_id, |
| 42 | + |
| 43 | + [ValidateSet("asc", "desc")] |
| 44 | + [string]$order = "desc", |
| 45 | + |
| 46 | + [int]$limit = 50, |
| 47 | + |
| 48 | + [int]$offset, |
| 49 | + |
| 50 | + [parameter(mandatory = $true)] |
| 51 | + [string]$url, |
| 52 | + |
| 53 | + [parameter(mandatory = $true)] |
| 54 | + [string]$apiKey |
| 55 | + ) |
| 56 | + |
| 57 | + $SearchParameter = @{ |
| 58 | + sort = $sort |
| 59 | + order = $order |
| 60 | + limit = $limit |
| 61 | + offset = $offset |
| 62 | + } |
| 63 | + |
| 64 | + if ($PSBoundParameters.ContainsKey('search')) { $SearchParameter.Add("search", $search) } |
| 65 | + if ($PSBoundParameters.ContainsKey('name')) { $SearchParameter.Add("name", $name) } |
| 66 | + if ($PSBoundParameters.ContainsKey('company_id')) { $SearchParameter.Add("company_id", $company_id) } |
| 67 | + if ($PSBoundParameters.ContainsKey('product_key')) { $SearchParameter.Add("product_key", $product_key) } |
| 68 | + if ($PSBoundParameters.ContainsKey('order_number')) { $SearchParameter.Add("order_number", $order_number) } |
| 69 | + if ($PSBoundParameters.ContainsKey('purchase_order')) { $SearchParameter.Add("purchase_order", $purchase_order) } |
| 70 | + if ($PSBoundParameters.ContainsKey('license_name')) { $SearchParameter.Add("license_name", $license_name) } |
| 71 | + if ($PSBoundParameters.ContainsKey('license_email')) { $SearchParameter.Add("license_email", $license_email) } |
| 72 | + if ($PSBoundParameters.ContainsKey('manufacturer_id')) { $SearchParameter.Add("manufacturer_id", $manufacturer_id) } |
| 73 | + if ($PSBoundParameters.ContainsKey('supplier_id')) { $SearchParameter.Add("supplier_id", $supplier_id) } |
| 74 | + if ($PSBoundParameters.ContainsKey('depreciation_id')) { $SearchParameter.Add("depreciation_id", $depreciation_id) } |
| 75 | + |
| 76 | + $Parameters = @{ |
| 77 | + Uri = "$url/api/v1/licenses" |
| 78 | + Method = 'Get' |
| 79 | + Token = $apiKey |
| 80 | + GetParameters = $SearchParameter |
| 81 | + } |
| 82 | + |
| 83 | + $result = Invoke-SnipeitMethod @Parameters |
| 84 | + |
| 85 | + $result |
| 86 | +} |
| 87 | + |
0 commit comments