Use new connect method

This commit is contained in:
Petri Asikainen 2021-08-02 08:14:38 +03:00
parent 0afd33368b
commit ed080618a7
73 changed files with 1237 additions and 686 deletions

View file

@ -21,10 +21,10 @@ Result offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitAccessory -search Keyboard Get-SnipeitAccessory -search Keyboard
@ -88,22 +88,31 @@ function Get-SnipeitAccessory() {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
switch($PsCmdlet.ParameterSetName) { switch($PsCmdlet.ParameterSetName) {
'Search' {$apiurl = "$url/api/v1/accessories"} 'Search' {$api = "/api/v1/accessories"}
'Get by ID' {$apiurl= "$url/api/v1/accessories/$id"} 'Get by ID' {$api= "/api/v1/accessories/$id"}
'Accessories checked out to user id' {$apiurl = "$url/api/v1/users/$user_id/accessories"} 'Accessories checked out to user id' {$api = "/api/v1/users/$user_id/accessories"}
} }
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
GetParameters = $SearchParameter GetParameters = $SearchParameter
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -8,16 +8,15 @@
Unique ID For accessory to list Unique ID For accessory to list
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitAccessoryOwner -id 1 Get-SnipeitAccessoryOwner -id 1
#> #>
function Get-SnipeitAccessoryOwner() function Get-SnipeitAccessoryOwner() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -35,13 +34,21 @@ function Get-SnipeitAccessoryOwner()
) )
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$id/checkedout" Api = "/api/v1/accessories/$id/checkedout"
Method = 'GET' Method = 'GET'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -30,10 +30,10 @@ Result offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitAccessory -search Keyboard Get-SnipeitAccessory -search Keyboard
@ -78,12 +78,12 @@ function Get-SnipeitActivity() {
[string]$apiKey [string]$apiKey
) )
if(($target_type -and -not $target_id) -or if (($target_type -and -not $target_id) -or
($target_id -and -not $target_type)) { ($target_id -and -not $target_type)) {
throw "Please specify both target_type and target_id" throw "Please specify both target_type and target_id"
} }
if(($item_type -and -not $item_id) -or if (($item_type -and -not $item_id) -or
($item_id -and -not $item_type)) { ($item_id -and -not $item_type)) {
throw "Please specify both item_type and item_id" throw "Please specify both item_type and item_id"
} }
@ -92,14 +92,23 @@ function Get-SnipeitActivity() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/reports/activity" Api = "/api/v1/reports/activity"
Method = 'Get' Method = 'Get'
GetParameters = $SearchParameter GetParameters = $SearchParameter
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -60,13 +60,13 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..." Get-SnipeitAsset -all
Returens all assets Returens all assets
.EXAMPLE .EXAMPLE
@ -211,25 +211,34 @@ function Get-SnipeitAsset() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
switch ($PsCmdlet.ParameterSetName) { switch ($PsCmdlet.ParameterSetName) {
'Search' { $apiurl = "$url/api/v1/hardware" } 'Search' { $api = "/api/v1/hardware" }
'Get with id' {$apiurl= "$url/api/v1/hardware/$id"} 'Get with id' {$api= "/api/v1/hardware/$id"}
'Get with asset tag' {$apiurl= "$url/api/v1/hardware/bytag/$asset_tag"} 'Get with asset tag' {$api= "/api/v1/hardware/bytag/$asset_tag"}
'Get with serial' { $apiurl= "$url/api/v1/hardware/byserial/$serial"} 'Get with serial' { $api= "/api/v1/hardware/byserial/$serial"}
'Assets due auditing soon' {$apiurl = "$url/api/v1/hardware/audit/due"} 'Assets due auditing soon' {$api = "/api/v1/hardware/audit/due"}
'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"} 'Assets overdue for auditing' {$api = "/api/v1/hardware/audit/overdue"}
'Assets checked out to user id'{$apiurl = "$url/api/v1/users/$user_id/assets"} 'Assets checked out to user id'{$api = "/api/v1/users/$user_id/assets"}
'Assets with component id' {$apiurl = "$url/api/v1/components/$component_id/assets"} 'Assets with component id' {$api = "/api/v1/components/$component_id/assets"}
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
GetParameters = $SearchParameter GetParameters = $SearchParameter
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
if ($all) { if ($all) {
$offstart = $(if ($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
Write-Verbose "Callargs: $($callargs | convertto-json)" Write-Verbose "Callargs: $($callargs | convertto-json)"
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -24,19 +24,18 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..." Get-SnipeitAssetMaintenances
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine"
.EXAMPLE .EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..." Get-SnipeitAssetMaintenances -search "myMachine"
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
#> #>
function Get-SnipeitAssetMaintenance() { function Get-SnipeitAssetMaintenance() {
Param( Param(
@ -67,14 +66,23 @@ function Get-SnipeitAssetMaintenance() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/maintenances" Api = "/api/v1/maintenances"
Method = 'Get' Method = 'Get'
GetParameters = $SearchParameter GetParameters = $SearchParameter
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
Url of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Url of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitCategory -id 1 Get-SnipeitCategory -id 1
@ -31,8 +31,7 @@ Get-SnipeitCategory -search "Laptop"
#> #>
function Get-SnipeitCategory() function Get-SnipeitCategory() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -64,25 +63,34 @@ function Get-SnipeitCategory()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/categories" $api = "/api/v1/categories"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/categories/$id" $api= "/api/v1/categories/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -17,10 +17,10 @@ Offset to use
.PARAMETER all .PARAMETER all
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitCompany Get-SnipeitCompany
@ -32,8 +32,7 @@ Gets specific company
#> #>
function Get-SnipeitCompany() function Get-SnipeitCompany() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -66,25 +65,34 @@ function Get-SnipeitCompany()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/companies" $api = "/api/v1/companies"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/companies/$id" $api= "/api/v1/companies/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system,can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitComponent Get-SnipeitComponent
@ -82,25 +82,34 @@ function Get-SnipeitComponent() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/components" $api = "/api/v1/components"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/components/$id" $api= "/api/v1/components/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -36,10 +36,10 @@ Offset to use
A return all results A return all results
.PARAMETER url .PARAMETER url
URL of Snipeit system,can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitConsumable -all Get-SnipeitConsumable -all
@ -111,14 +111,23 @@ function Get-SnipeitConsumable() {
switch ($PSCmdlet.ParameterSetName) { switch ($PSCmdlet.ParameterSetName) {
'Search' { 'Search' {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables" Api = "/api/v1/consumables"
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')
@ -141,11 +150,21 @@ function Get-SnipeitConsumable() {
'Get with ID' { 'Get with ID' {
foreach($consumable_id in $id) { foreach($consumable_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables/$consumable_id" Api = "$url/api/v1/consumables/$consumable_id"
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
$result $result
} }

View file

@ -6,18 +6,23 @@
A id of specific field A id of specific field
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitCustomField -url "https://assets.example.com" -token "token..." Get-SnipeitCustomField
Get all custom fields
.EXAMPLE
Get-SnipeitCustomField -id 1
Get custom field with ID 1
#> #>
function Get-SnipeitCustomField() function Get-SnipeitCustomField() {
{
Param( Param(
[int]$id, [int]$id,
@ -31,17 +36,27 @@ function Get-SnipeitCustomField()
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) { if ($id) {
$apiurl= "$url/api/v1/fields/$id" $api= "/api/v1/fields/$id"
} else { } else {
$apiurl = "$url/api/v1/fields" $api = "/api/v1/fields"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -18,13 +18,13 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitDepartment -url "https://assets.example.com" -token "token..." Get-SnipeitDepartment
.EXAMPLE .EXAMPLE
Get-SnipeitDepartment -search Department1 Get-SnipeitDepartment -search Department1
@ -34,8 +34,7 @@ Get-SnipeitDepartment -id 1
#> #>
function Get-SnipeitDepartment() function Get-SnipeitDepartment() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -72,25 +71,34 @@ function Get-SnipeitDepartment()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/departments" $api = "/api/v1/departments"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/departments/$id" $api= "/api/v1/departments/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -6,16 +6,18 @@ Returns a fieldset or list of Snipe-it Fieldsets
A id of specific fieldset A id of specific fieldset
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." Get-SnipeitFieldset
Get all fieldsets
.EXAMPLE .EXAMPLE
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Windows" } Get-SnipeitFieldset | Where-Object {$_.name -eq "Windows" }
Gets fieldset by name
#> #>
@ -33,15 +35,24 @@ function Get-SnipeitFieldset() {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) { if ($id) {
$apiurl = "$url/api/v1/fieldsets/$id" $api = "/api/v1/fieldsets/$id"
} else { } else {
$apiurl = "$url/api/v1/fieldsets" $api = "/api/v1/fieldsets"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters

View file

@ -19,10 +19,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitLicense -search SomeLicense Get-SnipeitLicense -search SomeLicense
@ -110,21 +110,30 @@ function Get-SnipeitLicense() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
switch($PsCmdlet.ParameterSetName) { switch($PsCmdlet.ParameterSetName) {
'Search' {$apiurl = "$url/api/v1/licenses"} 'Search' {$api = "/api/v1/licenses"}
'Get with ID' {$apiurl= "$url/api/v1/licenses/$id"} 'Get with ID' {$api= "/api/v1/licenses/$id"}
'Get licenses checked out to user ID' {$apiurl= "$url/api/v1/users/$user_id/licenses"} 'Get licenses checked out to user ID' {$api= "/api/v1/users/$user_id/licenses"}
'Get licenses checked out to asset ID' {$apiurl= "$url/api/v1/hardware/$asset_id/licenses"} 'Get licenses checked out to asset ID' {$api= "/api/v1/hardware/$asset_id/licenses"}
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -22,10 +22,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitLicenseSeat -id 1 Get-SnipeitLicenseSeat -id 1
@ -58,22 +58,31 @@ function Get-SnipeitLicenseSeat() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/licenses/$id/seats" $api = "/api/v1/licenses/$id/seats"
if ($seat_id) { if ($seat_id) {
$apiurl= "$url/api/v1/licenses/$id/seats/$seat_id" $api= "/api/v1/licenses/$id/seats/$seat_id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitLocation -search Location1 Get-SnipeitLocation -search Location1
@ -31,8 +31,7 @@ Get-SnipeitLocation -id 3
#> #>
function Get-SnipeitLocation() function Get-SnipeitLocation() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -65,25 +64,34 @@ function Get-SnipeitLocation()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/locations" $api = "/api/v1/locations"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/locations/$id" $api= "/api/v1/locations/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitManufacturer -search HP Get-SnipeitManufacturer -search HP
@ -32,8 +32,7 @@
Returns manufacturer with id 3 Returns manufacturer with id 3
#> #>
function Get-SnipeitManufacturer() function Get-SnipeitManufacturer() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -66,25 +65,34 @@ function Get-SnipeitManufacturer()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/manufacturers" $api = "/api/v1/manufacturers"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/manufacturers/$id" $api= "/api/v1/manufacturers/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitModel -search "DL380" Get-SnipeitModel -search "DL380"
@ -31,8 +31,7 @@ Get-SnipeitModel -id 1
#> #>
function Get-SnipeitModel() function Get-SnipeitModel() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -65,25 +64,34 @@ function Get-SnipeitModel()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/models" $api = "/api/v1/models"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/models/$id" $api= "/api/v1/models/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy" Get-SnipeitStatus -search "Ready to Deploy"
@ -31,8 +31,7 @@ Get-SnipeitStatus -id 3
#> #>
function Get-SnipeitStatus() function Get-SnipeitStatus() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -65,25 +64,34 @@ function Get-SnipeitStatus()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/statuslabels" $api = "/api/v1/statuslabels"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/statuslabels/$id" $api= "/api/v1/statuslabels/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitSupplier -search MySupplier Get-SnipeitSupplier -search MySupplier
@ -30,8 +30,7 @@ Get-SnipeitSupplier -search MySupplier
Get-SnipeitSupplier -id 2 Get-SnipeitSupplier -id 2
#> #>
function Get-SnipeitSupplier() function Get-SnipeitSupplier() {
{
[CmdletBinding(DefaultParameterSetName = 'Search')] [CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
@ -64,25 +63,34 @@ function Get-SnipeitSupplier()
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/suppliers" $api = "/api/v1/suppliers"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
} }
if ($id) { if ($id) {
$apiurl= "$url/api/v1/suppliers/$id" $api= "/api/v1/suppliers/$id"
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter GetParameters = $SearchParameter
} }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -24,10 +24,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitUser -search SomeSurname Get-SnipeitUser -search SomeSurname
@ -101,20 +101,29 @@ function Get-SnipeitUser() {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
switch ($PsCmdlet.ParameterSetName) { switch ($PsCmdlet.ParameterSetName) {
'Search' { $apiurl = "$url/api/v1/users"} 'Search' { $api = "/api/v1/users"}
'Get with id' {$apiurl= "$url/api/v1/users/$id"} 'Get with id' {$api= "/api/v1/users/$id"}
'Get users a specific accessory id has been checked out to' {$apiurl= "$url/api/v1/accessories/$accessory_id/checkedout"} 'Get users a specific accessory id has been checked out to' {$api= "/api/v1/accessories/$accessory_id/checkedout"}
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Api = $api
Method = 'Get' Method = 'Get'
GetParameters = $SearchParameter GetParameters = $SearchParameter
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
} }
if ($all) { if ($all) {
$offstart = $(if($offset){$offset} Else {0}) $offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter $callargs = $SearchParameter
$callargs.Remove('all') $callargs.Remove('all')

View file

@ -57,10 +57,10 @@ Min quantity of the accessory before alert is triggered
Accessory image fileame and path Accessory image fileame and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1 New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1
@ -125,13 +125,22 @@ function New-SnipeitAccessory() {
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories" Api = "/api/v1/accessories"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -52,10 +52,10 @@ Id of target user , location or asset
Checkout asset when creating to one of following types user, location or asset. Checkout asset when creating to one of following types user, location or asset.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.PARAMETER customfields .PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit. Hastable of custom fields and extra fields that need passing through to Snipeit.
@ -74,8 +74,7 @@ New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -customfields = @{ "_
Using customfields when creating asset. Using customfields when creating asset.
#> #>
function New-SnipeitAsset() function New-SnipeitAsset() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low", ConfirmImpact = "Low",
@ -153,33 +152,40 @@ function New-SnipeitAsset()
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($customfields) if ($customfields) {
{
$Values += $customfields $Values += $customfields
} }
#Checkout asset when creating it #Checkout asset when creating it
if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating'){ if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') {
switch ($checkout_to_type){ switch ($checkout_to_type) {
'location' { $Values += @{ "assigned_location" = $assigned_id } } 'location' { $Values += @{ "assigned_location" = $assigned_id } }
'user' { $Values += @{ "assigned_user" = $assigned_id } } 'user' { $Values += @{ "assigned_user" = $assigned_id } }
'asset' { $Values += @{ "assigned_asset" = $assigned_id } } 'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
} }
#This are not needed for API #This are not needed for API
if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')}
if($Values.ContainsKey('checkout_to_type')){$Values.Remove('checkout_to_type')} if ($Values.ContainsKey('checkout_to_type')) {$Values.Remove('checkout_to_type')}
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware" Api = "/api/v1/hardware"
Method = 'Post' Method = 'Post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -31,10 +31,10 @@ Optional completion date
Optional cost Optional cost
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01 New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01
@ -91,13 +91,22 @@ function New-SnipeitAssetMaintenance() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/maintenances" Api = "/api/v1/maintenances"
Method = 'Post' Method = 'Post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -16,8 +16,7 @@ New-SnipeitAudit -tag 1 -location_id 1
#> #>
function New-SnipeitAudit() function New-SnipeitAudit() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -43,20 +42,27 @@ function New-SnipeitAudit()
"location_id" = $location_id "location_id" = $location_id
} }
if ($PSBoundParameters.ContainsKey('tag')) if ($PSBoundParameters.ContainsKey('tag')) {
{
$Values += @{"asset_tag" = $tag} $Values += @{"asset_tag" = $tag}
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/audit" Api = "/api/v1/hardware/audit"
Method = 'Post' Method = 'Post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -24,17 +24,16 @@ If switch is present, send email to user on checkin/checkout
Category image filename and path Category image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitCategory -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..." New-SnipeitCategory -name "Laptops" -category_type asset
#> #>
function New-SnipeitCategory() function New-SnipeitCategory() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -69,7 +68,7 @@ function New-SnipeitCategory()
begin { begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if($eula_text -and $use_default_eula){ if ($eula_text -and $use_default_eula) {
throw 'Dont use -use_defalt_eula if -eula_text is set' throw 'Dont use -use_defalt_eula if -eula_text is set'
} }
@ -79,14 +78,22 @@ function New-SnipeitCategory()
process { process {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories" Api = "/api/v1/categories"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -12,18 +12,17 @@ Comapany name
Company image filename and path Company image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitCompany -name "Acme Company" New-SnipeitCompany -name "Acme Company"
#> #>
function New-SnipeitCompany() function New-SnipeitCompany() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -48,17 +47,26 @@ function New-SnipeitCompany()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies" Api = "/api/v1/companies"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $result
$result
} }

View file

@ -30,16 +30,15 @@ Cost of item being purchased.
Component image filename and path Component image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
An example New-SnipeitComponent -name 'Display adapter' -catecory_id 3 -qty 10
.NOTES
General notes
#> #>
function New-SnipeitComponent() { function New-SnipeitComponent() {
@ -87,13 +86,22 @@ function New-SnipeitComponent() {
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components" Api = "/api/v1/components"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -48,10 +48,10 @@ Item number for the consumable
Consumable Image filename and path Consumable Image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
@ -60,8 +60,7 @@ Create consumable with stock count 20 , alert when stock is 5 or lower
#> #>
function New-SnipeitConsumable() function New-SnipeitConsumable() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -127,14 +126,22 @@ function New-SnipeitConsumable()
process { process {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables" Api = "/api/v1/consumables"
Method = 'Post' Method = 'Post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -30,17 +30,16 @@
Any additional text you wish to display under the new form field to make it clearer what the gauges should be. Any additional text you wish to display under the new form field to make it clearer what the gauges should be.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset" New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#> #>
function New-SnipeitCustomField() function New-SnipeitCustomField() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -84,16 +83,22 @@ function New-SnipeitCustomField()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields" Api = "/api/v1/fields"
Method = 'post' Method = 'post'
Body = $Values Body = $Values
Token = $apiKey }
if ($PSBoundParameters.ContainsKey('apiKey')) {
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Set-SnipeitPSSessionApiKey -url $url
} }
} }
process{ process{
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
{
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -21,10 +21,10 @@
Department Image filename and path Department Image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -66,13 +66,22 @@ function New-SnipeitDepartment() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments" Api = "/api/v1/departments"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -57,10 +57,10 @@
Termination date for license. Termination date for license.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitLicence -name "License" -seats 3 -company_id 1 New-SnipeitLicence -name "License" -seats 3 -company_id 1
@ -141,13 +141,22 @@ function New-SnipeitLicense() {
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses" Api = "/api/v1/licenses"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -42,10 +42,10 @@
Location Image filename and path Location Image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14 New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14
@ -98,13 +98,22 @@ function New-SnipeitLocation() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations" Api = "/api/v1/locations"
Method = 'post' Method = 'post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -15,17 +15,16 @@
Remove current image Remove current image
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitManufacturer -name "HP" New-SnipeitManufacturer -name "HP"
#> #>
function New-SnipeitManufacturer() function New-SnipeitManufacturer() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -54,14 +53,22 @@ function New-SnipeitManufacturer()
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/manufacturers" Api = "/api/v1/manufacturers"
Method = 'post' Method = 'post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -24,17 +24,16 @@
Asset model Image filename and path Asset model Image filename and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
#> #>
function New-SnipeitModel() function New-SnipeitModel() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -81,14 +80,22 @@ function New-SnipeitModel()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models" Api = "/api/v1/models"
Method = 'post' Method = 'post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -45,10 +45,10 @@
Image file name and path for item Image file name and path for item
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -102,13 +102,22 @@ function New-SnipeitSupplier() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/suppilers" Api = "/api/v1/suppilers"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -54,10 +54,10 @@
User Image file name and path User Image file name and path
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -126,13 +126,22 @@ function New-SnipeitUser() {
} }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users" Api = "/api/v1/users"
Method = 'post' Method = 'post'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -6,10 +6,10 @@
.PARAMETER ID .PARAMETER ID
Unique ID For accessory to be removed Unique ID For accessory to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitAccessory -ID 44 -Verbose Remove-SnipeitAccessory -ID 44 -Verbose
@ -18,8 +18,7 @@
Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory
#> #>
function Remove-SnipeitAccessory () function Remove-SnipeitAccessory () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitAccessory ()
} }
process { process {
foreach($accessory_id in $id){ foreach($accessory_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id" Api = "/api/v1/accessories/$accessory_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,10 +6,10 @@
.PARAMETER ID .PARAMETER ID
Unique ID For Asset to be removed Unique ID For Asset to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitAsset -ID 44 -Verbose Remove-SnipeitAsset -ID 44 -Verbose
@ -18,8 +18,7 @@
Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset
#> #>
function Remove-SnipeitAsset () function Remove-SnipeitAsset () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -41,18 +40,27 @@ function Remove-SnipeitAsset ()
} }
process { process {
foreach($asset_id in $id){ foreach($asset_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id" Api = "/api/v1/hardware/$asset_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -1,23 +1,23 @@
<#
.SYNOPSIS
Remove asset maintenance from Snipe-it asset system
.DESCRIPTION
Removes asset maintenance event or events from Snipe-it asset system by ID
.PARAMETER ID
Unique ID of the asset maintenance to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitAssetMaintenance -ID 44
#>
function Remove-SnipeitAssetMaintenance { function Remove-SnipeitAssetMaintenance {
<#
.SYNOPSIS
Remove asset maintenance from Snipe-it asset system
.DESCRIPTION
Removes asset maintenance event or events from Snipe-it asset system by ID
.PARAMETER ID
Unique ID of the asset maintenance to be removed
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitAssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose
#>
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -39,15 +39,23 @@ function Remove-SnipeitAssetMaintenance {
} }
process { process {
foreach($maintenance_id in $id){ foreach($maintenance_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/maintenances/$maintenance_id" Api = "/api/v1/maintenances/$maintenance_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For categoryto be removed Unique ID For categoryto be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitCategory -ID 44 -Verbose Remove-SnipeitCategory -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitCategory -search something | Remove-SnipeitCategory Get-SnipeitCategory -search something | Remove-SnipeitCategory
#> #>
function Remove-SnipeitCategory () function Remove-SnipeitCategory () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -39,18 +38,27 @@ function Remove-SnipeitCategory ()
begin { begin {
} }
process { process {
foreach($category_id in $id){ foreach($category_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories/$category_id" Api = "/api/v1/categories/$category_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For Company to be removed Unique ID For Company to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitCompany -ID 44 -Verbose Remove-SnipeitCompany -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCompany Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCompany
#> #>
function Remove-SnipeitCompany () function Remove-SnipeitCompany () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -39,18 +38,27 @@ function Remove-SnipeitCompany ()
begin { begin {
} }
process { process {
foreach($company_id in $id){ foreach($company_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies/$company_id" Api = "/api/v1/companies/$company_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER IDs .PARAMETER IDs
Unique ID For component to be removed Unique ID For component to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitComponent -ID 44 -Verbose Remove-SnipeitComponent -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent
#> #>
function Remove-SnipeitComponent () function Remove-SnipeitComponent () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitComponent ()
} }
process { process {
foreach($component_id in $id){ foreach($component_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components/$component_id" Api = "/api/v1/components/$component_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -7,20 +7,19 @@
Unique ID For consumable to be removed Unique ID For consumable to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitConsumable -ID 44 -Verbose Remove-SnipeitConsumable -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitConsumable -search "paper" | Remove-Snipeitconsumable Get-SnipeitConsumable -search "paper" | Remove-SnipeitConsumable
#> #>
function Remove-SnipeitConsumable () function Remove-SnipeitConsumable () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -41,18 +40,27 @@ function Remove-SnipeitConsumable ()
} }
process { process {
foreach($consumable_id in $id){ foreach($consumable_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables/$consumable_id" Api = "/api/v1/consumables/$consumable_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,10 +6,10 @@
.PARAMETER ID .PARAMETER ID
Unique ID For field to be removed Unique ID For field to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitCustomField -ID 44 -Verbose Remove-SnipeitCustomField -ID 44 -Verbose
@ -18,8 +18,7 @@
Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-SnipeitCustomField Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-SnipeitCustomField
#> #>
function Remove-SnipeitCustomField () function Remove-SnipeitCustomField () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -38,18 +37,27 @@ function Remove-SnipeitCustomField ()
begin { begin {
} }
process { process {
foreach($field_id in $id){ foreach($field_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields/$field_id" Api = "/api/v1/fields/$field_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For department to be removed Unique ID For department to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitDepartment -ID 44 -Verbose Remove-SnipeitDepartment -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDepartment Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDepartment
#> #>
function Remove-SnipeitDepartment () function Remove-SnipeitDepartment () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -39,18 +38,27 @@ function Remove-SnipeitDepartment ()
begin { begin {
} }
process { process {
foreach($department_id in $id){ foreach($department_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments/$department_id" Api = "/api/v1/departments/$department_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For licence to be removed Unique ID For licence to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitLicence -ID 44 -Verbose Remove-SnipeitLicence -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense
#> #>
function Remove-SnipeitLicense () function Remove-SnipeitLicense () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitLicense ()
} }
process { process {
foreach($license_id in $id){ foreach($license_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id" Api = "/api/v1/licenses/$license_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For location to be removed Unique ID For location to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitLocation -ID 44 -Verbose Remove-SnipeitLocation -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation
#> #>
function Remove-SnipeitLocation () function Remove-SnipeitLocation () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitLocation ()
} }
process { process {
foreach($location_id in $id){ foreach($location_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations/$asset_id" Api = "/api/v1/locations/$asset_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For manufacturer to be removed Unique ID For manufacturer to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitManufacturer -ID 44 -Verbose Remove-SnipeitManufacturer -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-SnipeitManufacturer Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-SnipeitManufacturer
#> #>
function Remove-SnipeitManufacturer () function Remove-SnipeitManufacturer () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitManufacturer ()
} }
process { process {
foreach($manufacturer_id in $id){ foreach($manufacturer_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/manufacturers/$manufacturer_id" Api = "/api/v1/manufacturers/$manufacturer_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,20 +6,19 @@
.PARAMETER ID .PARAMETER ID
Unique ID For Model to be removed Unique ID For Model to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitModel -ID 44 -Verbose Remove-SnipeitModel -ID 44
.EXAMPLE .EXAMPLE
Get-SnipeitModel -search needle | Remove-SnipeitModel Get-SnipeitModel -search needle | Remove-SnipeitModel
#> #>
function Remove-SnipeitModel () function Remove-SnipeitModel () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitModel ()
} }
process { process {
foreach($model_id in $id){ foreach($model_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models/$model_id" Api = "/api/v1/models/$model_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -6,10 +6,10 @@
.PARAMETER ID .PARAMETER ID
Unique ID For supplier to be removed Unique ID For supplier to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitSupplier -ID 44 Remove-SnipeitSupplier -ID 44
@ -18,8 +18,7 @@
Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier
#> #>
function Remove-SnipeitSupplier () function Remove-SnipeitSupplier () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -40,18 +39,27 @@ function Remove-SnipeitSupplier ()
} }
process { process {
foreach($suppliers_id in $id){ foreach($suppliers_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/suppliers/$supplier_id" Api = "/api/v1/suppliers/$supplier_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
$result = Invoke-SnipeitMethod @Parameters Set-SnipeitPSSessionApiKey -apiKey $apikey
} }
$result
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
} }
} }

View file

@ -7,17 +7,16 @@
Unique ID For User to be removed Unique ID For User to be removed
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#> #>
function Remove-SnipeitUser () function Remove-SnipeitUser () {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -41,13 +40,21 @@ function Remove-SnipeitUser ()
process { process {
foreach($user_id in $id) { foreach($user_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users/$user_id" Api = "/api/v1/users/$user_id"
Method = 'Delete' Method = 'Delete'
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -10,10 +10,10 @@
Use Get-SnipeitAccessoryOwner to find out nooded value Use Get-SnipeitAccessoryOwner to find out nooded value
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
To get the accessories_users table for specific accessory id number To get the accessories_users table for specific accessory id number
@ -25,8 +25,7 @@
Get-SnipeitAccessoryOwner -assigned_pivot_id xxx Get-SnipeitAccessoryOwner -assigned_pivot_id xxx
#> #>
function Reset-SnipeitAccessoryOwner() function Reset-SnipeitAccessoryOwner() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -44,14 +43,22 @@ function Reset-SnipeitAccessoryOwner()
) )
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin" Api = "/api/v1/accessories/$assigned_pivot_id/checkin"
Method = 'Post' Method = 'Post'
Body = @{} Body = @{}
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -17,13 +17,11 @@
Notes about checkin Notes about checkin
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose Remove-SnipeitUser -ID 44
#> #>
function Reset-SnipeitAssetOwner() { function Reset-SnipeitAssetOwner() {
[CmdletBinding( [CmdletBinding(
@ -58,13 +56,22 @@ function Reset-SnipeitAssetOwner() {
if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) } if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) }
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$id/checkin" Api = "/api/v1/hardware/$id/checkin"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -54,11 +54,10 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitAccessory -id 1 -qty 3 Set-SnipeitAccessory -id 1 -qty 3
@ -126,15 +125,24 @@ function Set-SnipeitAccessory() {
} }
process { process {
foreach($accessory_id in $id){ foreach($accessory_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id" Api = "/api/v1/accessories/$accessory_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -14,16 +14,15 @@
Notes about checkout Notes about checkout
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user" Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user"
#> #>
function Set-SnipeitAccessoryOwner() function Set-SnipeitAccessoryOwner() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -49,16 +48,24 @@ function Set-SnipeitAccessoryOwner()
} }
process { process {
foreach($accessory_id in $id){ foreach($accessory_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id/checkout" Api = "/api/v1/accessories/$accessory_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -63,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.PARAMETER customfields .PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit Hastable of custom fields and extra fields that need passing through to Snipeit
@ -81,8 +81,7 @@
Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated' Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated'
#> #>
function Set-SnipeitAsset() function Set-SnipeitAsset() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -151,24 +150,31 @@ function Set-SnipeitAsset()
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($customfields) if ($customfields) {
{
$Values += $customfields $Values += $customfields
} }
} }
process { process {
foreach($asset_id in $id){ foreach($asset_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id" Api = "/api/v1/hardware/$asset_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -28,16 +28,15 @@
Optional date to override the checkout time of now Optional date to override the checkout time of now
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing check out to user" Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing check out to user"
#> #>
function Set-SnipeitAssetOwner() function Set-SnipeitAssetOwner() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -81,29 +80,36 @@ function Set-SnipeitAssetOwner()
$Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd") $Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd")
} }
switch ($checkout_to_type) switch ($checkout_to_type) {
{
'location' { $Values += @{ "assigned_location" = $assigned_id } } 'location' { $Values += @{ "assigned_location" = $assigned_id } }
'user' { $Values += @{ "assigned_user" = $assigned_id } } 'user' { $Values += @{ "assigned_user" = $assigned_id } }
'asset' { $Values += @{ "assigned_asset" = $assigned_id } } 'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
} }
#This can be removed now #This can be removed now
if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')}
} }
process{ process{
foreach($asset_id in $id){ foreach($asset_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id/checkout" Api = "/api/v1/hardware/$asset_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -30,17 +30,16 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitCategory -id 4 -name "Laptops" Set-SnipeitCategory -id 4 -name "Laptops"
#> #>
function Set-SnipeitCategory() function Set-SnipeitCategory() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -86,16 +85,24 @@ function Set-SnipeitCategory()
} }
process { process {
foreach($category_id in $id){ foreach($category_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories/$category_id" Api = "/api/v1/categories/$category_id"
Method = $RequestType Method = $RequestType
Body = $values Body = $values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -21,10 +21,10 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
An example An example
@ -32,8 +32,7 @@ An example
.NOTES .NOTES
General notes General notes
#> #>
function Set-SnipeitCompany() function Set-SnipeitCompany() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -66,16 +65,24 @@ function Set-SnipeitCompany()
} }
process{ process{
foreach($company_id in $id){ foreach($company_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies/$company_id" Api = "/api/v1/companies/$company_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -42,19 +42,17 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .EXAMPLE
An example Set-SnipeitComponent -id 42 -qty 12
Sets count of component with ID 42 to 12
.NOTES
General notes
#> #>
function Set-SnipeitComponent() function Set-SnipeitComponent() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -107,16 +105,24 @@ function Set-SnipeitComponent()
} }
process { process {
foreach($component_id in $id){ foreach($component_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components/$component_id" Api = "/api/v1/components/$component_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -57,10 +57,10 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
@ -69,8 +69,7 @@ Create consumable with stock count 20 , alert when stock is 5 or lower
#> #>
function Set-SnipeitConsumable() function Set-SnipeitConsumable() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -146,16 +145,24 @@ function Set-SnipeitConsumable()
} }
process { process {
foreach($consumable_id in $id ){ foreach($consumable_id in $id ) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables/$consumable_id" Api = "/api/v1/consumables/$consumable_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -33,17 +33,16 @@
Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed. Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset" New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#> #>
function Set-SnipeitCustomField() function Set-SnipeitCustomField() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -93,14 +92,22 @@ function Set-SnipeitCustomField()
process{ process{
foreach($field_id in $id) { foreach($field_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields/$field_id" Api = "/api/v1/fields/$field_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -30,10 +30,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitDepartment -id 4 -manager_id 3 Set-SnipeitDepartment -id 4 -manager_id 3
@ -83,13 +83,22 @@ function Set-SnipeitDepartment() {
process { process {
foreach ($department_id in $id) { foreach ($department_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments/$department_id" Api = "/api/v1/departments/$department_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -1,14 +1,16 @@
<# <#
.SYNOPSIS .SYNOPSIS
Sets authetication information Sets authetication information. Deprecated, use Connect-SnipeitPS instead.
.DESCRIPTION .DESCRIPTION
Set apikey and url user to connect Snipe-It system Deprecated combatibilty function that Set apikey and url user to connect Snipe-It system.
Please use Connect-SnipeitPS instead.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitInfo -url $url -apiKey -Verbose Set-SnipeitInfo -url $url -apiKey -Verbose
@ -17,50 +19,18 @@ function Set-SnipeitInfo {
[CmdletBinding()] [CmdletBinding()]
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
param ( param (
[parameter(Mandatory=$true)]
[Uri]$url, [Uri]$url,
[parameter(Mandatory=$true)]
[String]$apiKey [String]$apiKey
) )
BEGIN { BEGIN {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
function Add-DefaultParameter {
param(
[Parameter(Mandatory = $true)]
[string]$Command,
[Parameter(Mandatory = $true)] Write-Warning "Deprecated $($MyInvocation.InvocationName) is still working, please use Connect-SnipeitPS instead."
[string]$Parameter,
[Parameter(Mandatory = $true)]
$Value
)
PROCESS {
#Write-Verbose "[$($MyInvocation.MyCommand.Name)] Setting [$command : $parameter] = $value"
# Needs to set both global and module scope for the private functions:
# http://stackoverflow.com/questions/30427110/set-psdefaultparametersvalues-for-use-within-module-scope
$PSDefaultParameterValues["${command}:${parameter}"] = $Value
$global:PSDefaultParameterValues["${command}:${parameter}"] = $Value
}
}
$moduleCommands = Get-Command -Module SnipeitPS -CommandType Function
} }
PROCESS { PROCESS {
foreach ($command in $moduleCommands) { Connect-SnipeitPS -Url $url -apiKey $apiKey
$parameter = "url"
if ($url -and ($command.Parameters.Keys -contains $parameter)) {
Add-DefaultParameter -Command $command -Parameter $parameter -Value ($url.AbsoluteUri.TrimEnd('/'))
}
$parameter = "apiKey"
if ($apiKey -and ($command.Parameters.Keys -contains $parameter)) {
Add-DefaultParameter -Command $command -Parameter $parameter -Value $apiKey
}
}
} }
} }

View file

@ -63,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitLicence -name "License" -seats 3 -company_id 1 Set-SnipeitLicence -name "License" -seats 3 -company_id 1
@ -154,15 +154,24 @@ function Set-SnipeitLicense() {
} }
process { process {
foreach($license_id in $id){ foreach($license_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id" Api = "/api/v1/licenses/$license_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -20,10 +20,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3
@ -38,8 +38,7 @@
Checkin licence seat id 1 of licence id 1 Checkin licence seat id 1 of licence id 1
#> #>
function Set-SnipeitLicenseSeat() function Set-SnipeitLicenseSeat() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -78,14 +77,22 @@ function Set-SnipeitLicenseSeat()
process{ process{
foreach($license_id in $id) { foreach($license_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" Api = "/api/v1/licenses/$license_id/seats/$seat_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) if ($PSBoundParameters.ContainsKey('apiKey')) {
{ Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -54,10 +54,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100 Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100
@ -121,13 +121,22 @@ function Set-SnipeitLocation() {
process{ process{
foreach ($location_id in $id) { foreach ($location_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations/$location_id" Api = "/api/v1/locations/$location_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -18,17 +18,16 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitManufacturer -name "HP" New-SnipeitManufacturer -name "HP"
#> #>
function Set-SnipeitManufacturer() function Set-SnipeitManufacturer() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -62,13 +61,22 @@ function Set-SnipeitManufacturer()
process{ process{
foreach ($manufacturer_id in $id) { foreach ($manufacturer_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/manufacturers/$manufacturer_id" Api = "/api/v1/manufacturers/$manufacturer_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -33,10 +33,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
@ -90,13 +90,22 @@ function Set-SnipeitModel() {
process { process {
foreach ($model_id in $id) { foreach ($model_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models/$model_id" Api = "/api/v1/models/$model_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -19,10 +19,10 @@ Hex code showing what color the status label should be on the pie chart in the d
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy" Get-SnipeitStatus -search "Ready to Deploy"
@ -32,8 +32,7 @@ Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending
#> #>
function Set-SnipeitStatus() function Set-SnipeitStatus() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -73,13 +72,22 @@ function Set-SnipeitStatus()
process { process {
foreach($status_id in $id) { foreach($status_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/statuslabels/$status_id" Api = "/api/v1/statuslabels/$status_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $result

View file

@ -51,10 +51,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE .EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -117,13 +117,22 @@ function Set-SnipeitSupplier() {
process { process {
foreach ($supplier_id in $id) { foreach ($supplier_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/suppliers/$supplier_id" Api = "/api/v1/suppliers/$supplier_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -63,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE .EXAMPLE
Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -144,13 +144,22 @@ function Set-SnipeitUser() {
process{ process{
foreach($user_id in $id) { foreach($user_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users/$user_id" Api = "/api/v1/users/$user_id"
Method = 'PATCH' Method = 'PATCH'
Body = $Values Body = $Values
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('apiKey')) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url')) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSSessionApiKey -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }

View file

@ -15,8 +15,7 @@ Replaces old command from file "your-script.ps1" and creates new script "new-scr
After testing new file you can replace old file with new. After testing new file you can replace old file with new.
#> #>
function Update-SnipeitAlias() function Update-SnipeitAlias() {
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -34,8 +33,8 @@ function Update-SnipeitAlias()
} }
process { process {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
ForEach ($st in $String){ ForEach ($st in $String) {
$result = $st $result = $st
ForEach ($key in $SnipeitAliases.Keys ) { ForEach ($key in $SnipeitAliases.Keys ) {
#Write-Verbose "Replacing $key with $($SnipeitAliases[$key])" #Write-Verbose "Replacing $key with $($SnipeitAliases[$key])"