mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 01:42:29 +00:00
alias check for every public function
This commit is contained in:
parent
ccbe86c2c9
commit
cdc60fbeaa
45 changed files with 97 additions and 3 deletions
13
SnipeitPS/Private/Test-SnipeItAlias.ps1
Normal file
13
SnipeitPS/Private/Test-SnipeItAlias.ps1
Normal 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."
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = @{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ function New-SnipeItAsset()
|
|||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ function New-SnipeItAudit()
|
|||
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"location_id" = $location_id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ function New-SnipeItManufacturer()
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ function Remove-SnipeItAsset ()
|
|||
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"ID" = $Name
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ function Remove-SnipeItAssetMaintenance {
|
|||
$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"ID" = $ID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ function Remove-SnipeItUser ()
|
|||
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"ID" = $ID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ function Reset-SnipeItAssetOwner() {
|
|||
[string]$apiKey
|
||||
)
|
||||
|
||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = @{
|
||||
"notes" = $notes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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)}
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
|
|||
}
|
||||
|
||||
#Create unprefixed aliases
|
||||
Set-SnipeItAlias -Verbose
|
||||
Set-SnipeItAlias
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue