mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
commit
0b1d7f9c95
13 changed files with 379 additions and 31 deletions
17
CHANGELOG.md
17
CHANGELOG.md
|
|
@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/),
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [v1.4.x] - 2021-05-27
|
||||
|
||||
## More Activity
|
||||
|
||||
### New features
|
||||
SnipeIt activity history is now searchable. So finding out checked out the
|
||||
assest its easy. Api support many different target or item types that can
|
||||
be uses as filter. Searchable types are 'Accessory','Asset','AssetMaintenance'
|
||||
,'AssetModel','Category','Company','Component','Consumable','CustomField',
|
||||
,'Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel',
|
||||
'Supplier','User'
|
||||
|
||||
|
||||
### New Functions
|
||||
- Get-SnipeItActivity Get and search Snipe-It change history.
|
||||
|
||||
|
||||
# [v1.3.x] - 2021-05-27
|
||||
|
||||
## Checking out accessories
|
||||
|
|
|
|||
126
SnipeitPS/Public/Get-SnipeItActivity.ps1
Normal file
126
SnipeitPS/Public/Get-SnipeItActivity.ps1
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Gets and search Snipe-it Activity history
|
||||
|
||||
.DESCRIPTION
|
||||
Gets a list of Snipe-it activity history
|
||||
|
||||
.PARAMETER search
|
||||
A text string to search the Activity history
|
||||
|
||||
.PARAMETER target_type
|
||||
Type of target. One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
|
||||
|
||||
.PARAMETER target_id
|
||||
Needed if target_type is specified
|
||||
|
||||
.PARAMETER item_type
|
||||
Type of target. One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
|
||||
|
||||
.PARAMETER item_id
|
||||
Needed if target_type is specified
|
||||
|
||||
.PARAMETER action_type
|
||||
Type of action. One from following list "add seats", "checkin from", 'checkout' or 'update'
|
||||
|
||||
.PARAMETER offset
|
||||
Result offset to use
|
||||
|
||||
.PARAMETER all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-SnipeItInfo command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
|
||||
|
||||
.EXAMPLE
|
||||
Get-SnipeItAccessory -search Keyboard
|
||||
|
||||
.EXAMPLE
|
||||
Get-SnipeItAccessory -id 1
|
||||
|
||||
#>
|
||||
|
||||
function Get-SnipeItActivity() {
|
||||
Param(
|
||||
|
||||
[string]$search,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')]
|
||||
[string]$target_type,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$target_id,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[ValidateSet('Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User')]
|
||||
[string]$item_type,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$item_id,
|
||||
|
||||
[ValidateSet("add seats", "checkin from", 'checkout','update')]
|
||||
[string]$action_type ,
|
||||
|
||||
[int]$limit = 50,
|
||||
|
||||
[int]$offset,
|
||||
|
||||
[switch]$all = $false,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
if(($target_type -and -not $target_id) -or
|
||||
($target_id -and -not $target_type)) {
|
||||
throw "Please specify both target_type and target_id"
|
||||
}
|
||||
|
||||
if(($item_type -and -not $item_id) -or
|
||||
($item_id -and -not $item_type)) {
|
||||
throw "Please specify both item_type and item_id"
|
||||
}
|
||||
|
||||
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/reports/activity"
|
||||
Method = 'Get'
|
||||
GetParameters = $SearchParameter
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$offstart = $(if($offset){$offset} Else {0})
|
||||
$callargs = $SearchParameter
|
||||
$callargs.Remove('all')
|
||||
|
||||
while ($true) {
|
||||
$callargs['offset'] = $offstart
|
||||
$callargs['limit'] = $limit
|
||||
$res=Get-SnipeItActivity @callargs
|
||||
$res
|
||||
if ($res.count -lt $limit) {
|
||||
break
|
||||
}
|
||||
$offstart = $offstart + $limit
|
||||
}
|
||||
} else {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'SnipeItPS'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '1.3'
|
||||
ModuleVersion = '1.4'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
|
@ -114,7 +114,8 @@ FunctionsToExport = @(
|
|||
'Update-SnipeItAlias',
|
||||
'Set-SnipeItAccessoryOwner',
|
||||
'Get-SnipeItAccessoryOwner',
|
||||
'Reset-SnipeItAccessoryOwner'
|
||||
'Reset-SnipeItAccessoryOwner',
|
||||
'Get-SnipeItActivity'
|
||||
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ environment:
|
|||
PSGalleryAPIKey:
|
||||
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
|
||||
|
||||
version: 1.3.{build}
|
||||
version: 1.4.{build}
|
||||
|
||||
# Don't rebuild when I tag a release on GitHub
|
||||
skip_tags: true
|
||||
|
|
|
|||
215
docs/Get-SnipeItActivity.md
Normal file
215
docs/Get-SnipeItActivity.md
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeitPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-SnipeItActivity
|
||||
|
||||
## SYNOPSIS
|
||||
Gets and search Snipe-it Activity history
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-SnipeItActivity [[-search] <String>] [[-target_type] <String>] [[-target_id] <Int32>]
|
||||
[[-item_type] <String>] [[-item_id] <Int32>] [[-action_type] <String>] [[-limit] <Int32>] [[-offset] <Int32>]
|
||||
[-all] [-url] <String> [-apiKey] <String> [<CommonParameters>]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Gets a list of Snipe-it activity history
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
```
|
||||
Get-SnipeItAccessory -search Keyboard
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Get-SnipeItAccessory -id 1
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -action_type
|
||||
Type of action.
|
||||
One from following list "add seats", "checkin from", 'checkout' or 'update'
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 6
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -all
|
||||
A return all results, works with -offset and other parameters
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: False
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 10
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -item_id
|
||||
Needed if target_type is specified
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 5
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -item_type
|
||||
Type of target.
|
||||
One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 4
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -limit
|
||||
{{ Fill limit Description }}
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 7
|
||||
Default value: 50
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -offset
|
||||
Result offset to use
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 8
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -search
|
||||
A text string to search the Activity history
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -target_id
|
||||
Needed if target_type is specified
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 3
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -target_type
|
||||
Type of target.
|
||||
One from following list 'Accessory','Asset','AssetMaintenance','AssetModel','Category','Company','Component','Consumable','CustomField','Depreciable','Depreciation','Group','Licence','LicenseSeat','Location','Manufacturer','Statuslabel','Supplier','User'
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 2
|
||||
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: 9
|
||||
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
|
||||
|
|
@ -25,16 +25,14 @@ Get-SnipeItCompany [[-search] <String>] [[-id] <Int32>] [[-order] <String>] [[-l
|
|||
### EXAMPLE 1
|
||||
```
|
||||
Get-SnipeItCompany
|
||||
```
|
||||
|
||||
Gets all companies
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Get-SnipeItCompany -id 1
|
||||
```
|
||||
|
||||
Gets specific company
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -26,23 +26,20 @@ Get-SnipeItComponent [[-search] <String>] [[-id] <Int32>] [[-category_id] <Int32
|
|||
### EXAMPLE 1
|
||||
```
|
||||
Get-SnipeItComponent
|
||||
```
|
||||
|
||||
Returns all components
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Get-SnipeItComponent -search display
|
||||
```
|
||||
|
||||
Returns search results containeing string display
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
```
|
||||
Get-SnipeItComponent -id
|
||||
```
|
||||
|
||||
Returns specific component
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,14 @@ Get-SnipeItManufacturer [[-search] <String>] [[-id] <Int32>] [[-order] <String>]
|
|||
### EXAMPLE 1
|
||||
```
|
||||
Get-SnipeItManufacturer -search HP
|
||||
```
|
||||
|
||||
Search all manufacturers for string HP
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Get-SnipeItManufacturer -id 3
|
||||
```
|
||||
|
||||
Returns manufacturer with id 3
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -28,23 +28,20 @@ Long description
|
|||
### EXAMPLE 1
|
||||
```
|
||||
New-SnipeItAsset -status_id 1 -model_id 1 -name "Machine1"
|
||||
```
|
||||
|
||||
Create asset with automatic tag if tag genaration is enabled on snipe-it, other wise without tag
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
New-SnipeItAsset -status_id 1 -model_id 1 -name "Machine1" -asset_tag "DEV123"
|
||||
```
|
||||
|
||||
Specifying asset tag when creating asset
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
```
|
||||
New-SnipeItAsset -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5" = "Windows 10 Pro" }
|
||||
```
|
||||
|
||||
Using customfields when creating asset.
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,8 @@ Creates a new user to Snipe-IT system
|
|||
### EXAMPLE 1
|
||||
```
|
||||
New-SnipeItuser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
|
||||
```
|
||||
|
||||
Creates new a new user who can't login to system
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,14 @@ Checkout specific license seat to user, asset or both
|
|||
### EXAMPLE 1
|
||||
```
|
||||
Set-SnipeItLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 -Verbose
|
||||
```
|
||||
|
||||
Checkout licence to user id 3
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Set-SnipeItLicenceSeat -ID 1 -seat_id 1 -asset_id 3 -Verbose
|
||||
```
|
||||
|
||||
Checkout licence to asset id 3
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,8 @@ Creates a new user to Snipe-IT system
|
|||
### EXAMPLE 1
|
||||
```
|
||||
Update-SnipeItUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
|
||||
```
|
||||
|
||||
Updates user with id 3
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ Gets a list of Snipe-it Accessories
|
|||
### [Get-SnipeItAccessoryOwner](Get-SnipeItAccessoryOwner.md)
|
||||
Get list of checked out accessories
|
||||
|
||||
### [Get-SnipeItActivity](Get-SnipeItActivity.md)
|
||||
Gets and search Snipe-it Activity history
|
||||
|
||||
### [Get-SnipeItAsset](Get-SnipeItAsset.md)
|
||||
Gets a list of Snipe-it Assets or specific asset
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue