mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-14 02:12:29 +00:00
Merge pull request #136 from PetriAsi/feature/pipelineinput
Pipeline support for Set functions
This commit is contained in:
commit
d4c138604d
12 changed files with 259 additions and 195 deletions
|
|
@ -79,10 +79,10 @@ function Get-SnipeItAsset() {
|
||||||
[int]$id,
|
[int]$id,
|
||||||
|
|
||||||
[string]$asset_tag,
|
[string]$asset_tag,
|
||||||
|
[Alias('asset_serial')]
|
||||||
|
[string]$serial,
|
||||||
|
|
||||||
[string]$asset_serial,
|
[string]$order_number,
|
||||||
|
|
||||||
[int]$order_number,
|
|
||||||
|
|
||||||
[int]$model_id,
|
[int]$model_id,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ function Get-SnipeItLicense() {
|
||||||
|
|
||||||
[string]$product_key,
|
[string]$product_key,
|
||||||
|
|
||||||
[int]$order_number,
|
[string]$order_number,
|
||||||
|
|
||||||
[string]$purchase_order,
|
[string]$purchase_order,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ Creates new accessory on Snipe-It system
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
Accessory name
|
Accessory name
|
||||||
|
|
||||||
|
.PARAMETER notes
|
||||||
|
Notes about the accessory
|
||||||
|
|
||||||
.PARAMETER qty
|
.PARAMETER qty
|
||||||
Quantity of the accessory you have
|
Quantity of the accessory you have
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ Updates accessory on Snipe-It system
|
||||||
Updates accessory on Snipe-It system
|
Updates accessory on Snipe-It system
|
||||||
|
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
ID number of Accessory on Snipe-It system
|
ID number of Accessory or array of IDs on Snipe-It system
|
||||||
|
|
||||||
|
.PARAMETER notes
|
||||||
|
Notes about the accessory
|
||||||
|
|
||||||
.PARAMETER qty
|
.PARAMETER qty
|
||||||
Quantity of the accessory you have
|
Quantity of the accessory you have
|
||||||
|
|
@ -64,8 +67,8 @@ function Set-SnipeItAccessory() {
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[ValidateLength(3, 255)]
|
[ValidateLength(3, 255)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
@ -81,6 +84,7 @@ function Set-SnipeItAccessory() {
|
||||||
[ValidateRange(1, [int]::MaxValue)]
|
[ValidateRange(1, [int]::MaxValue)]
|
||||||
[int]$manufacturer_id,
|
[int]$manufacturer_id,
|
||||||
|
|
||||||
|
[AllowEmptyString]
|
||||||
[string]$order_number,
|
[string]$order_number,
|
||||||
|
|
||||||
[float]$purchase_cost,
|
[float]$purchase_cost,
|
||||||
|
|
@ -99,6 +103,7 @@ function Set-SnipeItAccessory() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
@ -108,10 +113,13 @@ function Set-SnipeItAccessory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach($accessory_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/accessories/$id"
|
Uri = "$url/api/v1/accessories/$accessory_id"
|
||||||
Method = 'POST'
|
Method = 'Patch'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
}
|
}
|
||||||
|
|
@ -121,5 +129,7 @@ function Set-SnipeItAccessory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
Checkout accessory to user
|
Checkout accessory to user
|
||||||
|
|
||||||
.PARAMETER id
|
.PARAMETER id
|
||||||
Unique ID For accessory to checkout
|
Unique ID For accessory or array of IDs to checkout
|
||||||
|
|
||||||
.PARAMETER assigned_id
|
.PARAMETER assigned_id
|
||||||
Id of target user
|
Id of target user
|
||||||
|
|
@ -30,8 +30,8 @@ function Set-SnipeItAccessoryOwner()
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$assigned_to,
|
[int]$assigned_to,
|
||||||
|
|
@ -44,13 +44,16 @@ function Set-SnipeItAccessoryOwner()
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
begin{
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach($accessory_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/accessories/$id/checkout"
|
Uri = "$url/api/v1/accessories/$accessory_id/checkout"
|
||||||
Method = 'POST'
|
Method = 'POST'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -62,4 +65,6 @@ function Set-SnipeItAccessoryOwner()
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result
|
return $result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
Long description
|
Long description
|
||||||
|
|
||||||
.PARAMETER id
|
.PARAMETER id
|
||||||
ID of the Asset
|
ID of the Asset or array of IDs
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
Asset name
|
Asset name
|
||||||
|
|
@ -70,6 +70,9 @@
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Set-SnipeItAsset -id 1 -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
Set-SnipeItAsset -id 1 -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-SnipeItAsset -serial 12345678 | Set-SnipeItAsset -notes 'Just updated'
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function Set-SnipeItAsset()
|
function Set-SnipeItAsset()
|
||||||
|
|
@ -80,8 +83,8 @@ function Set-SnipeItAsset()
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
|
|
@ -124,7 +127,7 @@ function Set-SnipeItAsset()
|
||||||
|
|
||||||
[hashtable] $customfields
|
[hashtable] $customfields
|
||||||
)
|
)
|
||||||
|
begin{
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
@ -139,9 +142,12 @@ function Set-SnipeItAsset()
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach($asset_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/hardware/$id"
|
Uri = "$url/api/v1/hardware/$asset_id"
|
||||||
Method = $RequestType
|
Method = $RequestType
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -153,4 +159,6 @@ function Set-SnipeItAsset()
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
Checkout asset to user/localtion/asset
|
Checkout asset to user/localtion/asset
|
||||||
|
|
||||||
.PARAMETER ID
|
.PARAMETER ID
|
||||||
Unique ID For asset to checkout
|
Unique IDs For assets to checkout
|
||||||
|
|
||||||
.PARAMETER assigned_id
|
.PARAMETER assigned_id
|
||||||
Id of target user , location or asset
|
Id of target user , location or asset
|
||||||
|
|
@ -41,8 +41,8 @@ function Set-SnipeItAssetOwner()
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$assigned_id,
|
[int]$assigned_id,
|
||||||
|
|
@ -65,6 +65,7 @@ function Set-SnipeItAssetOwner()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin{
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
@ -89,8 +90,12 @@ function Set-SnipeItAssetOwner()
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach($asset_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/hardware/$id/checkout"
|
Uri = "$url/api/v1/hardware/$asset_id/checkout"
|
||||||
Method = 'POST'
|
Method = 'POST'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -102,4 +107,6 @@ function Set-SnipeItAssetOwner()
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result
|
return $result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
Updates licence on Snipe-It system
|
Updates licence on Snipe-It system
|
||||||
|
|
||||||
.PARAMETER id
|
.PARAMETER id
|
||||||
ID number of licence
|
ID number of license or array of license IDs
|
||||||
|
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
Name of license
|
Name of license
|
||||||
|
|
@ -77,8 +77,8 @@ function Set-SnipeItLicense() {
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true, ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[ValidateLength(3, 255)]
|
[ValidateLength(3, 255)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
@ -128,7 +128,7 @@ function Set-SnipeItLicense() {
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
begin{
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
@ -146,9 +146,11 @@ function Set-SnipeItLicense() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
process {
|
||||||
|
foreach($license_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/licenses/$id"
|
Uri = "$url/api/v1/licenses/$license_id"
|
||||||
Method = 'PUT'
|
Method = 'PUT'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -159,5 +161,6 @@ function Set-SnipeItLicense() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
Checkout specific license seat to user, asset or both
|
Checkout specific license seat to user, asset or both
|
||||||
|
|
||||||
.PARAMETER ID
|
.PARAMETER ID
|
||||||
Unique ID For asset to checkout
|
Unique ID For license to checkout or array of IDs
|
||||||
|
|
||||||
.PARAMETER assigned_to
|
.PARAMETER assigned_to
|
||||||
Id of target user
|
Id of target user
|
||||||
|
|
@ -40,7 +40,7 @@ function Set-SnipeItLicenseSeat()
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$seat_id,
|
[int]$seat_id,
|
||||||
|
|
@ -58,12 +58,16 @@ function Set-SnipeItLicenseSeat()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin{
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach($license_id in $id) {
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/licenses/$id/seats/$seat_id"
|
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
|
||||||
Method = 'Patch'
|
Method = 'Patch'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -75,4 +79,6 @@ function Set-SnipeItLicenseSeat()
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result
|
return $result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Long description
|
Long description
|
||||||
|
|
||||||
|
.PARAMETER id
|
||||||
|
ID number of location or array or IDs
|
||||||
|
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
Name of Location
|
Name of Location
|
||||||
|
|
||||||
|
|
@ -59,8 +62,8 @@ function Set-SnipeitLocation() {
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[ValidateLength(3, 255)]
|
[ValidateLength(3, 255)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
@ -92,14 +95,18 @@ function Set-SnipeitLocation() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin{
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach ($location_id in $id) {
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/locations/$id"
|
Uri = "$url/api/v1/locations/$location_id"
|
||||||
Method = 'PUT'
|
Method = 'PUT'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -110,5 +117,7 @@ function Set-SnipeitLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
Updates Model on Snipe-it asset system
|
Updates Model on Snipe-it asset system
|
||||||
|
|
||||||
.PARAMETER id
|
.PARAMETER id
|
||||||
ID number of the Asset Model
|
ID number of the Asset Model or array of IDs
|
||||||
|
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
Name of the Asset Model
|
Name of the Asset Model
|
||||||
|
|
@ -40,8 +40,8 @@ function Set-SnipeItModel() {
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[ValidateLength(1, 255)]
|
[ValidateLength(1, 255)]
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
@ -66,14 +66,17 @@ function Set-SnipeItModel() {
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
process {
|
||||||
|
foreach ($model_id in $id) {
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/models/$id"
|
Uri = "$url/api/v1/models/$model_id"
|
||||||
Method = 'put'
|
Method = 'put'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -84,4 +87,6 @@ function Set-SnipeItModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates a new user
|
Creates a new user
|
||||||
|
|
||||||
|
.PARAMETER id
|
||||||
|
ID number of Snipe--It user or array of IDs
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new user to Snipe-IT system
|
Creates a new user to Snipe-IT system
|
||||||
|
|
||||||
|
|
@ -68,8 +71,8 @@ function Set-SnipeItUser() {
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[string]$first_name,
|
[string]$first_name,
|
||||||
|
|
||||||
|
|
@ -103,15 +106,18 @@ function Set-SnipeItUser() {
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
begin{
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach($user_id in $id) {
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/users/$id"
|
Uri = "$url/api/v1/users/$user_id"
|
||||||
Method = 'PATCH'
|
Method = 'PATCH'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
|
@ -122,4 +128,6 @@ function Set-SnipeItUser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue