mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 01:42:29 +00:00
begin, process, end
This commit is contained in:
parent
3446a885dc
commit
923838e15f
37 changed files with 1357 additions and 1201 deletions
|
|
@ -36,18 +36,17 @@ function Invoke-SnipeitMethod {
|
|||
BEGIN {
|
||||
#use legacy per command based url and apikey
|
||||
if ( $null -ne $SnipeitPSSession.legacyUrl -and $null -ne $SnipeitPSSession.legacyApiKey ) {
|
||||
[string]$Url = $SnipeitPSSession.legacyrl
|
||||
[string]$Url = $SnipeitPSSession.legacyUrl
|
||||
Write-Debug "Invoke-SnipeitMethod url: $Url"
|
||||
$Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.legacyApiKey
|
||||
|
||||
throw "Cannot connect to Snipe it. Please run Connect-SnipePS to set connection information."
|
||||
} elseif ($null -ne $SnipeitPSSession.url -and $null -ne $SnipeitPSSession.apiKey) {
|
||||
|
||||
} else {
|
||||
[string]$Url = $SnipeitPSSession.url
|
||||
Write-Debug "Invoke-SnipeitMethod url: $Url"
|
||||
$Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.apiKey
|
||||
|
||||
} else {
|
||||
throw "Please use Connect-SnipeitPS to setup connection before any other commands."
|
||||
}
|
||||
|
||||
# Validation of parameters
|
||||
|
|
@ -57,9 +56,6 @@ function Invoke-SnipeitMethod {
|
|||
Throw $exception
|
||||
}
|
||||
|
||||
# Double check those old deprecated -url parameters
|
||||
$Url = $Url.TrimEnd('/')
|
||||
|
||||
#Build request uri
|
||||
$apiUri = "$Url$Api"
|
||||
#To support images "image" property have be handled before this
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ function Reset-SnipeitPSLegacyApi {
|
|||
param(
|
||||
)
|
||||
process {
|
||||
Write-Verbose 'Reset-SnipeitPSLegacyApi'
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$SnipeitPSSession.legacyUrl = $null
|
||||
$SnipeitPSSession.legacyApiKey = $null
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function Set-SnipeitPSLegacyUrl {
|
|||
)
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$SnipeitPSSession.legacyUrl = $url
|
||||
$SnipeitPSSession.legacyUrl = $url.TrimEnd('/')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ function Connect-SnipeitPS {
|
|||
switch ($PsCmdlet.ParameterSetName) {
|
||||
'Connect with url and apikey' {
|
||||
$SnipeitPSSession.url = $url.TrimEnd('/')
|
||||
$SnipeitPSSession.apiKey = $apiKey | ConvertTo-SecureString -AsPlainText
|
||||
$SnipeitPSSession.apiKey = ConvertTo-SecureString -AsPlainText -String $apiKey
|
||||
}
|
||||
|
||||
'Connect with url and secure apikey' {
|
||||
|
|
|
|||
|
|
@ -85,55 +85,61 @@ function Get-SnipeitAccessory() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
switch($PsCmdlet.ParameterSetName) {
|
||||
'Search' {$api = "/api/v1/accessories"}
|
||||
'Get by ID' {$api= "/api/v1/accessories/$id"}
|
||||
'Accessories checked out to user id' {$api = "/api/v1/users/$user_id/accessories"}
|
||||
}
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAccessory @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
switch($PsCmdlet.ParameterSetName) {
|
||||
'Search' {$api = "/api/v1/accessories"}
|
||||
'Get by ID' {$api= "/api/v1/accessories/$id"}
|
||||
'Accessories checked out to user id' {$api = "/api/v1/users/$user_id/accessories"}
|
||||
}
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAccessory @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,30 +32,33 @@ function Get-SnipeitAccessoryOwner() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/accessories/$id/checkedout"
|
||||
Method = 'GET'
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/accessories/$id/checkedout"
|
||||
Method = 'GET'
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,59 +77,64 @@ function Get-SnipeitActivity() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
if (($target_type -and -not $target_id) -or
|
||||
($target_id -and -not $target_type)) {
|
||||
throw "Please specify both target_type and target_id"
|
||||
}
|
||||
|
||||
if (($item_type -and -not $item_id) -or
|
||||
($item_id -and -not $item_type)) {
|
||||
throw "Please specify both item_type and item_id"
|
||||
}
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/reports/activity"
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitActivity @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
begin {
|
||||
if (($target_type -and -not $target_id) -or
|
||||
($target_id -and -not $target_type)) {
|
||||
throw "Please specify both target_type and target_id"
|
||||
}
|
||||
|
||||
if (($item_type -and -not $item_id) -or
|
||||
($item_id -and -not $item_type)) {
|
||||
throw "Please specify both item_type and item_id"
|
||||
}
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/reports/activity"
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitActivity @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,61 +206,67 @@ function Get-SnipeitAsset() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
switch ($PsCmdlet.ParameterSetName) {
|
||||
'Search' { $api = "/api/v1/hardware" }
|
||||
'Get with id' {$api= "/api/v1/hardware/$id"}
|
||||
'Get with asset tag' {$api= "/api/v1/hardware/bytag/$asset_tag"}
|
||||
'Get with serial' { $api= "/api/v1/hardware/byserial/$serial"}
|
||||
'Assets due auditing soon' {$api = "/api/v1/hardware/audit/due"}
|
||||
'Assets overdue for auditing' {$api = "/api/v1/hardware/audit/overdue"}
|
||||
'Assets checked out to user id'{$api = "/api/v1/users/$user_id/assets"}
|
||||
'Assets with component id' {$api = "/api/v1/components/$component_id/assets"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
Write-Verbose "Callargs: $($callargs | convertto-json)"
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAsset @callargs
|
||||
$res
|
||||
if ( $res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
switch ($PsCmdlet.ParameterSetName) {
|
||||
'Search' { $api = "/api/v1/hardware" }
|
||||
'Get with id' {$api= "/api/v1/hardware/$id"}
|
||||
'Get with asset tag' {$api= "/api/v1/hardware/bytag/$asset_tag"}
|
||||
'Get with serial' { $api= "/api/v1/hardware/byserial/$serial"}
|
||||
'Assets due auditing soon' {$api = "/api/v1/hardware/audit/due"}
|
||||
'Assets overdue for auditing' {$api = "/api/v1/hardware/audit/overdue"}
|
||||
'Assets checked out to user id'{$api = "/api/v1/users/$user_id/assets"}
|
||||
'Assets with component id' {$api = "/api/v1/components/$component_id/assets"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
Write-Verbose "Callargs: $($callargs | convertto-json)"
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAsset @callargs
|
||||
$res
|
||||
if ( $res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,50 +60,55 @@ function Get-SnipeitAssetMaintenance() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/maintenances"
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAssetMaintenance @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/maintenances"
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitAssetMaintenance @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,58 +59,64 @@ function Get-SnipeitCategory() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$api = "/api/v1/categories"
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
$api = "/api/v1/categories"
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/categories/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitCategory @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/categories/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitCategory @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,58 +61,63 @@ function Get-SnipeitCompany() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/companies"
|
||||
$api = "/api/v1/companies"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/companies/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitCompany @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/companies/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitCompany @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,58 +78,64 @@ function Get-SnipeitComponent() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/components"
|
||||
$api = "/api/v1/components"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/components/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitComponent @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/components/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitComponent @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,37 +33,40 @@ function Get-SnipeitCustomField() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/fields/$id"
|
||||
} else {
|
||||
$api = "/api/v1/fields"
|
||||
if ($id) {
|
||||
$api= "/api/v1/fields/$id"
|
||||
} else {
|
||||
$api = "/api/v1/fields"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
process {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,60 +66,65 @@ function Get-SnipeitDepartment() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/departments"
|
||||
$api = "/api/v1/departments"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/departments/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitDepartment @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/departments/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitDepartment @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,36 +31,39 @@ function Get-SnipeitFieldset() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
bagin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
if ($id) {
|
||||
$api = "/api/v1/fieldsets/$id"
|
||||
} else {
|
||||
$api = "/api/v1/fieldsets"
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api = "/api/v1/fieldsets/$id"
|
||||
} else {
|
||||
$api = "/api/v1/fieldsets"
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,57 +104,62 @@ function Get-SnipeitLicense() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
bagin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
switch($PsCmdlet.ParameterSetName) {
|
||||
'Search' {$api = "/api/v1/licenses"}
|
||||
'Get with ID' {$api= "/api/v1/licenses/$id"}
|
||||
'Get licenses checked out to user ID' {$api= "/api/v1/users/$user_id/licenses"}
|
||||
'Get licenses checked out to asset ID' {$api= "/api/v1/hardware/$asset_id/licenses"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLicense @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
switch($PsCmdlet.ParameterSetName) {
|
||||
'Search' {$api = "/api/v1/licenses"}
|
||||
'Get with ID' {$api= "/api/v1/licenses/$id"}
|
||||
'Get licenses checked out to user ID' {$api= "/api/v1/users/$user_id/licenses"}
|
||||
'Get licenses checked out to asset ID' {$api= "/api/v1/hardware/$asset_id/licenses"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLicense @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,57 +53,62 @@ function Get-SnipeitLicenseSeat() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/licenses/$id/seats"
|
||||
$api = "/api/v1/licenses/$id/seats"
|
||||
|
||||
|
||||
if ($seat_id) {
|
||||
$api= "/api/v1/licenses/$id/seats/$seat_id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLicenseSeat @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($seat_id) {
|
||||
$api= "/api/v1/licenses/$id/seats/$seat_id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLicenseSeat @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,60 +59,65 @@ function Get-SnipeitLocation() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$api = "/api/v1/locations"
|
||||
|
||||
$api = "/api/v1/locations"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/locations/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLocation @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/locations/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitLocation @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,59 +60,64 @@ function Get-SnipeitManufacturer() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$api = "/api/v1/manufacturers"
|
||||
|
||||
$api = "/api/v1/manufacturers"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/manufacturers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitManufacturer @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/manufacturers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitManufacturer @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,58 +60,64 @@ function Get-SnipeitModel() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/models"
|
||||
$api = "/api/v1/models"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/models/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitModel @callargs
|
||||
$res
|
||||
if ($res.count -ne $limit ) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/models/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitModel @callargs
|
||||
$res
|
||||
if ($res.count -ne $limit ) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,59 +59,64 @@ function Get-SnipeitStatus() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$api = "/api/v1/statuslabels"
|
||||
|
||||
$api = "/api/v1/statuslabels"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/statuslabels/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitStatus @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/statuslabels/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitStatus @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,59 +59,64 @@ function Get-SnipeitSupplier() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$api = "/api/v1/suppliers"
|
||||
$api = "/api/v1/suppliers"
|
||||
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/suppliers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitSupplier @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
if ($search -and $id ) {
|
||||
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$api= "/api/v1/suppliers/$id"
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitSupplier @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,53 +97,58 @@ function Get-SnipeitUser() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
switch ($PsCmdlet.ParameterSetName) {
|
||||
'Search' { $api = "/api/v1/users"}
|
||||
'Get with id' {$api= "/api/v1/users/$id"}
|
||||
'Get users a specific accessory id has been checked out to' {$api= "/api/v1/accessories/$accessory_id/checkedout"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitUser @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
switch ($PsCmdlet.ParameterSetName) {
|
||||
'Search' { $api = "/api/v1/users"}
|
||||
'Get with id' {$api= "/api/v1/users/$id"}
|
||||
'Get users a specific accessory id has been checked out to' {$api= "/api/v1/accessories/$accessory_id/checkedout"}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = $api
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($all) {
|
||||
$offstart = $(if ($offset) {$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeitUser @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,40 +115,44 @@ function New-SnipeitAccessory() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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")
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/accessories"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/accessories"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,55 +144,61 @@ function New-SnipeitAsset() {
|
|||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
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 ($customfields) {
|
||||
$Values += $customfields
|
||||
}
|
||||
|
||||
#Checkout asset when creating it
|
||||
if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') {
|
||||
switch ($checkout_to_type) {
|
||||
'location' { $Values += @{ "assigned_location" = $assigned_id } }
|
||||
'user' { $Values += @{ "assigned_user" = $assigned_id } }
|
||||
'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
|
||||
if ($values['purchase_date']) {
|
||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
#This are not needed for API
|
||||
if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')}
|
||||
if ($Values.ContainsKey('checkout_to_type')) {$Values.Remove('checkout_to_type')}
|
||||
if ($customfields) {
|
||||
$Values += $customfields
|
||||
}
|
||||
|
||||
#Checkout asset when creating it
|
||||
if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') {
|
||||
switch ($checkout_to_type) {
|
||||
'location' { $Values += @{ "assigned_location" = $assigned_id } }
|
||||
'user' { $Values += @{ "assigned_user" = $assigned_id } }
|
||||
'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
|
||||
}
|
||||
|
||||
#This are not needed for API
|
||||
if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')}
|
||||
if ($Values.ContainsKey('checkout_to_type')) {$Values.Remove('checkout_to_type')}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/hardware"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/hardware"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,44 +76,49 @@ function New-SnipeitAssetMaintenance() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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['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")
|
||||
}
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/maintenances"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($Values['completion_date']) {
|
||||
$Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd")
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/maintenances"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,41 +35,46 @@ function New-SnipeitAudit() {
|
|||
[string]$apiKey
|
||||
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
$Values = @{
|
||||
"location_id" = $location_id
|
||||
}
|
||||
|
||||
$Values = @{
|
||||
"location_id" = $location_id
|
||||
if ($PSBoundParameters.ContainsKey('tag')) {
|
||||
$Values += @{"asset_tag" = $tag}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/hardware/audit"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('tag')) {
|
||||
$Values += @{"asset_tag" = $tag}
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/hardware/audit"
|
||||
Method = 'Post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,36 +41,41 @@ function New-SnipeitCompany() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/companies"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/companies"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,40 +76,45 @@ function New-SnipeitComponent() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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")
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/components"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/components"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,9 +122,7 @@ function New-SnipeitConsumable() {
|
|||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/consumables"
|
||||
Method = 'Post'
|
||||
|
|
@ -140,7 +138,9 @@ function New-SnipeitConsumable() {
|
|||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,36 +60,41 @@ function New-SnipeitDepartment() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/departments"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/departments"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,48 +123,52 @@ function New-SnipeitLicense() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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['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['termination_date']) {
|
||||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/licenses"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($Values['purchase_date']) {
|
||||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($Values['termination_date']) {
|
||||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/licenses"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,34 +93,40 @@ function New-SnipeitLocation() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
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
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/locations"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/locations"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,36 +46,40 @@ function New-SnipeitManufacturer() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/manufacturers"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/manufacturers"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,43 +66,49 @@ function New-SnipeitModel() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
name = $name
|
||||
category_id = $category_id
|
||||
manufacturer_id = $manufacturer_id
|
||||
fieldset_id = $fieldset_id
|
||||
$Values = @{
|
||||
name = $name
|
||||
category_id = $category_id
|
||||
manufacturer_id = $manufacturer_id
|
||||
fieldset_id = $fieldset_id
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
|
||||
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/models"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
|
||||
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/models"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,36 +96,41 @@ function New-SnipeitSupplier() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/suppilers"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/suppilers"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,39 +116,44 @@ function New-SnipeitUser() {
|
|||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
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 ($password ) {
|
||||
$Values['password_confirmation'] = $password
|
||||
}
|
||||
|
||||
if ($password ) {
|
||||
$Values['password_confirmation'] = $password
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/users"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/users"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url')) {
|
||||
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue