mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Do converto-json later in invoke-snipeitmethod function
This commit is contained in:
parent
28a6ffd05f
commit
2850b82a16
49 changed files with 80 additions and 136 deletions
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
# Body of the request
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Body,
|
||||
[Hashtable]$Body,
|
||||
|
||||
[string] $Token,
|
||||
|
||||
|
|
@ -34,6 +34,9 @@
|
|||
Throw $exception
|
||||
}
|
||||
|
||||
#To support images "image" property have be handled before this
|
||||
$Body = $Body | ConvertTo-Json
|
||||
|
||||
$_headers = @{
|
||||
"Authorization" = "Bearer $($token)"
|
||||
'Content-Type' = 'application/json; charset=utf-8'
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ function Get-SnipeitAsset() {
|
|||
'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"}
|
||||
}
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
|
|
|
|||
|
|
@ -113,12 +113,10 @@ function New-SnipeitAccessory() {
|
|||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,12 +137,10 @@ function New-SnipeitAsset()
|
|||
$Values += $customfields
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware"
|
||||
Method = 'Post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,20 +81,19 @@ function New-SnipeitAssetMaintenance() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['start_date']) {
|
||||
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['start_date']) {
|
||||
$Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($values['completion_date']) {
|
||||
$values['completion_date'] = $values['completion_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['completion_date']) {
|
||||
$Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/maintenances"
|
||||
Method = 'Post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,10 @@ function New-SnipeitAudit()
|
|||
$Values += @{"asset_tag" = $tag}
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/audit"
|
||||
Method = 'Post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ function New-SnipeitCategory()
|
|||
}
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -77,7 +75,7 @@ function New-SnipeitCategory()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,10 @@ function New-SnipeitCompany()
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/companies"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,16 +76,14 @@ function New-SnipeitComponent() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,18 +114,16 @@ function New-SnipeitConsumable()
|
|||
begin {
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/consumables"
|
||||
Method = 'Post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,12 +83,10 @@ function New-SnipeitCustomField()
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/fields"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,10 @@ function New-SnipeitDepartment() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/departments"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,24 +128,22 @@ function New-SnipeitLicense() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['expiration_date']) {
|
||||
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['expiration_date']) {
|
||||
$Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($values['termination_date']) {
|
||||
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['termination_date']) {
|
||||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,12 +89,10 @@ function New-SnipeitLocation() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,10 @@ function New-SnipeitManufacturer()
|
|||
"name" = $Name
|
||||
}
|
||||
|
||||
#Convert Values to JSON format
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,12 +73,11 @@ function New-SnipeitModel()
|
|||
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
|
||||
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,12 +117,10 @@ function New-SnipeitUser() {
|
|||
$Values['password_confirmation'] = $password
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitAccessory ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$accessory_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = @{}
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function Remove-SnipeitAsset ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$asset_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function Remove-SnipeitAssetMaintenance {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/maintenances/$maintenance_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitCategory ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories/$category_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitCompany ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/companies/$company_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitComponent ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function Remove-SnipeitConsumable ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/consumables/$consumable_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitCustomField ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/fields/$field_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitDepartment ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/departments/$department_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitLicense ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitLocation ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations/$asset_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitManufacturer ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers/$manufacturer_id_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitModel ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models/$model_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function Remove-SnipeitUser ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$user_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Body = '@{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function Reset-SnipeitAccessoryOwner()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
|
||||
Method = 'Post'
|
||||
Body = '{}'
|
||||
Body = @{}
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,12 +57,10 @@ function Reset-SnipeitAssetOwner() {
|
|||
if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) }
|
||||
if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) }
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$id/checkin"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,12 +108,10 @@ function Set-SnipeitAccessory() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
Write-Verbose "Body: $Body"
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -121,7 +119,7 @@ function Set-SnipeitAccessory() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$accessory_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ function Set-SnipeitAccessoryOwner()
|
|||
)
|
||||
begin{
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -55,7 +53,7 @@ function Set-SnipeitAccessoryOwner()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$accessory_id/checkout"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ function Set-SnipeitAsset()
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($customfields)
|
||||
|
|
@ -143,7 +143,6 @@ function Set-SnipeitAsset()
|
|||
$Values += $customfields
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -151,7 +150,7 @@ function Set-SnipeitAsset()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$asset_id"
|
||||
Method = $RequestType
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ function Set-SnipeitAssetOwner()
|
|||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($Values['expected_checkin']) {
|
||||
$Values['expected_checkin'] = $values['expected_checkin'].ToString("yyyy-MM-dd")
|
||||
$Values['expected_checkin'] = $Values['expected_checkin'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($Values['checkout_at']) {
|
||||
$Values['checkout_at'] = $values['checkout_at'].ToString("yyyy-MM-dd")
|
||||
$Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
switch ($checkout_to_type)
|
||||
|
|
@ -88,8 +88,6 @@ function Set-SnipeitAssetOwner()
|
|||
#This can be removed now
|
||||
if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -97,7 +95,7 @@ function Set-SnipeitAssetOwner()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$asset_id/checkout"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ function Set-SnipeitCategory()
|
|||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -75,7 +73,7 @@ function Set-SnipeitCategory()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories/$category_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,7 @@ function Set-SnipeitCompany()
|
|||
)
|
||||
|
||||
begin{
|
||||
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $values | ConvertTo-Json;
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -55,7 +53,7 @@ function Set-SnipeitCompany()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/companies/$company_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,13 +77,11 @@ function Set-SnipeitComponent()
|
|||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -91,7 +89,7 @@ function Set-SnipeitComponent()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ function Set-SnipeitConsumable()
|
|||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -132,7 +131,7 @@ function Set-SnipeitConsumable()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/consumables/$consumable_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,6 @@ function Set-SnipeitCustomField()
|
|||
}
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -92,7 +89,7 @@ function Set-SnipeitCustomField()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/fields/$field_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ function Set-SnipeitDepartment() {
|
|||
begin {
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -70,7 +68,7 @@ function Set-SnipeitDepartment() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/departments/$department_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,19 +135,18 @@ function Set-SnipeitLicense() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($values['expiration_date']) {
|
||||
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['expiration_date']) {
|
||||
$Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($values['termination_date']) {
|
||||
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
|
||||
if ($Values['termination_date']) {
|
||||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -155,7 +154,7 @@ function Set-SnipeitLicense() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id"
|
||||
Method = 'PUT'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ function Set-SnipeitLicenseSeat()
|
|||
|
||||
begin{
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -70,7 +68,7 @@ function Set-SnipeitLicenseSeat()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,6 @@ function Set-SnipeitLocation() {
|
|||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -108,7 +106,7 @@ function Set-SnipeitLocation() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations/$location_id"
|
||||
Method = 'PUT'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,14 +70,13 @@ function Set-SnipeitModel() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
process {
|
||||
foreach ($model_id in $id) {
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models/$model_id"
|
||||
Method = 'put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ function Set-SnipeitStatus()
|
|||
|
||||
begin {
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$Body = $Values | ConvertTo-Json
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -70,7 +69,7 @@ function Set-SnipeitStatus()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/statuslabels/$status_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ function Set-SnipeitUser() {
|
|||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -119,7 +118,7 @@ function Set-SnipeitUser() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$user_id"
|
||||
Method = 'PATCH'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue