diff --git a/SnipeitPS/Public/Get-SnipeItAccessoryOwner.ps1 b/SnipeitPS/Public/Get-SnipeItAccessoryOwner.ps1 new file mode 100644 index 0000000..cc4c9de --- /dev/null +++ b/SnipeitPS/Public/Get-SnipeItAccessoryOwner.ps1 @@ -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 +} diff --git a/SnipeitPS/Public/Reset-SnipeItAccessoryOwner.ps1 b/SnipeitPS/Public/Reset-SnipeItAccessoryOwner.ps1 new file mode 100644 index 0000000..8f5ffe0 --- /dev/null +++ b/SnipeitPS/Public/Reset-SnipeItAccessoryOwner.ps1 @@ -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 +} diff --git a/SnipeitPS/Public/Set-SnipeItAccessoryOwner.ps1 b/SnipeitPS/Public/Set-SnipeItAccessoryOwner.ps1 new file mode 100644 index 0000000..2602475 --- /dev/null +++ b/SnipeitPS/Public/Set-SnipeItAccessoryOwner.ps1 @@ -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 +} diff --git a/SnipeitPS/SnipeItPS.psd1 b/SnipeitPS/SnipeItPS.psd1 index 0f7a1e0..8bc84b8 100644 --- a/SnipeitPS/SnipeItPS.psd1 +++ b/SnipeitPS/SnipeItPS.psd1 @@ -111,7 +111,10 @@ FunctionsToExport = @( 'Get-SnipeItAccessory', 'Remove-SnipeItAsset', 'Remove-SnipeItUser', - 'Update-SnipeItAlias' + 'Update-SnipeItAlias', + 'Set-SnipeItAccessoryOwner', + 'Get-SnipeItAccessoryOwner', + 'Reset-SnipeItAccessoryOwner' ) diff --git a/docs/Get-SnipeItAccessoryOwner.md b/docs/Get-SnipeItAccessoryOwner.md new file mode 100644 index 0000000..ae75064 --- /dev/null +++ b/docs/Get-SnipeItAccessoryOwner.md @@ -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] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] +``` + +## 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 diff --git a/docs/Reset-SnipeItAccessoryOwner.md b/docs/Reset-SnipeItAccessoryOwner.md new file mode 100644 index 0000000..e777d94 --- /dev/null +++ b/docs/Reset-SnipeItAccessoryOwner.md @@ -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] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] +``` + +## 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 diff --git a/docs/Set-SnipeItAccessoryOwner.md b/docs/Set-SnipeItAccessoryOwner.md new file mode 100644 index 0000000..98da95c --- /dev/null +++ b/docs/Set-SnipeItAccessoryOwner.md @@ -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] [-assigned_to] [[-note] ] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] +``` + +## 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 diff --git a/docs/SnipeItPS.md b/docs/SnipeItPS.md index 4b03e7d..dbc6cf3 100644 --- a/docs/SnipeItPS.md +++ b/docs/SnipeItPS.md @@ -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