Support for checkin accessories out and in

This commit is contained in:
Petri Asikainen 2021-05-25 22:53:22 +03:00
parent 9a7bc1339c
commit 66e746bce0
8 changed files with 574 additions and 1 deletions

View file

@ -0,0 +1,49 @@
<#
.SYNOPSIS
Get list of checked out accessories
.DESCRIPTION
Get list of checked out accessories
.PARAMETER id
Unique ID For accessory to list
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Get-SnipeItAccessoryOwner -id 1
#>
function Get-SnipeItAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true)]
[int]$id,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
$Parameters = @{
Uri = "$url/api/v1/accessories/$id/checkedout"
Method = 'GET'
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}

View file

@ -0,0 +1,59 @@
<#
.SYNOPSIS
Checkin accessories
.DESCRIPTION
Checkin accessories
.PARAMETER assigned_pivot_id
This is the assigned_pivot_id of the accessory+user relationships in the accessories_users table
Use Get-SnipeItAccessoryOwner to find out nooded value
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
To get the accessories_users table for specific accessory id number
Get-SnipeItAccessoryOwner -id 1
Thenselect assigned_pivot_id for userid you like check in
Get-SnipeItAccessoryOwner -assigned_pivot_id xxx
#>
function Reset-SnipeItAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true)]
[int]$assigned_pivot_id,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
$Parameters = @{
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
Method = 'Post'
Body = '{}'
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}

View file

@ -0,0 +1,65 @@
<#
.SYNOPSIS
Checkout accessory
.DESCRIPTION
Checkout accessory to user
.PARAMETER id
Unique ID For accessory to checkout
.PARAMETER assigned_id
Id of target user
.PARAMETER note
Notes about checkout
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Set-SnipeItAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user"
#>
function Set-SnipeItAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true)]
[int]$id,
[parameter(mandatory = $true)]
[int]$assigned_to,
[string] $note,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;
$Parameters = @{
Uri = "$url/api/v1/accessories/$id/checkout"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}

View file

@ -111,7 +111,10 @@ FunctionsToExport = @(
'Get-SnipeItAccessory',
'Remove-SnipeItAsset',
'Remove-SnipeItUser',
'Update-SnipeItAlias'
'Update-SnipeItAlias',
'Set-SnipeItAccessoryOwner',
'Get-SnipeItAccessoryOwner',
'Reset-SnipeItAccessoryOwner'
)

View file

@ -0,0 +1,117 @@
---
external help file: SnipeItPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Get-SnipeItAccessoryOwner
## SYNOPSIS
Get list of checked out accessories
## SYNTAX
```
Get-SnipeItAccessoryOwner [-id] <Int32> [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
Get list of checked out accessories
## EXAMPLES
### EXAMPLE 1
```
Get-SnipeItAccessoryOwner -id 1
```
## PARAMETERS
### -apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -id
Unique ID For accessory to list
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
URL of Snipeit system, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

View file

@ -0,0 +1,124 @@
---
external help file: SnipeItPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Reset-SnipeItAccessoryOwner
## SYNOPSIS
Checkin accessories
## SYNTAX
```
Reset-SnipeItAccessoryOwner [-assigned_pivot_id] <Int32> [-url] <String> [-apiKey] <String> [-WhatIf]
[-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Checkin accessories
## EXAMPLES
### EXAMPLE 1
```
To get the accessories_users table for specific accessory id number
```
Get-SnipeItAccessoryOwner -id 1
Thenselect assigned_pivot_id for userid you like check in
Get-SnipeItAccessoryOwner -assigned_pivot_id xxx
## PARAMETERS
### -apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -assigned_pivot_id
This is the assigned_pivot_id of the accessory+user relationships in the accessories_users table
Use Get-SnipeItAccessoryOwner to find out nooded value
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
URL of Snipeit system, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

View file

@ -0,0 +1,147 @@
---
external help file: SnipeItPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Set-SnipeItAccessoryOwner
## SYNOPSIS
Checkout accessory
## SYNTAX
```
Set-SnipeItAccessoryOwner [-id] <Int32> [-assigned_to] <Int32> [[-note] <String>] [-url] <String>
[-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Checkout accessory to user
## EXAMPLES
### EXAMPLE 1
```
Set-SnipeItAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user"
```
## PARAMETERS
### -apiKey
User's API Key for Snipeit, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -assigned_to
{{ Fill assigned_to Description }}
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -id
Unique ID For accessory to checkout
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -note
Notes about checkout
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
URL of Snipeit system, can be set using Set-SnipeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

View file

@ -14,6 +14,9 @@ Locale: en-US
### [Get-SnipeItAccessory](Get-SnipeItAccessory.md)
Gets a list of Snipe-it Accessories
### [Get-SnipeItAccessoryOwner](Get-SnipeItAccessoryOwner.md)
Get list of checked out accessories
### [Get-SnipeItAsset](Get-SnipeItAsset.md)
Gets a list of Snipe-it Assets or specific asset
@ -92,9 +95,15 @@ Removes Asset from Snipe-it asset system
### [Remove-SnipeItUser](Remove-SnipeItUser.md)
Removes User from Snipe-it asset system
### [Reset-SnipeItAccessoryOwner](Reset-SnipeItAccessoryOwner.md)
Checkin accessories
### [Set-SnipeItAccessory](Set-SnipeItAccessory.md)
Updates accessory on Snipe-It system
### [Set-SnipeItAccessoryOwner](Set-SnipeItAccessoryOwner.md)
Checkout accessory
### [Set-SnipeItAsset](Set-SnipeItAsset.md)
Update a specific Asset in the Snipe-it asset system