Skip to content

Commit

Permalink
Merge pull request #119 from snazy2000/develop
Browse files Browse the repository at this point in the history
First 1.2 version
  • Loading branch information
PetriAsi authored May 24, 2021
2 parents c5e02c8 + 575a17c commit 5934568
Show file tree
Hide file tree
Showing 97 changed files with 1,888 additions and 603 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ 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.2.x] - 2021-05-24

## Prefixing SnipeItPS

### New Features
All commands are now prefixed like Set-Info -> Set-SnipeItInfo.
To keep compatibility all old commands are available as aliases.
To update existing scripts theres Update-SnipeItAlias command.

### New fuctions
- Update-SnipeitAlias Tool to update existing scripts
- Get-SnipeItLicenceSeat lists license seats
- Set-SnipeItLicenseSeat Set and checkouts/in license seats
Licenseseat api is supported from Snipe-It release => v5.1.5

### New fixes
Added -id parameter support to support Get-SnipeItCustomField and
Get-SnipeItFieldSet commands

# [v1.1.x] - 2021-05-18

## Pull request rollup release. Lots of new features including:
Expand Down
38 changes: 38 additions & 0 deletions SnipeitPS/Private/Get-SnipeItAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Function Get-SnipeItAlias(){
@{'Get-Asset' = 'Get-SnipeItAsset';
'Get-AssetMaintenance' = 'Get-SnipeItAssetMaintenance';
'Get-Category' = 'Get-SnipeItCategory';
'Get-Company' = 'Get-SnipeItCompany';
'Get-Component' = 'Get-SnipeItCompany';
'Get-CustomField' = 'Get-SnipeItCustomField';
'Get-Department' = 'Get-SnipeItDepartment';
'Get-Fieldset' = 'Get-SnipeItFieldset';
'Get-Manufacturer' = 'Get-SnipeItManufacturer';
'Get-Model' = 'Get-SnipeItModel';
'Get-Status' = 'Get-SnipeItStatus';
'Get-Supplier' = 'Get-SnipeItSupplier';
'Get-User' = 'Get-SnipeItUser';
'New-Asset' = 'New-SnipeItAsset';
'New-AssetMaintenance' = 'New-SnipeItAssetMaintenance';
'New-Category' = 'New-SnipeItCategory';
'New-Component' = 'New-SnipeItComponent';
'New-CustomField' = 'New-SnipeItCustomField';
'New-Department' = 'New-SnipeItDepartment';
'New-License' = 'New-SnipeItLicense';
'Set-License' = 'Set-SnipeItLicense';
'New-Location' = 'New-SnipeItLocation';
'New-Manufacturer' = 'New-SnipeItManufacturer';
'New-Model' = 'New-SnipeItModel';
'New-User' = 'New-SnipeItUser';
'Set-Asset' = 'Set-SnipeItAsset';
'Set-AssetOwner' = 'Set-SnipeItAssetOwner';
'Set-Component' = 'Set-SnipeItComponent';
'Set-Model' = 'Set-SnipeItModel';
'Set-Info' = 'Set-SnipeItInfo';
'Set-User' = 'Set-SnipeItUser';
'New-Accessory' = 'New-SnipeItAccessory';
'Set-Accessory' = 'Set-SnipeItAccessory';
'Get-Accessory' = 'Get-SnipeItAccessory';
'Remove-Asset' = 'Remove-SnipeItAsset';
'Remove-User' = 'Remove-SnipeItUser';}
}
18 changes: 18 additions & 0 deletions SnipeitPS/Private/Set-SnipeItAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function Set-SnipeItAlias()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
param()
Write-Verbose "Setting compatibility aliases.. "
Write-Verbose "All aliases are deprediated."
$SnipeItAliases = get-SnipeItAlias
ForEach ($key in $SnipeItAliases.Keys ) {
New-Alias -Name $key -Value $($SnipeItAliases[$key]) -Scope 1
Write-Verbose ("{0,5} -> {1}" -f $key,$($SnipeItAliases[$key]))
}
Write-Verbose "Please start using native 'SnipeIt' prfixed functions instead."
Get-Command -Module SnipeItPS -CommandType Alias | Select-Object -Property DisplayName,ResolvedCommand

}
15 changes: 15 additions & 0 deletions SnipeitPS/Private/Test-SnipeItAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function Test-SnipeItAlias()
{
[CmdletBinding()]
param(
[parameter(mandatory = $true)]
[string]$invocationName,
[parameter(mandatory = $true)]
[string]$commandName
)
if($invocationName -ne $commandName) {
Write-Warning "$invocationName is still working, but it has been superceded by $commandName, please use it instead."
Write-Warning 'To update your scripts you can use Update-SnipeItAlias helper function: '
Write-Warning '"Get-Content [your-script.ps1] | Update-SnipeItAlias | Out-File [new-script-name.ps1]"'
}
}
36 changes: 0 additions & 36 deletions SnipeitPS/Public/Get-CustomField.ps1

This file was deleted.

37 changes: 0 additions & 37 deletions SnipeitPS/Public/Get-Fieldset.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ Result offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
URL of Snipeit system, can be set using Set-Info command
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-Info command
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Get-Accessory -search Keyboard
Get-SnipeItAccessory -search Keyboard
.EXAMPLE
Get-Accessory -id 1
Get-SnipeItAccessory -id 1
#>

function Get-Accessory() {
function Get-SnipeItAccessory() {
Param(
[string]$search,

Expand Down Expand Up @@ -63,6 +63,7 @@ function Get-Accessory() {
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name

$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

Expand All @@ -81,7 +82,7 @@ function Get-Accessory() {
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-Accessory @callargs
$res=Get-SnipeItAccessory @callargs
$res
if ($res.count -lt $limit) {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,29 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
URL of Snipeit system, can be set using Set-Info command
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-Info command
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Get-Asset -url "https://assets.example.com"-token "token..."
Get-SnipeItAsset -url "https://assets.example.com"-token "token..."
.EXAMPLE
Get-Asset -search "myMachine"-url "https://assets.example.com"-token "token..."
Get-SnipeItAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
.EXAMPLE
Get-Asset -search "myMachine"-url "https://assets.example.com"-token "token..."
Get-SnipeItAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
.EXAMPLE
Get-Asset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
Get-SnipeItAsset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
#>

function Get-Asset() {
function Get-SnipeItAsset() {
Param(
[string]$search,

[string]$id,
[int]$id,

[string]$asset_tag,

Expand Down Expand Up @@ -118,6 +118,7 @@ function Get-Asset() {
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name

$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

Expand Down Expand Up @@ -164,7 +165,7 @@ function Get-Asset() {
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-Asset @callargs
$res=Get-SnipeItAsset @callargs
$res
if ( $res.count -lt $limit) {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
URL of Snipeit system, can be set using Set-Info command
URL of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-Info command
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Get-AssetMaintenances -url "https://assets.example.com" -token "token..."
Get-SnipeItAssetMaintenances -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-AssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
Get-SnipeItAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-AssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
Get-SnipeItAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
#>
function Get-AssetMaintenance() {
function Get-SnipeItAssetMaintenance() {
Param(
[string]$search,

Expand All @@ -62,6 +62,8 @@ function Get-AssetMaintenance() {
[string]$apiKey
)

Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name

$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

$Parameters = @{
Expand All @@ -79,7 +81,7 @@ function Get-AssetMaintenance() {
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-AssetMaintenance @callargs
$res=Get-SnipeItAssetMaintenance @callargs
$res
if ($res.count -lt $limit) {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Url of Snipeit system, can be set using Set-Info command
Url of Snipeit system, can be set using Set-SnipeItInfo command
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-Info command
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
.EXAMPLE
Get-Category -id 1
Get-SnipeItCategory -id 1
.EXAMPLE
Get-Category -search "Laptop"
Get-SnipeItCategory -search "Laptop"
#>

function Get-Category()
function Get-SnipeItCategory()
{
Param(
[string]$search,

[string]$id,
[int]$id,

[ValidateSet("asc", "desc")]
[string]$order = "desc",
Expand All @@ -53,6 +53,7 @@ function Get-Category()
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name

$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

Expand Down Expand Up @@ -81,7 +82,7 @@ function Get-Category()
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-Category @callargs
$res=Get-SnipeItCategory @callargs
$res
if ($res.count -lt $limit) {
break
Expand Down
Loading

0 comments on commit 5934568

Please sign in to comment.