alias check for every public function

This commit is contained in:
Petri Asikainen 2021-05-23 19:23:24 +03:00
parent ccbe86c2c9
commit cdc60fbeaa
45 changed files with 97 additions and 3 deletions

View file

@ -0,0 +1,13 @@
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."
}
}

View file

@ -63,6 +63,7 @@ function Get-SnipeItAccessory() {
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

View file

@ -118,6 +118,7 @@ function Get-SnipeItAsset() {
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

View file

@ -62,6 +62,8 @@ function Get-SnipeItAssetMaintenance() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Parameters = @{

View file

@ -53,6 +53,7 @@ function Get-SnipeItCategory()
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

View file

@ -55,6 +55,8 @@ function Get-SnipeItCompany()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/companies"

View file

@ -68,6 +68,8 @@ function Get-SnipeItComponent() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/components"

View file

@ -28,6 +28,8 @@ function Get-SnipeItCustomField()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) {
$apiurl= "$url/api/v1/fields/$id"
} else {

View file

@ -60,6 +60,8 @@ function Get-SnipeItDepartment()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/departments"

View file

@ -30,6 +30,8 @@ function Get-SnipeItFieldset() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) {
$apiurl = "$url/api/v1/fieldsets/$id"
} else {

View file

@ -79,6 +79,8 @@ function Get-SnipeItLicense() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/licenses"

View file

@ -54,6 +54,8 @@ function Get-SnipeitLocation()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/locations"

View file

@ -56,6 +56,8 @@ function Get-SnipeItManufacturer()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/manufacturers"

View file

@ -54,6 +54,8 @@ function Get-SnipeItModel()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/models"

View file

@ -54,6 +54,8 @@ function Get-SnipeItStatus()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/statuslabels"

View file

@ -54,6 +54,8 @@ function Get-SnipeItSupplier()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/suppliers"

View file

@ -76,6 +76,8 @@ function Get-SnipeItUser() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$apiurl = "$url/api/v1/users"

View file

@ -102,6 +102,8 @@ function New-SnipeItAccessory() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['purchase_date']) {

View file

@ -123,6 +123,8 @@ function New-SnipeItAsset()
[hashtable] $customfields
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters

View file

@ -77,6 +77,8 @@ function New-SnipeItAssetMaintenance() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['start_date']) {

View file

@ -37,6 +37,8 @@ function New-SnipeItAudit()
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"location_id" = $location_id
}

View file

@ -55,6 +55,8 @@ function New-SnipeItCategory()
[switch]$checkin_email
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"name" = $name
"category_type" = $category_type

View file

@ -37,6 +37,8 @@ function New-SnipeItCompany()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -67,6 +67,8 @@ function New-SnipeItComponent() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['purchase_date']) {

View file

@ -46,6 +46,8 @@ function New-SnipeItCustomField()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
#Convert Values to JSON format

View file

@ -53,6 +53,8 @@ function New-SnipeItDepartment() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -124,6 +124,8 @@ function New-SnipeItLicense() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['expiration_date']) {

View file

@ -78,6 +78,8 @@ function New-SnipeItLocation() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -36,6 +36,7 @@ function New-SnipeItManufacturer()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"name" = $Name

View file

@ -61,6 +61,8 @@ function New-SnipeItModel()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
name = $name
category_id = $category_id

View file

@ -109,6 +109,8 @@ function New-SnipeItUser() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($password ) {

View file

@ -32,6 +32,8 @@ function Remove-SnipeItAsset ()
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $Name
}

View file

@ -36,6 +36,8 @@ function Remove-SnipeItAssetMaintenance {
$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $ID
}

View file

@ -33,6 +33,8 @@ function Remove-SnipeItUser ()
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $ID
}

View file

@ -48,6 +48,8 @@ function Reset-SnipeItAssetOwner() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"notes" = $notes
}

View file

@ -99,6 +99,8 @@ function Set-SnipeItAccessory() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['purchase_date']) {

View file

@ -114,6 +114,8 @@ function Set-SnipeItAsset()
[hashtable] $customfields
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($model_id) { $Values.Add('model_id',$model_id)}

View file

@ -65,6 +65,8 @@ function Set-SnipeItAssetOwner()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($Values['expected_checkin']) {

View file

@ -69,6 +69,8 @@ function Set-SnipeItComponent()
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['purchase_date']) {

View file

@ -23,7 +23,7 @@ function Set-SnipeItInfo {
)
BEGIN {
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
function Add-DefaultParameter {
param(
[Parameter(Mandatory = $true)]
@ -43,6 +43,7 @@ function Set-SnipeItInfo {
# http://stackoverflow.com/questions/30427110/set-psdefaultparametersvalues-for-use-within-module-scope
$PSDefaultParameterValues["${command}:${parameter}"] = $Value
$global:PSDefaultParameterValues["${command}:${parameter}"] = $Value
}
}

View file

@ -129,7 +129,9 @@ function Set-SnipeItLicense() {
[string]$apiKey
)
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
if ($values['expiration_date']) {
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")

View file

@ -82,6 +82,8 @@ function Set-SnipeitLocation() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -66,6 +66,8 @@ function Set-SnipeItModel() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -104,6 +104,8 @@ function Set-SnipeItUser() {
[string]$apiKey
)
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
$Body = $Values | ConvertTo-Json;

View file

@ -15,4 +15,4 @@ Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
}
#Create unprefixed aliases
Set-SnipeItAlias -Verbose
Set-SnipeItAlias