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