mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Add search to all Get commands
This commit is contained in:
parent
57512d50f7
commit
cc72820bde
12 changed files with 66 additions and 7 deletions
|
|
@ -19,6 +19,8 @@ Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_
|
|||
function Get-Asset()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,7 +32,8 @@ function Get-Asset()
|
|||
Uri = "$url/api/v1/hardware"
|
||||
Method = 'Get'
|
||||
GetParameters = @{
|
||||
limit = 9999
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
Token = $apiKey
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ function Get-Category()
|
|||
Uri = "$url/api/v1/categories"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Company -url "https://assets.example.com" -token "token..." | Where-Object {
|
|||
function Get-Company()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Company()
|
|||
Uri = "$url/api/v1/companies"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Component -url "https://assets.example.com" -token "token..." | Where-Object
|
|||
function Get-Component()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Component()
|
|||
Uri = "$url/api/v1/components"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Department -url "https://assets.example.com" -token "token..." | Where-Objec
|
|||
function Get-Department()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Department()
|
|||
Uri = "$url/api/v1/departments"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Location -url "https://assets.example.com" -token "token..." | Where-Object
|
|||
function Get-Location()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Location()
|
|||
Uri = "$url/api/v1/locations"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Manufacturer -url "https://assets.example.com" -token "token..." | Where-Obj
|
|||
function Get-Manufacturer()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Manufacturer()
|
|||
Uri = "$url/api/v1/manufacturers"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Models -url "https://assets.example.com" -token "token..." | Where-Object {$
|
|||
function Get-Model()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Model()
|
|||
Uri = "$url/api/v1/models"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Status -url "https://assets.example.com" -token "token..." | Where-Object {$
|
|||
function Get-Status()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Status()
|
|||
Uri = "$url/api/v1/statuslabels"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Get-Supplier -url "https://assets.example.com" -token "token..." | Where-Object
|
|||
function Get-Supplier()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -30,6 +32,10 @@ function Get-Supplier()
|
|||
Uri = "$url/api/v1/suppliers"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_.
|
|||
function Get-User()
|
||||
{
|
||||
Param(
|
||||
[string]$search,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
|
|
@ -29,6 +31,7 @@ function Get-User()
|
|||
Uri = "$url/api/v1/users"
|
||||
Method = 'Get'
|
||||
GetParameters = @{
|
||||
search = $search
|
||||
limit = 999
|
||||
}
|
||||
Token = $apiKey
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
.PARAMETER userName
|
||||
Parameter description
|
||||
|
||||
.PARAMETER jobTitle
|
||||
.PARAMETER jobtitle
|
||||
Parameter description
|
||||
|
||||
.PARAMETER email
|
||||
|
|
@ -76,7 +76,7 @@ function Set-User() {
|
|||
|
||||
[string]$userName,
|
||||
|
||||
[string]$jobTitle,
|
||||
[string]$jobtitle,
|
||||
|
||||
[string]$email,
|
||||
|
||||
|
|
@ -105,17 +105,18 @@ function Set-User() {
|
|||
|
||||
$Values = @{}
|
||||
|
||||
$exclude = @('id', 'url', 'apiKey')
|
||||
$excludeRegex = [string]::Join('|', $exclude) # create the regex
|
||||
#$exclude = @('id', 'url', 'apiKey')
|
||||
#$excludeRegex = [string]::Join('|', $exclude) # create the regex
|
||||
|
||||
foreach ($psbp in $PSBoundParameters.GetEnumerator()) {
|
||||
if ($psbp.Key -notmatch $excludeRegex) {
|
||||
#if ($psbp.Key -notmatch $excludeRegex) {
|
||||
$Values.Add($psbp.Key, $psbp.Value)
|
||||
}
|
||||
#}
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Body
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$id"
|
||||
Method = 'PATCH'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue