diff --git a/CHANGELOG.md b/CHANGELOG.md index e2abdaf..47069fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ 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/). +# [v.1.10.x] - 2021-09-03 + +## New secure ways to connect Snipe it + +### -secureApiKey allow pass apiKey as SecureString +Connect-SnipeitPS -URL 'https://asset.example.com' -secureApiKey 'tokenKey' + +### Set connection with safely saved credentials, first save credentials +$SnipeCred= Get-Credential -message "Use url as username and apikey as password" +$SnipeCred | Export-CliXml snipecred.xml + +### ..then use your saved credentials like +Connect-SnipeitPS -siteCred (Import-CliXml snipecred.xml) + +## Fix for content encoding in invoke-snipeitmethod +Version 1.9 introduced bug that converted non ascii characters to ascii +during request. + # [v.1.9.x] - 2021-07-14 ## Image uploads diff --git a/README.md b/README.md index 294f257..7d18afd 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,23 @@ Install-Module SnipeitPS # Check for updates occasionally: Update-Module SnipeitPS -# To use each session: +# import module to session: Import-Module SnipeitPS -Set-SnipeitInfo -URL 'https://asset.example.com' -apiKey 'tokenKey' + +# Set connection +Connect-SnipeitPS -URL 'https://asset.example.com' -apiKey 'tokenKey' + +# Or set connection with safely saved credentials, first save credentials +$SnipeCred =Get-Credential -message "Use url as username and apikey as password" +$SnipeCred | Export-CliXml snipecred.xml + +# ..then use your saved credentials like +Connect-SnipeitPS -siteCred (Import-CliXml snipecred.xml) + +# OR use -secureApiKey that allow pass apiKey as SecureString +# if you are usin Microsoft.PowerShell.SecretManagement or like +Connect-SnipeitPS -URL 'https://asset.example.com' -secureApiKey 'tokenKey' + ``` ### Usage diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 075a41a..6d67bcc 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -1,31 +1,54 @@ -function Invoke-SnipeitMethod { - <# +<# .SYNOPSIS - Extracted invokation of the REST method to own function. - #> + Make api request to Snipe it + + .PARAMETER Api + Api part of url. prefix with slash ie. "/api/v1/hardware" + + .PARAMETER Method + Method of the invokation, one of following "GET", "POST", "PUT", "PATCH" or "DELETE" + + .PARAMETER Body + Request body as hashtable. Needed for post, put and patch + + .PARAMETER GetParameters + Get-Parameters as hastable. +#> + +function Invoke-SnipeitMethod { [OutputType( [PSObject] )] - param ( - # REST API to invoke - [Parameter(Mandatory = $true)] - [Uri]$URi, - # Method of the invokation + param ( + + [Parameter(Mandatory = $true)] + [string]$Api, + [ValidateSet("GET", "POST", "PUT", "PATCH", "DELETE")] [string]$Method = "GET", - # Body of the request [Hashtable]$Body, - [string] $Token, - - # GET Parameters [Hashtable]$GetParameters - ) BEGIN { + #use legacy per command based url and apikey + if ( $null -ne $SnipeitPSSession.legacyUrl -and $null -ne $SnipeitPSSession.legacyApiKey ) { + [string]$Url = $SnipeitPSSession.legacyUrl + Write-Debug "Invoke-SnipeitMethod url: $Url" + $Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.legacyApiKey + + } elseif ($null -ne $SnipeitPSSession.url -and $null -ne $SnipeitPSSession.apiKey) { + [string]$Url = $SnipeitPSSession.url + Write-Debug "Invoke-SnipeitMethod url: $Url" + $Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.apiKey + + } else { + throw "Please use Connect-SnipeitPS to setup connection before any other commands." + } + # Validation of parameters if (($Method -in ("POST", "PUT", "PATCH")) -and (!($Body))) { $message = "The following parameters are required when using the ${Method} parameter: Body." @@ -33,35 +56,36 @@ Throw $exception } + #Build request uri + $apiUri = "$Url$Api" #To support images "image" property have be handled before this $_headers = @{ - "Authorization" = "Bearer $($token)" + "Authorization" = "Bearer $($Token)" 'Content-Type' = 'application/json; charset=utf-8' "Accept" = "application/json" } } Process { - if ($GetParameters -and ($URi -notlike "*\?*")) - { + # This can be done using $Body, maybe some day - PetriAsi + if ($GetParameters -and ($apiUri -notlike "*\?*")){ Write-Debug "Using `$GetParameters: $($GetParameters | Out-String)" - [string]$URI += (ConvertTo-GetParameter $GetParameters) + [string]$apiUri = $apiUri + (ConvertTo-GetParameter $GetParameters) # Prevent recursive appends $GetParameters = $null } # set mandatory parameters $splatParameters = @{ - Uri = $URi + Uri = $apiUri Method = $Method Headers = $_headers UseBasicParsing = $true ErrorAction = 'SilentlyContinue' } - # Place holder for intended image manipulation - # if and when snipe it API gets support for images + # Send image requests as multipart/form-data if supported if($null -ne $body -and $Body.Keys -contains 'image' ){ if($PSVersionTable.PSVersion -ge '7.0'){ $Body['image'] = get-item $body['image'] @@ -71,15 +95,15 @@ $splatParameters["Method"] = 'POST' $splatParameters["Form"] = $Body } else { - # use base64 encoded images for powershell version < 7 - Add-Type -AssemblyName "System.Web" - $mimetype = [System.Web.MimeMapping]::GetMimeMapping($body['image']) - $Body['image'] = 'data:@'+$mimetype+';base64,'+[Convert]::ToBase64String([IO.File]::ReadAllBytes($Body['image'])) + # use base64 encoded images for powershell version < 7 + Add-Type -AssemblyName "System.Web" + $mimetype = [System.Web.MimeMapping]::GetMimeMapping($body['image']) + $Body['image'] = 'data:@'+$mimetype+';base64,'+[Convert]::ToBase64String([IO.File]::ReadAllBytes($Body['image'])) } } if ($Body -and $splatParameters.Keys -notcontains 'Form') { - $splatParameters["Body"] = $Body | Convertto-Json + $splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes(($Body | Convertto-Json)) } $script:PSDefaultParameterValues = $global:PSDefaultParameterValues @@ -105,18 +129,16 @@ if ($webResponse) { Write-Verbose $webResponse - # API returned a Content: lets work wit it + # API returned a Content: lets work with it try{ - if ($webResponse.status -eq "error") { - Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received from; resolving" + Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received ... resolving" # This could be handled nicely in an function such as: # ResolveError $response -WriteError Write-Error $($webResponse.messages | Out-String) - } - else { + } else { #update operations return payload - if ($webResponse.payload){ + if ($webResponse.payload) { $result = $webResponse.payload } #Search operations return rows @@ -124,7 +146,7 @@ $result = $webResponse.rows } #Remove operations returns status and message - elseif ($webResponse.status -eq 'success'){ + elseif ($webResponse.status -eq 'success') { $result = $webResponse.payload } #Search and query result with no results @@ -140,9 +162,6 @@ Write-Verbose "Messages: $($webResponse.messages)" $result - - - } } catch { @@ -151,7 +170,7 @@ } elseif ($webResponse.StatusCode -eq "Unauthorized") { - Write-Error "[$($MyInvocation.MyCommand.Name)] You are not Authorized to access the resource, check your token is correct" + Write-Error "[$($MyInvocation.MyCommand.Name)] You are not Authorized to access the resource, check your apiKey is correct" } else { # No content, although statusCode < 400 @@ -169,3 +188,4 @@ Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended" } } + diff --git a/SnipeitPS/Private/Reset-SnipeitPSLegacyApi.ps1 b/SnipeitPS/Private/Reset-SnipeitPSLegacyApi.ps1 new file mode 100644 index 0000000..c4508c3 --- /dev/null +++ b/SnipeitPS/Private/Reset-SnipeitPSLegacyApi.ps1 @@ -0,0 +1,16 @@ +function Reset-SnipeitPSLegacyApi { + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + param( + ) + process { + Write-Verbose 'Reset-SnipeitPSLegacyApi' + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $SnipeitPSSession.legacyUrl = $null + $SnipeitPSSession.legacyApiKey = $null + + } + } +} diff --git a/SnipeitPS/Private/Set-SnipeitPSLegacyApiKey.ps1 b/SnipeitPS/Private/Set-SnipeitPSLegacyApiKey.ps1 new file mode 100644 index 0000000..1568b30 --- /dev/null +++ b/SnipeitPS/Private/Set-SnipeitPSLegacyApiKey.ps1 @@ -0,0 +1,14 @@ +function Set-SnipeitPSLegacyApiKey { + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + param( + [string]$apiKey + ) + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $SnipeitPSSession.legacyApiKey = ConvertTo-SecureString -AsPlainText -String $apiKey + } + } +} diff --git a/SnipeitPS/Private/Set-SnipeitPSLegacyUrl.ps1 b/SnipeitPS/Private/Set-SnipeitPSLegacyUrl.ps1 new file mode 100644 index 0000000..0b08778 --- /dev/null +++ b/SnipeitPS/Private/Set-SnipeitPSLegacyUrl.ps1 @@ -0,0 +1,14 @@ +function Set-SnipeitPSLegacyUrl { + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + param( + $url + ) + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $SnipeitPSSession.legacyUrl = $url.TrimEnd('/') + } + } +} diff --git a/SnipeitPS/Private/Test-SnipeitPSConnection.ps1 b/SnipeitPS/Private/Test-SnipeitPSConnection.ps1 new file mode 100644 index 0000000..ba0a8f2 --- /dev/null +++ b/SnipeitPS/Private/Test-SnipeitPSConnection.ps1 @@ -0,0 +1,18 @@ +function Test-SnipeitPSConnection { + #test api connection + $Parameters = @{ + Api = '/api/v1/statuslabels' + Method = 'Get' + GetParameters = @{'limit'=1} + } + Write-Verbose "Testing connection to $($SnipeitPSSession.url)." + + $contest = Invoke-SnipeitMethod @Parameters + + if ( $contest) { + Write-Verbose "Connection to $($SnipeitPSSession.url) tested succesfully." + return $true + } else { + return $false + } +} diff --git a/SnipeitPS/Public/Connect-SnipeitPS.ps1 b/SnipeitPS/Public/Connect-SnipeitPS.ps1 new file mode 100644 index 0000000..8646189 --- /dev/null +++ b/SnipeitPS/Public/Connect-SnipeitPS.ps1 @@ -0,0 +1,93 @@ +<# + .SYNOPSIS + Sets authetication information + + .DESCRIPTION + Sets apikey and url to connect Snipe-It system. + Based on Set-SnipeitInfo command, what is now just compatibility wrapper + and calls Connect-SnipeitPS + + .PARAMETER url + URL of Snipeit system. + + .PARAMETER apiKey + User's API Key for Snipeit. + + .PARAMETER secureApiKey + Snipe it Api key as securestring + + .PARAMETER siteCred + PSCredential where username shoul be snipe it url and password should be + snipe it apikey. + + .EXAMPLE + Connect-SnipeitPS -Url $url -apiKey $myapikey + Connect to Snipe it api. + + .EXAMPLE + Connect-SnipeitPS -Url $url -SecureApiKey $myapikey + Connects to Snipe it api with apikey stored to securestring + + .EXAMPLE + Connect-SnipeitPS -siteCred (Get-Credential -message "Use site url as username and apikey as password") + Connect to Snipe It with PSCredential object. + To use saved creadentials yu can use export-clixml and import-clixml commandlets. + + .EXAMPLE + Build credential with apikey value from secret vault (Microsoft.PowerShell.SecretManagement) + $siteurl = "https://mysnipeitsite.url" + $apikey = Get-SecretInfo -Name SnipeItApiKey + $siteCred = New-Object -Type PSCredential -Argumentlist $siteurl,$spikey + Connect-SnipeitPS -siteCred $siteCred + + + +#> +function Connect-SnipeitPS { + [CmdletBinding( + DefaultParameterSetName = 'Connect with url and apikey' + )] + [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] + + param ( + [Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$true)] + [Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$true)] + [Uri]$url, + + [Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$true)] + [String]$apiKey, + + [Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$true)] + [SecureString]$secureApiKey, + + [Parameter(ParameterSetName='Connect with credential',Mandatory=$true)] + [PSCredential]$siteCred + ) + + + PROCESS { + switch ($PsCmdlet.ParameterSetName) { + 'Connect with url and apikey' { + $SnipeitPSSession.url = $url.AbsoluteUri.TrimEnd('/') + $SnipeitPSSession.apiKey = ConvertTo-SecureString -AsPlainText -String $apiKey + } + + 'Connect with url and secure apikey' { + $SnipeitPSSession.url = $url.AbsoluteUri.TrimEnd('/') + $SnipeitPSSession.apiKey = $secureApiKey + } + + 'Connect with credential' { + $SnipeitPSSession.url = ($siteCred.GetNetworkCredential().UserName).TrimEnd('/') + $SnipeitPSSession.apiKey = $siteCred.GetNetworkCredential().SecurePassword + } + } + + Write-Debug "Site-url $($SnipeitPSSession.url)" + Write-Debug "Site apikey: $($SnipeitPSSession.apiKey)" + + if (-not (Test-SnipeitPSConnection)) { + throw "Cannot verify connection to snipe it. For the start try to check url and provided apikey or credential parameters" + } + } +} diff --git a/SnipeitPS/Public/Get-SnipeitAccessory.ps1 b/SnipeitPS/Public/Get-SnipeitAccessory.ps1 index 1a84a71..0e0aff8 100644 --- a/SnipeitPS/Public/Get-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAccessory.ps1 @@ -21,10 +21,10 @@ 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-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitAccessory -search Keyboard @@ -79,47 +79,67 @@ function Get-SnipeitAccessory() { [parameter(ParameterSetName='Accessories checked out to user id')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - switch($PsCmdlet.ParameterSetName) { - 'Search' {$apiurl = "$url/api/v1/accessories"} - 'Get by ID' {$apiurl= "$url/api/v1/accessories/$id"} - 'Accessories checked out to user id' {$apiurl = "$url/api/v1/users/$user_id/accessories"} - } - - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Parameters = @{ - Uri = $apiurl - 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-SnipeitAccessory @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + switch($PsCmdlet.ParameterSetName) { + 'Search' {$api = "/api/v1/accessories"} + 'Get by ID' {$api= "/api/v1/accessories/$id"} + 'Accessories checked out to user id' {$api = "/api/v1/users/$user_id/accessories"} + } + + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitAccessory @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitAccessoryOwner.ps1 b/SnipeitPS/Public/Get-SnipeitAccessoryOwner.ps1 index b9a8177..70965d8 100644 --- a/SnipeitPS/Public/Get-SnipeitAccessoryOwner.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAccessoryOwner.ps1 @@ -8,16 +8,15 @@ Unique ID For accessory to list .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Get-SnipeitAccessoryOwner -id 1 #> -function Get-SnipeitAccessoryOwner() -{ +function Get-SnipeitAccessoryOwner() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -27,23 +26,39 @@ function Get-SnipeitAccessoryOwner() [parameter(mandatory = $true)] [int]$id, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + $Parameters = @{ + Api = "/api/v1/accessories/$id/checkedout" + Method = 'GET' + } - $Parameters = @{ - Uri = "$url/api/v1/accessories/$id/checkedout" - Method = 'GET' - Token = $apiKey + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - return $result } diff --git a/SnipeitPS/Public/Get-SnipeitActivity.ps1 b/SnipeitPS/Public/Get-SnipeitActivity.ps1 index 5a6806a..133779c 100644 --- a/SnipeitPS/Public/Get-SnipeitActivity.ps1 +++ b/SnipeitPS/Public/Get-SnipeitActivity.ps1 @@ -30,10 +30,10 @@ 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-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitAccessory -search Keyboard @@ -71,51 +71,70 @@ function Get-SnipeitActivity() { [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [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 -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - - $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 + begin { + 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 -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + + $Parameters = @{ + Api = "/api/v1/reports/activity" + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + 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 + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitAsset.ps1 b/SnipeitPS/Public/Get-SnipeitAsset.ps1 index ac38bcb..d1bd734 100644 --- a/SnipeitPS/Public/Get-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAsset.ps1 @@ -60,13 +60,13 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE -Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..." +Get-SnipeitAsset -all Returens all assets .EXAMPLE @@ -199,56 +199,75 @@ function Get-SnipeitAsset() { [parameter(ParameterSetName='Assets with component id')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - switch ($PsCmdlet.ParameterSetName) { - 'Search' { $apiurl = "$url/api/v1/hardware" } - 'Get with id' {$apiurl= "$url/api/v1/hardware/$id"} - 'Get with asset tag' {$apiurl= "$url/api/v1/hardware/bytag/$asset_tag"} - 'Get with serial' { $apiurl= "$url/api/v1/hardware/byserial/$serial"} - 'Assets due auditing soon' {$apiurl = "$url/api/v1/hardware/audit/due"} - 'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"} - 'Assets checked out to user id'{$apiurl = "$url/api/v1/users/$user_id/assets"} - 'Assets with component id' {$apiurl = "$url/api/v1/components/$component_id/assets"} - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - GetParameters = $SearchParameter - Token = $apiKey - } - - if ($all) { - $offstart = $(if ($offset){$offset} Else {0}) - $callargs = $SearchParameter - Write-Verbose "Callargs: $($callargs | convertto-json)" - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitAsset @callargs - $res - if ( $res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + switch ($PsCmdlet.ParameterSetName) { + 'Search' { $api = "/api/v1/hardware" } + 'Get with id' {$api= "/api/v1/hardware/$id"} + 'Get with asset tag' {$api= "/api/v1/hardware/bytag/$asset_tag"} + 'Get with serial' { $api= "/api/v1/hardware/byserial/$serial"} + 'Assets due auditing soon' {$api = "/api/v1/hardware/audit/due"} + 'Assets overdue for auditing' {$api = "/api/v1/hardware/audit/overdue"} + 'Assets checked out to user id'{$api = "/api/v1/users/$user_id/assets"} + 'Assets with component id' {$api = "/api/v1/components/$component_id/assets"} + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + Write-Verbose "Callargs: $($callargs | convertto-json)" + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitAsset @callargs + $res + if ( $res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Get-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/Get-SnipeitAssetMaintenance.ps1 index 9476f51..e07dcc9 100644 --- a/SnipeitPS/Public/Get-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAssetMaintenance.ps1 @@ -24,19 +24,18 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE -Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..." +Get-SnipeitAssetMaintenances +.EXAMPLE +Get-SnipeitAssetMaintenances -search "myMachine" .EXAMPLE -Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..." - -.EXAMPLE -Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..." +Get-SnipeitAssetMaintenances -search "myMachine" #> function Get-SnipeitAssetMaintenance() { Param( @@ -55,42 +54,61 @@ function Get-SnipeitAssetMaintenance() { [int]$offset, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Parameters = @{ + Api = "/api/v1/maintenances" + Method = 'Get' + GetParameters = $SearchParameter + } - $Parameters = @{ - Uri = "$url/api/v1/maintenances" - Method = 'Get' - GetParameters = $SearchParameter - Token = $apiKey + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitAssetMaintenance @callargs - $res - if ($res.count -lt $limit) { - break + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitAssetMaintenance @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit } - $offstart = $offstart + $limit + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitCategory.ps1 b/SnipeitPS/Public/Get-SnipeitCategory.ps1 index eb82103..1c41d4b 100644 --- a/SnipeitPS/Public/Get-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Get-SnipeitCategory.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -Url of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Url of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitCategory -id 1 @@ -31,8 +31,7 @@ Get-SnipeitCategory -search "Laptop" #> -function Get-SnipeitCategory() -{ +function Get-SnipeitCategory() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -54,50 +53,70 @@ function Get-SnipeitCategory() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $apiurl = "$url/api/v1/categories" + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } + $api = "/api/v1/categories" - if ($id) { - $apiurl= "$url/api/v1/categories/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitCategory @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/categories/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitCategory @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitCompany.ps1 b/SnipeitPS/Public/Get-SnipeitCompany.ps1 index 31b6b74..98237ac 100644 --- a/SnipeitPS/Public/Get-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Get-SnipeitCompany.ps1 @@ -17,10 +17,10 @@ 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 +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitCompany @@ -32,8 +32,7 @@ Gets specific company #> -function Get-SnipeitCompany() -{ +function Get-SnipeitCompany() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -55,51 +54,70 @@ function Get-SnipeitCompany() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory=$true)] + [parameter(mandatory=$false)] [string]$url, - [parameter(mandatory=$true)] + [parameter(mandatory=$false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $apiurl = "$url/api/v1/companies" + $api = "/api/v1/companies" - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/companies/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitCompany @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/companies/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitCompany @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitComponent.ps1 b/SnipeitPS/Public/Get-SnipeitComponent.ps1 index 5681b3d..4c6913c 100644 --- a/SnipeitPS/Public/Get-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Get-SnipeitComponent.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system,can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitComponent @@ -71,51 +71,71 @@ function Get-SnipeitComponent() { [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $apiurl = "$url/api/v1/components" + $api = "/api/v1/components" - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/components/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitComponent @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/components/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitComponent @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitConsumable.ps1 b/SnipeitPS/Public/Get-SnipeitConsumable.ps1 index ae8b2aa..644243b 100644 --- a/SnipeitPS/Public/Get-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Get-SnipeitConsumable.ps1 @@ -36,10 +36,10 @@ Offset to use A return all results .PARAMETER url -URL of Snipeit system,can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitConsumable -all @@ -96,29 +96,38 @@ function Get-SnipeitConsumable() { [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } process { switch ($PSCmdlet.ParameterSetName) { 'Search' { $Parameters = @{ - Uri = "$url/api/v1/consumables" + Api = "/api/v1/consumables" Method = 'Get' - Token = $apiKey GetParameters = $SearchParameter } if ($all) { - $offstart = $(if($offset){$offset} Else {0}) + $offstart = $(if ($offset) {$offset} Else {0}) $callargs = $SearchParameter $callargs.Remove('all') @@ -141,16 +150,23 @@ function Get-SnipeitConsumable() { 'Get with ID' { foreach($consumable_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/consumables/$consumable_id" + Api = "$url/api/v1/consumables/$consumable_id" Method = 'Get' - Token = $apiKey GetParameters = $SearchParameter } + $result = Invoke-SnipeitMethod @Parameters $result } } } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Get-SnipeitCustomField.ps1 b/SnipeitPS/Public/Get-SnipeitCustomField.ps1 index f15db57..f83429c 100644 --- a/SnipeitPS/Public/Get-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Get-SnipeitCustomField.ps1 @@ -6,44 +6,67 @@ A id of specific field .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE - Get-SnipeitCustomField -url "https://assets.example.com" -token "token..." + Get-SnipeitCustomField + Get all custom fields + + .EXAMPLE + Get-SnipeitCustomField -id 1 + Get custom field with ID 1 + #> -function Get-SnipeitCustomField() -{ +function Get-SnipeitCustomField() { Param( [int]$id, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - if ($id) { - $apiurl= "$url/api/v1/fields/$id" - } else { - $apiurl = "$url/api/v1/fields" + if ($id) { + $api= "/api/v1/fields/$id" + } else { + $api = "/api/v1/fields" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey + process { + $result = Invoke-SnipeitMethod @Parameters + $result } - - $result = Invoke-SnipeitMethod @Parameters - - $result + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Get-SnipeitDepartment.ps1 b/SnipeitPS/Public/Get-SnipeitDepartment.ps1 index cfef1d3..ed0ab81 100644 --- a/SnipeitPS/Public/Get-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Get-SnipeitDepartment.ps1 @@ -18,13 +18,13 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE -Get-SnipeitDepartment -url "https://assets.example.com" -token "token..." +Get-SnipeitDepartment .EXAMPLE Get-SnipeitDepartment -search Department1 @@ -34,8 +34,7 @@ Get-SnipeitDepartment -id 1 #> -function Get-SnipeitDepartment() -{ +function Get-SnipeitDepartment() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -61,52 +60,71 @@ function Get-SnipeitDepartment() [ValidateSet('id', 'name', 'image', 'users_count', 'created_at')] [string]$sort = "created_at", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $apiurl = "$url/api/v1/departments" + $api = "/api/v1/departments" - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/departments/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitDepartment @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/departments/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitDepartment @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitFieldset.ps1 b/SnipeitPS/Public/Get-SnipeitFieldset.ps1 index 3ab6f03..37790c0 100644 --- a/SnipeitPS/Public/Get-SnipeitFieldset.ps1 +++ b/SnipeitPS/Public/Get-SnipeitFieldset.ps1 @@ -6,16 +6,18 @@ Returns a fieldset or list of Snipe-it Fieldsets A id of specific fieldset .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE -Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." +Get-SnipeitFieldset +Get all fieldsets .EXAMPLE -Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Windows" } +Get-SnipeitFieldset | Where-Object {$_.name -eq "Windows" } +Gets fieldset by name #> @@ -23,28 +25,45 @@ function Get-SnipeitFieldset() { Param( [int]$id, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + bagin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + if ($id) { + $api = "/api/v1/fieldsets/$id" + } else { + $api = "/api/v1/fieldsets" + } - if ($id) { - $apiurl = "$url/api/v1/fieldsets/$id" - } else { - $apiurl = "$url/api/v1/fieldsets" + $Parameters = @{ + Api = $api + Method = 'Get' + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } + process { + $result = Invoke-SnipeitMethod @Parameters - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey + $result + } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result = Invoke-SnipeitMethod @Parameters - - $result } diff --git a/SnipeitPS/Public/Get-SnipeitLicense.ps1 b/SnipeitPS/Public/Get-SnipeitLicense.ps1 index ba4a4d9..f739610 100644 --- a/SnipeitPS/Public/Get-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Get-SnipeitLicense.ps1 @@ -19,10 +19,10 @@ A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitLicense -search SomeLicense @@ -98,49 +98,68 @@ function Get-SnipeitLicense() { [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + bagin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - switch($PsCmdlet.ParameterSetName) { - 'Search' {$apiurl = "$url/api/v1/licenses"} - 'Get with ID' {$apiurl= "$url/api/v1/licenses/$id"} - 'Get licenses checked out to user ID' {$apiurl= "$url/api/v1/users/$user_id/licenses"} - 'Get licenses checked out to asset ID' {$apiurl= "$url/api/v1/hardware/$asset_id/licenses"} - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitLicense @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + switch($PsCmdlet.ParameterSetName) { + 'Search' {$api = "/api/v1/licenses"} + 'Get with ID' {$api= "/api/v1/licenses/$id"} + 'Get licenses checked out to user ID' {$api= "/api/v1/users/$user_id/licenses"} + 'Get licenses checked out to asset ID' {$api= "/api/v1/hardware/$asset_id/licenses"} + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitLicense @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Get-SnipeitLicenseSeat.ps1 index ce9fd15..67ad9d2 100644 --- a/SnipeitPS/Public/Get-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Get-SnipeitLicenseSeat.ps1 @@ -22,10 +22,10 @@ A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitLicenseSeat -id 1 @@ -47,49 +47,68 @@ function Get-SnipeitLicenseSeat() { [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $apiurl = "$url/api/v1/licenses/$id/seats" + $api = "/api/v1/licenses/$id/seats" - if ($seat_id) { - $apiurl= "$url/api/v1/licenses/$id/seats/$seat_id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitLicenseSeat @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($seat_id) { + $api= "/api/v1/licenses/$id/seats/$seat_id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitLicenseSeat @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitLocation.ps1 b/SnipeitPS/Public/Get-SnipeitLocation.ps1 index 7bc2b70..1fa5c13 100644 --- a/SnipeitPS/Public/Get-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Get-SnipeitLocation.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitLocation -search Location1 @@ -31,8 +31,7 @@ Get-SnipeitLocation -id 3 #> -function Get-SnipeitLocation() -{ +function Get-SnipeitLocation() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -54,52 +53,71 @@ function Get-SnipeitLocation() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $api = "/api/v1/locations" - $apiurl = "$url/api/v1/locations" - - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/locations/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitLocation @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/locations/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitLocation @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 index ca07641..6512040 100644 --- a/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Get-SnipeitManufacturer.ps1 @@ -18,10 +18,10 @@ A return all results, works with -offset and other parameters .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitManufacturer -search HP @@ -32,8 +32,7 @@ Returns manufacturer with id 3 #> -function Get-SnipeitManufacturer() -{ +function Get-SnipeitManufacturer() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -55,51 +54,70 @@ function Get-SnipeitManufacturer() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $api = "/api/v1/manufacturers" - $apiurl = "$url/api/v1/manufacturers" - - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/manufacturers/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitManufacturer @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/manufacturers/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitManufacturer @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitModel.ps1 b/SnipeitPS/Public/Get-SnipeitModel.ps1 index 38132c4..d28f4ea 100644 --- a/SnipeitPS/Public/Get-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Get-SnipeitModel.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitModel -search "DL380" @@ -31,8 +31,7 @@ Get-SnipeitModel -id 1 #> -function Get-SnipeitModel() -{ +function Get-SnipeitModel() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -54,51 +53,71 @@ function Get-SnipeitModel() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $apiurl = "$url/api/v1/models" + $api = "/api/v1/models" - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/models/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitModel @callargs - $res - if ($res.count -ne $limit ) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/models/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitModel @callargs + $res + if ($res.count -ne $limit ) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitStatus.ps1 b/SnipeitPS/Public/Get-SnipeitStatus.ps1 index d92d7cb..6eb4b05 100644 --- a/SnipeitPS/Public/Get-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Get-SnipeitStatus.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitStatus -search "Ready to Deploy" @@ -31,8 +31,7 @@ Get-SnipeitStatus -id 3 #> -function Get-SnipeitStatus() -{ +function Get-SnipeitStatus() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -54,51 +53,70 @@ function Get-SnipeitStatus() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $api = "/api/v1/statuslabels" - $apiurl = "$url/api/v1/statuslabels" - - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/statuslabels/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitStatus @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/statuslabels/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitStatus @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitSupplier.ps1 b/SnipeitPS/Public/Get-SnipeitSupplier.ps1 index 06556a8..d9de61b 100644 --- a/SnipeitPS/Public/Get-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/Get-SnipeitSupplier.ps1 @@ -18,10 +18,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitSupplier -search MySupplier @@ -30,8 +30,7 @@ Get-SnipeitSupplier -search MySupplier Get-SnipeitSupplier -id 2 #> -function Get-SnipeitSupplier() -{ +function Get-SnipeitSupplier() { [CmdletBinding(DefaultParameterSetName = 'Search')] Param( [parameter(ParameterSetName='Search')] @@ -53,52 +52,71 @@ function Get-SnipeitSupplier() [parameter(ParameterSetName='Search')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $apiurl = "$url/api/v1/suppliers" + $api = "/api/v1/suppliers" - if ($search -and $id ) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " - } - - if ($id) { - $apiurl= "$url/api/v1/suppliers/$id" - } - - $Parameters = @{ - Uri = $apiurl - Method = 'Get' - Token = $apiKey - GetParameters = $SearchParameter - } - - if ($all) { - $offstart = $(if($offset){$offset} Else {0}) - $callargs = $SearchParameter - $callargs.Remove('all') - - while ($true) { - $callargs['offset'] = $offstart - $callargs['limit'] = $limit - $res=Get-SnipeitSupplier @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + if ($search -and $id ) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " + } + + if ($id) { + $api= "/api/v1/suppliers/$id" + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitSupplier @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/Get-SnipeitUser.ps1 b/SnipeitPS/Public/Get-SnipeitUser.ps1 index 2d3381e..130d027 100644 --- a/SnipeitPS/Public/Get-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Get-SnipeitUser.ps1 @@ -24,10 +24,10 @@ Offset to use A return all results, works with -offset and other parameters .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitUser -search SomeSurname @@ -90,46 +90,65 @@ function Get-SnipeitUser() { [parameter(ParameterSetName='Get users a specific accessory id has been checked out to')] [switch]$all = $false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - switch ($PsCmdlet.ParameterSetName) { - 'Search' { $apiurl = "$url/api/v1/users"} - 'Get with id' {$apiurl= "$url/api/v1/users/$id"} - 'Get users a specific accessory id has been checked out to' {$apiurl= "$url/api/v1/accessories/$accessory_id/checkedout"} - } - - $Parameters = @{ - Uri = $apiurl - 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-SnipeitUser @callargs - $res - if ($res.count -lt $limit) { - break - } - $offstart = $offstart + $limit + $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + switch ($PsCmdlet.ParameterSetName) { + 'Search' { $api = "/api/v1/users"} + 'Get with id' {$api= "/api/v1/users/$id"} + 'Get users a specific accessory id has been checked out to' {$api= "/api/v1/accessories/$accessory_id/checkedout"} + } + + $Parameters = @{ + Api = $api + Method = 'Get' + GetParameters = $SearchParameter + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + } + process { + if ($all) { + $offstart = $(if ($offset) {$offset} Else {0}) + $callargs = $SearchParameter + $callargs.Remove('all') + + while ($true) { + $callargs['offset'] = $offstart + $callargs['limit'] = $limit + $res=Get-SnipeitUser @callargs + $res + if ($res.count -lt $limit) { + break + } + $offstart = $offstart + $limit + } + } else { + $result = Invoke-SnipeitMethod @Parameters + $result + } + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } - } else { - $result = Invoke-SnipeitMethod @Parameters - $result } } diff --git a/SnipeitPS/Public/New-SnipeitAccessory.ps1 b/SnipeitPS/Public/New-SnipeitAccessory.ps1 index fa3616c..bbd03c3 100644 --- a/SnipeitPS/Public/New-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/New-SnipeitAccessory.ps1 @@ -57,10 +57,10 @@ Min quantity of the accessory before alert is triggered Accessory image fileame and path .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1 @@ -109,32 +109,50 @@ function New-SnipeitAccessory() { [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + if ($values['purchase_date']) { + $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + } - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + $Parameters = @{ + Api = "/api/v1/accessories" + Method = 'POST' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - $Parameters = @{ - Uri = "$url/api/v1/accessories" - Method = 'POST' - Body = $Values - Token = $apiKey + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitAsset.ps1 b/SnipeitPS/Public/New-SnipeitAsset.ps1 index 065ff51..1294958 100644 --- a/SnipeitPS/Public/New-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/New-SnipeitAsset.ps1 @@ -52,10 +52,10 @@ Id of target user , location or asset Checkout asset when creating to one of following types user, location or asset. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .PARAMETER customfields Hastable of custom fields and extra fields that need passing through to Snipeit. @@ -74,8 +74,7 @@ New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -customfields = @{ "_ Using customfields when creating asset. #> -function New-SnipeitAsset() -{ +function New-SnipeitAsset() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low", @@ -135,53 +134,71 @@ function New-SnipeitAsset() [ValidateSet("location","asset","user")] [string] $checkout_to_type = "user", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey, [Alias('CustomValues')] [hashtable] $customfields ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") - } - - if ($customfields) - { - $Values += $customfields - } - - #Checkout asset when creating it - if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating'){ - switch ($checkout_to_type){ - 'location' { $Values += @{ "assigned_location" = $assigned_id } } - 'user' { $Values += @{ "assigned_user" = $assigned_id } } - 'asset' { $Values += @{ "assigned_asset" = $assigned_id } } + if ($values['purchase_date']) { + $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") } - #This are not needed for API - if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} - if($Values.ContainsKey('checkout_to_type')){$Values.Remove('checkout_to_type')} + if ($customfields) { + $Values += $customfields + } + + #Checkout asset when creating it + if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') { + switch ($checkout_to_type) { + 'location' { $Values += @{ "assigned_location" = $assigned_id } } + 'user' { $Values += @{ "assigned_user" = $assigned_id } } + 'asset' { $Values += @{ "assigned_asset" = $assigned_id } } + } + + #This are not needed for API + if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')} + if ($Values.ContainsKey('checkout_to_type')) {$Values.Remove('checkout_to_type')} + } + + $Parameters = @{ + Api = "/api/v1/hardware" + Method = 'Post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - $Parameters = @{ - Uri = "$url/api/v1/hardware" - Method = 'Post' - Body = $Values - Token = $apiKey + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 index a62f690..f732502 100644 --- a/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 @@ -31,10 +31,10 @@ Optional completion date Optional cost .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01 @@ -70,36 +70,55 @@ function New-SnipeitAssetMaintenance() { [string]$notes, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + if ($Values['start_date']) { + $Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd") + } - if ($Values['start_date']) { - $Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd") + if ($Values['completion_date']) { + $Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd") + } + + + $Parameters = @{ + Api = "/api/v1/maintenances" + Method = 'Post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - if ($Values['completion_date']) { - $Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd") + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - - $Parameters = @{ - Uri = "$url/api/v1/maintenances" - Method = 'Post' - Body = $Values - Token = $apiKey + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters - } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitAudit.ps1 b/SnipeitPS/Public/New-SnipeitAudit.ps1 index 883491b..5f7abb5 100644 --- a/SnipeitPS/Public/New-SnipeitAudit.ps1 +++ b/SnipeitPS/Public/New-SnipeitAudit.ps1 @@ -16,8 +16,7 @@ New-SnipeitAudit -tag 1 -location_id 1 #> -function New-SnipeitAudit() -{ +function New-SnipeitAudit() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -29,36 +28,53 @@ function New-SnipeitAudit() [int]$location_id, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = @{ + "location_id" = $location_id + } - $Values = @{ - "location_id" = $location_id + if ($PSBoundParameters.ContainsKey('tag')) { + $Values += @{"asset_tag" = $tag} + } + + $Parameters = @{ + Api = "/api/v1/hardware/audit" + Method = 'Post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - if ($PSBoundParameters.ContainsKey('tag')) - { - $Values += @{"asset_tag" = $tag} + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $Parameters = @{ - Uri = "$url/api/v1/hardware/audit" - Method = 'Post' - Body = $Values - Token = $apiKey + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters - } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitCategory.ps1 b/SnipeitPS/Public/New-SnipeitCategory.ps1 index f9e3741..1b01abb 100644 --- a/SnipeitPS/Public/New-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/New-SnipeitCategory.ps1 @@ -24,17 +24,16 @@ If switch is present, send email to user on checkin/checkout Category image filename and path .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE -New-SnipeitCategory -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..." +New-SnipeitCategory -name "Laptops" -category_type asset #> -function New-SnipeitCategory() -{ +function New-SnipeitCategory() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -59,17 +58,17 @@ function New-SnipeitCategory() [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - if($eula_text -and $use_default_eula){ + if ($eula_text -and $use_default_eula) { throw 'Dont use -use_defalt_eula if -eula_text is set' } @@ -79,17 +78,32 @@ function New-SnipeitCategory() process { $Parameters = @{ - Uri = "$url/api/v1/categories" + Api = "/api/v1/categories" Method = 'POST' Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitCompany.ps1 b/SnipeitPS/Public/New-SnipeitCompany.ps1 index 2f25c34..2cc07cb 100644 --- a/SnipeitPS/Public/New-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/New-SnipeitCompany.ps1 @@ -12,18 +12,17 @@ Comapany name Company image filename and path .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE New-SnipeitCompany -name "Acme Company" #> -function New-SnipeitCompany() -{ +function New-SnipeitCompany() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -36,29 +35,47 @@ function New-SnipeitCompany() [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Parameters = @{ + Api = "/api/v1/companies" + Method = 'POST' + Body = $Values + } - $Parameters = @{ - Uri = "$url/api/v1/companies" - Method = 'POST' - Body = $Values - Token = $apiKey + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitComponent.ps1 b/SnipeitPS/Public/New-SnipeitComponent.ps1 index 194b46e..08cdb72 100644 --- a/SnipeitPS/Public/New-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/New-SnipeitComponent.ps1 @@ -30,16 +30,15 @@ Cost of item being purchased. Component image filename and path .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE -An example +New-SnipeitComponent -name 'Display adapter' -catecory_id 3 -qty 10 + -.NOTES -General notes #> function New-SnipeitComponent() { @@ -71,32 +70,51 @@ function New-SnipeitComponent() { [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") + } - if ($Values['purchase_date']) { - $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") + $Parameters = @{ + Api = "/api/v1/components" + Method = 'POST' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - $Parameters = @{ - Uri = "$url/api/v1/components" - Method = 'POST' - Body = $Values - Token = $apiKey + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitConsumable.ps1 b/SnipeitPS/Public/New-SnipeitConsumable.ps1 index df2b594..c24704c 100644 --- a/SnipeitPS/Public/New-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/New-SnipeitConsumable.ps1 @@ -48,10 +48,10 @@ Item number for the consumable Consumable Image filename and path .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE @@ -60,8 +60,7 @@ Create consumable with stock count 20 , alert when stock is 5 or lower #> -function New-SnipeitConsumable() -{ +function New-SnipeitConsumable() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -110,10 +109,10 @@ function New-SnipeitConsumable() [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -123,21 +122,36 @@ function New-SnipeitConsumable() if ($Values['purchase_date']) { $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } + + $Parameters = @{ + Api = "/api/v1/consumables" + Method = 'Post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } process { - $Parameters = @{ - Uri = "$url/api/v1/consumables" - Method = 'Post' - Body = $Values - Token = $apiKey - } - - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitCustomField.ps1 b/SnipeitPS/Public/New-SnipeitCustomField.ps1 index 2b1efbe..05750da 100644 --- a/SnipeitPS/Public/New-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/New-SnipeitCustomField.ps1 @@ -30,17 +30,16 @@ Any additional text you wish to display under the new form field to make it clearer what the gauges should be. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset" #> -function New-SnipeitCustomField() -{ +function New-SnipeitCustomField() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -68,10 +67,10 @@ function New-SnipeitCustomField() [string]$custom_format, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -84,20 +83,33 @@ function New-SnipeitCustomField() $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Parameters = @{ - Uri = "$url/api/v1/fields" + Api = "/api/v1/fields" Method = 'post' Body = $Values - Token = $apiKey + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Set-SnipeitPSLegacyUrl -url $url } } process{ - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitDepartment.ps1 b/SnipeitPS/Public/New-SnipeitDepartment.ps1 index 185a165..1510303 100644 --- a/SnipeitPS/Public/New-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/New-SnipeitDepartment.ps1 @@ -21,10 +21,10 @@ Department Image filename and path .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 @@ -54,28 +54,47 @@ function New-SnipeitDepartment() { [switch]$image_delete=$false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Parameters = @{ + Api = "/api/v1/departments" + Method = 'POST' + Body = $Values + } - $Parameters = @{ - Uri = "$url/api/v1/departments" - Method = 'POST' - Body = $Values - Token = $apiKey + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitLicense.ps1 b/SnipeitPS/Public/New-SnipeitLicense.ps1 index 11a49fb..2f2ac28 100644 --- a/SnipeitPS/Public/New-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/New-SnipeitLicense.ps1 @@ -57,10 +57,10 @@ Termination date for license. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitLicence -name "License" -seats 3 -company_id 1 @@ -117,40 +117,58 @@ function New-SnipeitLicense() { [datetime]$termination_date, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + if ($Values['expiration_date']) { + $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd") + } - if ($Values['expiration_date']) { - $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") + } + + if ($Values['termination_date']) { + $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") + } + + $Parameters = @{ + Api = "/api/v1/licenses" + Method = 'POST' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - if ($Values['purchase_date']) { - $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") - } + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } - if ($Values['termination_date']) { - $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") + $result } - - $Parameters = @{ - Uri = "$url/api/v1/licenses" - Method = 'POST' - Body = $Values - Token = $apiKey + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters - } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitLocation.ps1 b/SnipeitPS/Public/New-SnipeitLocation.ps1 index b34eaa3..fa4d99a 100644 --- a/SnipeitPS/Public/New-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/New-SnipeitLocation.ps1 @@ -42,10 +42,10 @@ Location Image filename and path .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14 @@ -86,27 +86,47 @@ function New-SnipeitLocation() { [switch]$image_delete=$false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Parameters = @{ - Uri = "$url/api/v1/locations" - Method = 'post' - Body = $Values - Token = $apiKey + $Parameters = @{ + Api = "/api/v1/locations" + Method = 'post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 index 67b5604..3efb031 100644 --- a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 @@ -15,17 +15,16 @@ Remove current image .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitManufacturer -name "HP" #> -function New-SnipeitManufacturer() -{ +function New-SnipeitManufacturer() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -40,30 +39,47 @@ function New-SnipeitManufacturer() [switch]$image_delete=$false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $Values = @{ - "name" = $Name + $Values = @{ + "name" = $Name + } + + $Parameters = @{ + Api = "/api/v1/manufacturers" + Method = 'post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } - $Parameters = @{ - Uri = "$url/api/v1/manufacturers" - Method = 'post' - Body = $Values - Token = $apiKey + $result } - - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index c15616e..d198c39 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -24,17 +24,16 @@ Asset model Image filename and path .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 #> -function New-SnipeitModel() -{ +function New-SnipeitModel() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -60,37 +59,56 @@ function New-SnipeitModel() [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - $Values = @{ - name = $name - category_id = $category_id - manufacturer_id = $manufacturer_id - fieldset_id = $fieldset_id + $Values = @{ + name = $name + category_id = $category_id + manufacturer_id = $manufacturer_id + fieldset_id = $fieldset_id + } + + if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) } + if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) } + + + $Parameters = @{ + Api = "/api/v1/models" + Method = 'post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) } - if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) } + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } - - $Parameters = @{ - Uri = "$url/api/v1/models" - Method = 'post' - Body = $Values - Token = $apiKey + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/New-SnipeitSupplier.ps1 b/SnipeitPS/Public/New-SnipeitSupplier.ps1 index 3bd64bf..fdad3a4 100644 --- a/SnipeitPS/Public/New-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/New-SnipeitSupplier.ps1 @@ -45,10 +45,10 @@ Image file name and path for item .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 @@ -90,28 +90,47 @@ function New-SnipeitSupplier() { [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + $Parameters = @{ + Api = "/api/v1/suppilers" + Method = 'POST' + Body = $Values + } - $Parameters = @{ - Uri = "$url/api/v1/suppilers" - Method = 'POST' - Body = $Values - Token = $apiKey + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/New-SnipeitUser.ps1 b/SnipeitPS/Public/New-SnipeitUser.ps1 index 61cbe36..ffdab44 100644 --- a/SnipeitPS/Public/New-SnipeitUser.ps1 +++ b/SnipeitPS/Public/New-SnipeitUser.ps1 @@ -54,10 +54,10 @@ User Image file name and path .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 @@ -110,31 +110,50 @@ function New-SnipeitUser() { [ValidateScript({Test-Path $_})] [string]$image, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + if ($password ) { + $Values['password_confirmation'] = $password + } - if ($password ) { - $Values['password_confirmation'] = $password + $Parameters = @{ + Api = "/api/v1/users" + Method = 'post' + Body = $Values + } + + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } } - $Parameters = @{ - Uri = "$url/api/v1/users" - Method = 'post' - Body = $Values - Token = $apiKey + process { + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - $result = Invoke-SnipeitMethod @Parameters + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } } - - $result } diff --git a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 index 4189b17..d7f92b7 100644 --- a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 @@ -6,10 +6,10 @@ .PARAMETER ID Unique ID For accessory to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Remove-SnipeitAccessory -ID 44 -Verbose @@ -18,37 +18,55 @@ Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory #> -function Remove-SnipeitAccessory () -{ +function Remove-SnipeitAccessory () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($accessory_id in $id){ + foreach($accessory_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/accessories/$accessory_id" + Api = "/api/v1/accessories/$accessory_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 index 68d9dbb..3f718cb 100644 --- a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 @@ -6,10 +6,10 @@ .PARAMETER ID Unique ID For Asset to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Remove-SnipeitAsset -ID 44 -Verbose @@ -18,38 +18,56 @@ Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset #> -function Remove-SnipeitAsset () -{ +function Remove-SnipeitAsset () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name } + process { - foreach($asset_id in $id){ + foreach($asset_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/hardware/$asset_id" + Api = "/api/v1/hardware/$asset_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 index a1f7b65..b94c4a3 100644 --- a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 @@ -1,60 +1,72 @@ +<# + .SYNOPSIS + Remove asset maintenance from Snipe-it asset system + + .DESCRIPTION + Removes asset maintenance event or events from Snipe-it asset system by ID + + .PARAMETER ID + Unique ID of the asset maintenance to be removed + + .PARAMETER url + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. + .PARAMETER url + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. + + .EXAMPLE + Remove-SnipeitAssetMaintenance -ID 44 +#> function Remove-SnipeitAssetMaintenance { - <# - .SYNOPSIS - Remove asset maintenance from Snipe-it asset system - .DESCRIPTION - Removes asset maintenance event or events from Snipe-it asset system by ID - - .PARAMETER ID - Unique ID of the asset maintenance to be removed - - .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command - - .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command - - .EXAMPLE - Remove-SnipeitAssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose - #> [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] param ( - # Asset maintenance ID [Parameter(Mandatory = $true,ValueFromPipelineByPropertyName)] [int[]] $id, - # Snipeit URL - [Parameter(Mandatory = $true)] - [string] - $url, + [parameter(mandatory = $false)] + [string]$url, - # Snipeit ApiKey - [Parameter(Mandatory = $true)] - [string] - $apiKey + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name } + process { - foreach($maintenance_id in $id){ + foreach($maintenance_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/maintenances/$maintenance_id" + Api = "/api/v1/maintenances/$maintenance_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 index 0f86693..40b68f2 100644 --- a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 @@ -6,49 +6,66 @@ .PARAMETER ID Unique ID For categoryto be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitCategory -ID 44 -Verbose + Remove-SnipeitCategory -ID 44 .EXAMPLE Get-SnipeitCategory -search something | Remove-SnipeitCategory #> -function Remove-SnipeitCategory () -{ +function Remove-SnipeitCategory () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) begin { } process { - foreach($category_id in $id){ + foreach($category_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/categories/$category_id" + Api = "/api/v1/categories/$category_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 index 9ff94dc..ecb87a9 100644 --- a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 @@ -6,49 +6,66 @@ .PARAMETER ID Unique ID For Company to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitCompany -ID 44 -Verbose + Remove-SnipeitCompany -ID 44 .EXAMPLE Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCompany #> -function Remove-SnipeitCompany () -{ +function Remove-SnipeitCompany () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) begin { } process { - foreach($company_id in $id){ + foreach($company_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/companies/$company_id" + Api = "/api/v1/companies/$company_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 index 450dbed..265eb4a 100644 --- a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 @@ -6,49 +6,67 @@ .PARAMETER IDs Unique ID For component to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitComponent -ID 44 -Verbose + Remove-SnipeitComponent -ID 44 .EXAMPLE Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent #> -function Remove-SnipeitComponent () -{ +function Remove-SnipeitComponent () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($component_id in $id){ + foreach($component_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/components/$component_id" + Api = "/api/v1/components/$component_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 index 3e18b3d..230436f 100644 --- a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 @@ -7,49 +7,67 @@ Unique ID For consumable to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitConsumable -ID 44 -Verbose + Remove-SnipeitConsumable -ID 44 .EXAMPLE - Get-SnipeitConsumable -search "paper" | Remove-Snipeitconsumable + Get-SnipeitConsumable -search "paper" | Remove-SnipeitConsumable #> -function Remove-SnipeitConsumable () -{ +function Remove-SnipeitConsumable () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($consumable_id in $id){ + foreach($consumable_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/consumables/$consumable_id" + Api = "/api/v1/consumables/$consumable_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 index e258ca2..31528e4 100644 --- a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 @@ -6,10 +6,10 @@ .PARAMETER ID Unique ID For field to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Remove-SnipeitCustomField -ID 44 -Verbose @@ -18,37 +18,53 @@ Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-SnipeitCustomField #> -function Remove-SnipeitCustomField () -{ +function Remove-SnipeitCustomField () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) begin { } process { - foreach($field_id in $id){ + foreach($field_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/fields/$field_id" + Api = "/api/v1/fields/$field_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 index d6e95c7..c4e8538 100644 --- a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 @@ -6,49 +6,66 @@ .PARAMETER ID Unique ID For department to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitDepartment -ID 44 -Verbose + Remove-SnipeitDepartment -ID 44 .EXAMPLE Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDepartment #> -function Remove-SnipeitDepartment () -{ +function Remove-SnipeitDepartment () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) begin { } process { - foreach($department_id in $id){ + foreach($department_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/departments/$department_id" + Api = "/api/v1/departments/$department_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 index ba0dee4..55eecb1 100644 --- a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 @@ -6,49 +6,67 @@ .PARAMETER ID Unique ID For licence to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitLicence -ID 44 -Verbose + Remove-SnipeitLicence -ID 44 .EXAMPLE Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense #> -function Remove-SnipeitLicense () -{ +function Remove-SnipeitLicense () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($license_id in $id){ + foreach($license_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/licenses/$license_id" + Api = "/api/v1/licenses/$license_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 index 15c4567..c827325 100644 --- a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 @@ -6,49 +6,67 @@ .PARAMETER ID Unique ID For location to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitLocation -ID 44 -Verbose + Remove-SnipeitLocation -ID 44 .EXAMPLE Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation #> -function Remove-SnipeitLocation () -{ +function Remove-SnipeitLocation () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($location_id in $id){ + foreach($location_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/locations/$asset_id" + Api = "/api/v1/locations/$asset_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 index 9605d9b..38c5aab 100644 --- a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 @@ -6,49 +6,68 @@ .PARAMETER ID Unique ID For manufacturer to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitManufacturer -ID 44 -Verbose + Remove-SnipeitManufacturer -ID 44 .EXAMPLE Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-SnipeitManufacturer #> -function Remove-SnipeitManufacturer () -{ +function Remove-SnipeitManufacturer () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($manufacturer_id in $id){ + foreach($manufacturer_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/manufacturers/$manufacturer_id" + Api = "/api/v1/manufacturers/$manufacturer_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitModel.ps1 b/SnipeitPS/Public/Remove-SnipeitModel.ps1 index 65509bd..cb20fae 100644 --- a/SnipeitPS/Public/Remove-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitModel.ps1 @@ -6,49 +6,67 @@ .PARAMETER ID Unique ID For Model to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitModel -ID 44 -Verbose + Remove-SnipeitModel -ID 44 .EXAMPLE Get-SnipeitModel -search needle | Remove-SnipeitModel #> -function Remove-SnipeitModel () -{ +function Remove-SnipeitModel () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($model_id in $id){ + foreach($model_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/models/$model_id" + Api = "/api/v1/models/$model_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 b/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 index 196df14..a7d4d91 100644 --- a/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 @@ -6,10 +6,10 @@ .PARAMETER ID Unique ID For supplier to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Remove-SnipeitSupplier -ID 44 @@ -18,37 +18,55 @@ Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier #> -function Remove-SnipeitSupplier () -{ +function Remove-SnipeitSupplier () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [int[]]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin { } + process { - foreach($suppliers_id in $id){ + foreach($suppliers_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/suppliers/$supplier_id" + Api = "/api/v1/suppliers/$supplier_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { - $result = Invoke-SnipeitMethod @Parameters + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result } - $result + } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi } } } diff --git a/SnipeitPS/Public/Remove-SnipeitUser.ps1 b/SnipeitPS/Public/Remove-SnipeitUser.ps1 index 6afd60b..f7bb50c 100644 --- a/SnipeitPS/Public/Remove-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitUser.ps1 @@ -7,31 +7,32 @@ Unique ID For User to be removed .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose #> -function Remove-SnipeitUser () -{ +function Remove-SnipeitUser () { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( - [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] - [int]$id, - [parameter(mandatory = $true)] - [string]$URL, - [parameter(mandatory = $true)] - [string]$APIKey + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [int[]]$id, + [parameter(mandatory = $false)] + [string]$url, + + [parameter(mandatory = $false)] + [string]$apiKey ) + begin{ Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name } @@ -39,17 +40,32 @@ function Remove-SnipeitUser () process { foreach($user_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/users/$user_id" + Api = "/api/v1/users/$user_id" Method = 'Delete' - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 b/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 index 060bb90..254c5a8 100644 --- a/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 +++ b/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 @@ -10,10 +10,10 @@ Use Get-SnipeitAccessoryOwner to find out nooded value .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE To get the accessories_users table for specific accessory id number @@ -25,8 +25,7 @@ Get-SnipeitAccessoryOwner -assigned_pivot_id xxx #> -function Reset-SnipeitAccessoryOwner() -{ +function Reset-SnipeitAccessoryOwner() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -36,24 +35,38 @@ function Reset-SnipeitAccessoryOwner() [parameter(mandatory = $true)] [int]$assigned_pivot_id, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) $Parameters = @{ - Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin" + Api = "/api/v1/accessories/$assigned_pivot_id/checkin" Method = 'Post' Body = @{} - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + return $result + } diff --git a/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 b/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 index 6a55915..39fde33 100644 --- a/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 +++ b/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 @@ -17,13 +17,11 @@ Notes about checkin .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command - + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command - + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE - Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose + Remove-SnipeitUser -ID 44 #> function Reset-SnipeitAssetOwner() { [CmdletBinding( @@ -41,10 +39,10 @@ function Reset-SnipeitAssetOwner() { [string]$notes, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -58,15 +56,29 @@ function Reset-SnipeitAssetOwner() { if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) } $Parameters = @{ - Uri = "$url/api/v1/hardware/$id/checkin" + Api = "/api/v1/hardware/$id/checkin" Method = 'POST' Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + return $result } diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index cbb55d2..a117e46 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -54,11 +54,10 @@ Remove current image Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfoeItInfo command - +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Set-SnipeitAccessory -id 1 -qty 3 @@ -107,10 +106,10 @@ function Set-SnipeitAccessory() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -126,20 +125,36 @@ function Set-SnipeitAccessory() { } process { - foreach($accessory_id in $id){ + foreach($accessory_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/accessories/$accessory_id" + Api = "/api/v1/accessories/$accessory_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 b/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 index 4a6a319..49dbc28 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 @@ -14,16 +14,15 @@ Notes about checkout .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user" #> -function Set-SnipeitAccessoryOwner() -{ +function Set-SnipeitAccessoryOwner() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -38,10 +37,10 @@ function Set-SnipeitAccessoryOwner() [string] $note, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin{ @@ -49,20 +48,35 @@ function Set-SnipeitAccessoryOwner() } process { - foreach($accessory_id in $id){ + foreach($accessory_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/accessories/$accessory_id/checkout" + Api = "/api/v1/accessories/$accessory_id/checkout" Method = 'POST' Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } return $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitAsset.ps1 b/SnipeitPS/Public/Set-SnipeitAsset.ps1 index b375fda..54a72e3 100644 --- a/SnipeitPS/Public/Set-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAsset.ps1 @@ -63,10 +63,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .PARAMETER customfields Hastable of custom fields and extra fields that need passing through to Snipeit @@ -81,8 +81,7 @@ Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated' #> -function Set-SnipeitAsset() -{ +function Set-SnipeitAsset() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -133,10 +132,10 @@ function Set-SnipeitAsset() [switch]$image_delete=$false, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey, [Alias('CustomValues')] @@ -151,28 +150,42 @@ function Set-SnipeitAsset() $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - if ($customfields) - { + if ($customfields) { $Values += $customfields } } process { - foreach($asset_id in $id){ + foreach($asset_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/hardware/$asset_id" + Api = "/api/v1/hardware/$asset_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 b/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 index 6db1de7..825aa7d 100644 --- a/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 @@ -28,16 +28,15 @@ Optional date to override the checkout time of now .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing check out to user" #> -function Set-SnipeitAssetOwner() -{ +function Set-SnipeitAssetOwner() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -61,10 +60,10 @@ function Set-SnipeitAssetOwner() [datetime]$checkout_at, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -81,33 +80,47 @@ function Set-SnipeitAssetOwner() $Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd") } - switch ($checkout_to_type) - { + switch ($checkout_to_type) { 'location' { $Values += @{ "assigned_location" = $assigned_id } } 'user' { $Values += @{ "assigned_user" = $assigned_id } } 'asset' { $Values += @{ "assigned_asset" = $assigned_id } } } #This can be removed now - if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} + if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')} } process{ - foreach($asset_id in $id){ + foreach($asset_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/hardware/$asset_id/checkout" + Api = "/api/v1/hardware/$asset_id/checkout" Method = 'POST' Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } return $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitCategory.ps1 b/SnipeitPS/Public/Set-SnipeitCategory.ps1 index f10b21e..c234c40 100644 --- a/SnipeitPS/Public/Set-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCategory.ps1 @@ -30,17 +30,16 @@ Remove current image Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE Set-SnipeitCategory -id 4 -name "Laptops" #> -function Set-SnipeitCategory() -{ +function Set-SnipeitCategory() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -71,10 +70,10 @@ function Set-SnipeitCategory() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -86,20 +85,35 @@ function Set-SnipeitCategory() } process { - foreach($category_id in $id){ + foreach($category_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/categories/$category_id" + Api = "/api/v1/categories/$category_id" Method = $RequestType Body = $values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 index 923e76d..f7c7052 100644 --- a/SnipeitPS/Public/Set-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -21,10 +21,10 @@ Remove current image Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE An example @@ -32,8 +32,7 @@ An example .NOTES General notes #> -function Set-SnipeitCompany() -{ +function Set-SnipeitCompany() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -54,10 +53,10 @@ function Set-SnipeitCompany() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -66,20 +65,34 @@ function Set-SnipeitCompany() } process{ - foreach($company_id in $id){ + foreach($company_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/companies/$company_id" + Api = "/api/v1/companies/$company_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index 2834df9..bf8b5f2 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -42,19 +42,17 @@ Remove current image Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .EXAMPLE -An example +Set-SnipeitComponent -id 42 -qty 12 +Sets count of component with ID 42 to 12 -.NOTES -General notes #> -function Set-SnipeitComponent() -{ +function Set-SnipeitComponent() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -90,10 +88,10 @@ function Set-SnipeitComponent() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin { @@ -107,20 +105,35 @@ function Set-SnipeitComponent() } process { - foreach($component_id in $id){ + foreach($component_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/components/$component_id" + Api = "/api/v1/components/$component_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 index 4aa28ab..bf3d773 100644 --- a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 @@ -57,10 +57,10 @@ Remove current image Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE @@ -69,8 +69,7 @@ Create consumable with stock count 20 , alert when stock is 5 or lower #> -function Set-SnipeitConsumable() -{ +function Set-SnipeitConsumable() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -129,10 +128,10 @@ function Set-SnipeitConsumable() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -146,20 +145,35 @@ function Set-SnipeitConsumable() } process { - foreach($consumable_id in $id ){ + foreach($consumable_id in $id ) { $Parameters = @{ - Uri = "$url/api/v1/consumables/$consumable_id" + Api = "/api/v1/consumables/$consumable_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 index d958d37..4dd49ad 100644 --- a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 @@ -33,17 +33,16 @@ Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset" #> -function Set-SnipeitCustomField() -{ +function Set-SnipeitCustomField() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -75,10 +74,10 @@ function Set-SnipeitCustomField() [ValidateSet("Put","Patch")] [string]$RequestType = "Put", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin { @@ -93,19 +92,33 @@ function Set-SnipeitCustomField() process{ foreach($field_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/fields/$field_id" + Api = "/api/v1/fields/$field_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 index 09d4632..da4b877 100644 --- a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 @@ -30,10 +30,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Set-SnipeitDepartment -id 4 -manager_id 3 @@ -68,10 +68,10 @@ function Set-SnipeitDepartment() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -83,18 +83,33 @@ function Set-SnipeitDepartment() { process { foreach ($department_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/departments/$department_id" + Api = "/api/v1/departments/$department_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitInfo.ps1 b/SnipeitPS/Public/Set-SnipeitInfo.ps1 index 3788c2b..d0c7fbd 100644 --- a/SnipeitPS/Public/Set-SnipeitInfo.ps1 +++ b/SnipeitPS/Public/Set-SnipeitInfo.ps1 @@ -1,14 +1,16 @@ <# .SYNOPSIS - Sets authetication information + Sets authetication information. Deprecated, use Connect-SnipeitPS instead. + .DESCRIPTION - Set apikey and url user to connect Snipe-It system + Deprecated combatibilty function that Set apikey and url user to connect Snipe-It system. + Please use Connect-SnipeitPS instead. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + User's API Key for Snipeit. .EXAMPLE Set-SnipeitInfo -url $url -apiKey -Verbose @@ -17,50 +19,18 @@ function Set-SnipeitInfo { [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] param ( + [parameter(Mandatory=$true)] [Uri]$url, - + [parameter(Mandatory=$true)] [String]$apiKey ) BEGIN { - Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name - function Add-DefaultParameter { - param( - [Parameter(Mandatory = $true)] - [string]$Command, - [Parameter(Mandatory = $true)] - [string]$Parameter, - - [Parameter(Mandatory = $true)] - $Value - ) - - PROCESS { - #Write-Verbose "[$($MyInvocation.MyCommand.Name)] Setting [$command : $parameter] = $value" - - # Needs to set both global and module scope for the private functions: - # http://stackoverflow.com/questions/30427110/set-psdefaultparametersvalues-for-use-within-module-scope - $PSDefaultParameterValues["${command}:${parameter}"] = $Value - $global:PSDefaultParameterValues["${command}:${parameter}"] = $Value - - } - } - - $moduleCommands = Get-Command -Module SnipeitPS -CommandType Function + Write-Warning "Deprecated $($MyInvocation.InvocationName) is still working, please use Connect-SnipeitPS instead." } PROCESS { - foreach ($command in $moduleCommands) { - $parameter = "url" - if ($url -and ($command.Parameters.Keys -contains $parameter)) { - Add-DefaultParameter -Command $command -Parameter $parameter -Value ($url.AbsoluteUri.TrimEnd('/')) - } - - $parameter = "apiKey" - if ($apiKey -and ($command.Parameters.Keys -contains $parameter)) { - Add-DefaultParameter -Command $command -Parameter $parameter -Value $apiKey - } - } + Connect-SnipeitPS -Url $url -apiKey $apiKey } } diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index 184aa57..2eb8abd 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -63,10 +63,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Set-SnipeitLicence -name "License" -seats 3 -company_id 1 @@ -127,10 +127,10 @@ function Set-SnipeitLicense() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -154,19 +154,34 @@ function Set-SnipeitLicense() { } process { - foreach($license_id in $id){ + foreach($license_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/licenses/$license_id" + Api = "/api/v1/licenses/$license_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 5ef3880..c938847 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -20,10 +20,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 @@ -38,8 +38,7 @@ Checkin licence seat id 1 of licence id 1 #> -function Set-SnipeitLicenseSeat() -{ +function Set-SnipeitLicenseSeat() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -64,10 +63,10 @@ function Set-SnipeitLicenseSeat() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -78,18 +77,33 @@ function Set-SnipeitLicenseSeat() process{ foreach($license_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" + Api = "/api/v1/licenses/$license_id/seats/$seat_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) - { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } return $result } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } } diff --git a/SnipeitPS/Public/Set-SnipeitLocation.ps1 b/SnipeitPS/Public/Set-SnipeitLocation.ps1 index b1c3770..513d382 100644 --- a/SnipeitPS/Public/Set-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLocation.ps1 @@ -54,10 +54,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100 @@ -105,10 +105,10 @@ function Set-SnipeitLocation() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -121,18 +121,34 @@ function Set-SnipeitLocation() { process{ foreach ($location_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/locations/$location_id" + Api = "/api/v1/locations/$location_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 index d0c1064..2426441 100644 --- a/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 @@ -18,17 +18,16 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitManufacturer -name "HP" #> -function Set-SnipeitManufacturer() -{ +function Set-SnipeitManufacturer() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -46,10 +45,10 @@ function Set-SnipeitManufacturer() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -62,17 +61,33 @@ function Set-SnipeitManufacturer() process{ foreach ($manufacturer_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/manufacturers/$manufacturer_id" + Api = "/api/v1/manufacturers/$manufacturer_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitModel.ps1 b/SnipeitPS/Public/Set-SnipeitModel.ps1 index 695368f..008dc38 100644 --- a/SnipeitPS/Public/Set-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Set-SnipeitModel.ps1 @@ -33,10 +33,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 @@ -74,10 +74,10 @@ function Set-SnipeitModel() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -90,17 +90,33 @@ function Set-SnipeitModel() { process { foreach ($model_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/models/$model_id" + Api = "/api/v1/models/$model_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitStatus.ps1 b/SnipeitPS/Public/Set-SnipeitStatus.ps1 index 4c11b8a..dbfa747 100644 --- a/SnipeitPS/Public/Set-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Set-SnipeitStatus.ps1 @@ -19,10 +19,10 @@ Hex code showing what color the status label should be on the pie chart in the d Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE Get-SnipeitStatus -search "Ready to Deploy" @@ -32,8 +32,7 @@ Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending #> -function Set-SnipeitStatus() -{ +function Set-SnipeitStatus() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" @@ -59,10 +58,10 @@ function Set-SnipeitStatus() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -73,16 +72,32 @@ function Set-SnipeitStatus() process { foreach($status_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/statuslabels/$status_id" + Api = "/api/v1/statuslabels/$status_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitSupplier.ps1 b/SnipeitPS/Public/Set-SnipeitSupplier.ps1 index 7180c5a..19f01ed 100644 --- a/SnipeitPS/Public/Set-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/Set-SnipeitSupplier.ps1 @@ -51,10 +51,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - Users API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit. .EXAMPLE New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 @@ -101,10 +101,10 @@ function Set-SnipeitSupplier() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) @@ -117,18 +117,34 @@ function Set-SnipeitSupplier() { process { foreach ($supplier_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/suppliers/$supplier_id" + Api = "/api/v1/suppliers/$supplier_id" Method = $RequestType Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Set-SnipeitUser.ps1 b/SnipeitPS/Public/Set-SnipeitUser.ps1 index 82cc023..55e275b 100644 --- a/SnipeitPS/Public/Set-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Set-SnipeitUser.ps1 @@ -63,10 +63,10 @@ Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url - URL of Snipeit system, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey - User's API Key for Snipeit, can be set using Set-SnipeitInfo command + Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit. .EXAMPLE Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 @@ -124,10 +124,10 @@ function Set-SnipeitUser() { [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$url, - [parameter(mandatory = $true)] + [parameter(mandatory = $false)] [string]$apiKey ) begin{ @@ -144,17 +144,33 @@ function Set-SnipeitUser() { process{ foreach($user_id in $id) { $Parameters = @{ - Uri = "$url/api/v1/users/$user_id" + Api = "/api/v1/users/$user_id" Method = 'PATCH' Body = $Values - Token = $apiKey } - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + if ($PSBoundParameters.ContainsKey('apiKey')) { + Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyApiKey -apiKey $apikey + } + + if ($PSBoundParameters.ContainsKey('url')) { + Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." + Set-SnipeitPSLegacyUrl -url $url + } + + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } + + end { + # reset legacy sessions + if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { + Reset-SnipeitPSLegacyApi + } + } } diff --git a/SnipeitPS/Public/Update-SnipeitAlias.ps1 b/SnipeitPS/Public/Update-SnipeitAlias.ps1 index 8ba3323..ca9d2fb 100644 --- a/SnipeitPS/Public/Update-SnipeitAlias.ps1 +++ b/SnipeitPS/Public/Update-SnipeitAlias.ps1 @@ -15,8 +15,7 @@ Replaces old command from file "your-script.ps1" and creates new script "new-scr After testing new file you can replace old file with new. #> -function Update-SnipeitAlias() -{ +function Update-SnipeitAlias() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" @@ -34,8 +33,8 @@ function Update-SnipeitAlias() } process { - If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { - ForEach ($st in $String){ + if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + ForEach ($st in $String) { $result = $st ForEach ($key in $SnipeitAliases.Keys ) { #Write-Verbose "Replacing $key with $($SnipeitAliases[$key])" diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index 0f0201c..c742924 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -12,7 +12,7 @@ RootModule = 'SnipeitPS' # Version number of this module. -ModuleVersion = '1.9' +ModuleVersion = '1.10' # Supported PSEditions # CompatiblePSEditions = @() @@ -70,6 +70,7 @@ PowerShellVersion = '5.1' # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = @( + 'Connect-SnipeitPS', 'Get-SnipeitAccessory', 'Get-SnipeitAccessoryOwner', 'Get-SnipeitActivity', diff --git a/SnipeitPS/SnipeitPS.psm1 b/SnipeitPS/SnipeitPS.psm1 index ce0d808..4133806 100644 --- a/SnipeitPS/SnipeitPS.psm1 +++ b/SnipeitPS/SnipeitPS.psm1 @@ -5,14 +5,22 @@ Powershell API for Snipeit Asset Management $scriptRoot = $PSScriptRoot + '\Public' Get-ChildItem $scriptRoot *.ps1 | ForEach-Object { - Import-Module $_.FullName + . $_.FullName } $scriptRoot = $PSScriptRoot + '\Private' Get-ChildItem $scriptRoot *.ps1 | ForEach-Object { - Import-Module $_.FullName + . $_.FullName } #Create unprefixed aliases Set-SnipeitAlias + +#Session variable for storing current session information +$SnipeitPSSession = [ordered]@{ + 'url' = $null + 'apiKey' = $null +} +New-Variable -Name SnipeitPSSession -Value $SnipeitPSSession -Scope Script -Force + diff --git a/appveyor.yml b/appveyor.yml index dc61a6c..b99f6fe 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ environment: secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm PShell: '5' -version: 1.9.{build} +version: 1.10.{build} # Don't rebuild when I tag a release on GitHub skip_tags: true diff --git a/docs/Connect-SnipeitPS.md b/docs/Connect-SnipeitPS.md new file mode 100644 index 0000000..137649a --- /dev/null +++ b/docs/Connect-SnipeitPS.md @@ -0,0 +1,137 @@ +--- +external help file: SnipeitPS-help.xml +Module Name: snipeitps +online version: +schema: 2.0.0 +--- + +# Connect-SnipeitPS + +## SYNOPSIS +Sets authetication information + +## SYNTAX + +### Connect with url and apikey (Default) +``` +Connect-SnipeitPS -url -apiKey [] +``` + +### Connect with url and secure apikey +``` +Connect-SnipeitPS -url -secureApiKey [] +``` + +### Connect with credential +``` +Connect-SnipeitPS -siteCred [] +``` + +## DESCRIPTION +Sets apikey and url to connect Snipe-It system. +Based on Set-SnipeitInfo command, what is now just combatipility wrapper +and calls Connect-SnipeitPS + +## EXAMPLES + +### EXAMPLE 1 +``` +Connect-SnipeitPS -Url $url -apiKey $myapikey +Connect to Snipe it api. +``` + +### EXAMPLE 2 +``` +Connect-SnipeitPS -Url $url -SecureApiKey $myapikey +Connects to Snipe it api with apikey stored to securestring +``` + +### EXAMPLE 3 +``` +Connect-SnipeitPS -siteCred (Get-Credential -message "Use site url as username and apikey as password") +Connect to Snipe It with PSCredential object. +To use saved creadentials yu can use export-clixml and import-clixml commandlets. +``` + +### EXAMPLE 4 +``` +Build credential with apikey value from secret vault (Microsoft.PowerShell.SecretManagement) +$siteurl = "https://mysnipeitsite.url" +$apikey = Get-SecretInfo -Name SnipeItApiKey +$siteCred = New-Object -Type PSCredential -Argumentlist $siteurl,$spikey +Connect-SnipeitPS -siteCred $siteCred +``` + +## PARAMETERS + +### -apiKey +User's API Key for Snipeit. + +```yaml +Type: String +Parameter Sets: Connect with url and apikey +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -secureApiKey +Snipe it Api key as securestring + +```yaml +Type: SecureString +Parameter Sets: Connect with url and secure apikey +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -siteCred +PSCredential where username shoul be snipe it url and password should be +snipe it apikey. + +```yaml +Type: PSCredential +Parameter Sets: Connect with credential +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -url +URL of Snipeit system. + +```yaml +Type: Uri +Parameter Sets: Connect with url and apikey, Connect with url and secure apikey +Aliases: + +Required: True +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/Get-SnipeitAccessory.md b/docs/Get-SnipeitAccessory.md index 680c5a1..8f13557 100644 --- a/docs/Get-SnipeitAccessory.md +++ b/docs/Get-SnipeitAccessory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,17 +16,17 @@ Gets a list of Snipe-it Accessories ``` Get-SnipeitAccessory [-search ] [-company_id ] [-category_id ] [-manufacturer_id ] [-supplier_id ] [-sort ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Get by ID ``` -Get-SnipeitAccessory [-id ] -url -apiKey [] +Get-SnipeitAccessory [-id ] [-url ] [-apiKey ] [] ``` ### Accessories checked out to user id ``` -Get-SnipeitAccessory [-user_id ] [-all] -url -apiKey [] +Get-SnipeitAccessory [-user_id ] [-all] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -68,14 +68,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -235,14 +236,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitAccessoryOwner.md b/docs/Get-SnipeitAccessoryOwner.md index 914d9ea..f89f528 100644 --- a/docs/Get-SnipeitAccessoryOwner.md +++ b/docs/Get-SnipeitAccessoryOwner.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Get list of checked out accessories ## SYNTAX ``` -Get-SnipeitAccessoryOwner [-id] [-url] [-apiKey] [-WhatIf] [-Confirm] +Get-SnipeitAccessoryOwner [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -30,14 +30,15 @@ Get-SnipeitAccessoryOwner -id 1 ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -60,14 +61,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitActivity.md b/docs/Get-SnipeitActivity.md index 8e656b3..8aeaeff 100644 --- a/docs/Get-SnipeitActivity.md +++ b/docs/Get-SnipeitActivity.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Gets and search Snipe-it Activity history ``` Get-SnipeitActivity [[-search] ] [[-target_type] ] [[-target_id] ] [[-item_type] ] [[-item_id] ] [[-action_type] ] [[-limit] ] [[-offset] ] - [-all] [-url] [-apiKey] [] + [-all] [[-url] ] [[-apiKey] ] [] ``` ## DESCRIPTION @@ -67,14 +67,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False @@ -189,14 +190,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitAsset.md b/docs/Get-SnipeitAsset.md index db43ac2..d48be29 100644 --- a/docs/Get-SnipeitAsset.md +++ b/docs/Get-SnipeitAsset.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -17,46 +17,46 @@ Gets a list of Snipe-it Assets or specific asset Get-SnipeitAsset [-search ] [-order_number ] [-model_id ] [-category_id ] [-manufacturer_id ] [-company_id ] [-location_id ] [-depreciation_id ] [-requestable ] [-status ] [-status_id ] [-sort ] [-order ] - [-limit ] [-offset ] [-all] -url -apiKey [] + [-limit ] [-offset ] [-all] [-url ] [-apiKey ] [] ``` ### Get with id ``` -Get-SnipeitAsset [-id ] -url -apiKey [] +Get-SnipeitAsset [-id ] [-url ] [-apiKey ] [] ``` ### Get with asset tag ``` -Get-SnipeitAsset [-asset_tag ] -url -apiKey [] +Get-SnipeitAsset [-asset_tag ] [-url ] [-apiKey ] [] ``` ### Get with serial ``` -Get-SnipeitAsset [-serial ] -url -apiKey [] +Get-SnipeitAsset [-serial ] [-url ] [-apiKey ] [] ``` ### Assets due auditing soon ``` Get-SnipeitAsset [-audit_due] [-sort ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Assets overdue for auditing ``` Get-SnipeitAsset [-audit_overdue] [-sort ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Assets checked out to user id ``` Get-SnipeitAsset [-user_id ] [-sort ] [-order ] [-limit ] [-offset ] - [-all] -url -apiKey [] + [-all] [-url ] [-apiKey ] [] ``` ### Assets with component id ``` Get-SnipeitAsset [-component_id ] [-sort ] [-order ] [-limit ] [-offset ] - [-all] -url -apiKey [] + [-all] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -66,7 +66,7 @@ Get-SnipeitAsset [-component_id ] [-sort ] [-order ] [-li ### EXAMPLE 1 ``` -Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..." +Get-SnipeitAsset -all Returens all assets ``` @@ -136,14 +136,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -468,14 +469,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitAssetMaintenance.md b/docs/Get-SnipeitAssetMaintenance.md index 8ca5d36..fb5fcc9 100644 --- a/docs/Get-SnipeitAssetMaintenance.md +++ b/docs/Get-SnipeitAssetMaintenance.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Lists Snipe-it Assets Maintenances ``` Get-SnipeitAssetMaintenance [[-search] ] [[-asset_id] ] [[-sort] ] [[-order] ] - [[-limit] ] [-all] [[-offset] ] [-url] [-apiKey] [] + [[-limit] ] [-all] [[-offset] ] [[-url] ] [[-apiKey] ] [] ``` ## DESCRIPTION @@ -24,17 +24,17 @@ Get-SnipeitAssetMaintenance [[-search] ] [[-asset_id] ] [[-sort] ### EXAMPLE 1 ``` -Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..." +Get-SnipeitAssetMaintenances ``` ### EXAMPLE 2 ``` -Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..." +Get-SnipeitAssetMaintenances -search "myMachine" ``` ### EXAMPLE 3 ``` -Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..." +Get-SnipeitAssetMaintenances -search "myMachine" ``` ## PARAMETERS @@ -55,14 +55,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 8 Default value: None Accept pipeline input: False @@ -162,14 +163,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 7 Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitCategory.md b/docs/Get-SnipeitCategory.md index d430813..903fd32 100644 --- a/docs/Get-SnipeitCategory.md +++ b/docs/Get-SnipeitCategory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,12 +15,12 @@ Gets a list of Snipe-it Categories ### Search (Default) ``` Get-SnipeitCategory [-search ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitCategory [-id ] -url -apiKey [] +Get-SnipeitCategory [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -56,14 +56,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -148,14 +149,15 @@ Accept wildcard characters: False ``` ### -url -Url of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Url of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitCompany.md b/docs/Get-SnipeitCompany.md index 6f46298..f69206c 100644 --- a/docs/Get-SnipeitCompany.md +++ b/docs/Get-SnipeitCompany.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,13 +14,13 @@ Gets a list of Snipe-it Companies ### Search (Default) ``` -Get-SnipeitCompany [-search ] [-order ] [-limit ] [-offset ] [-all] -url - -apiKey [] +Get-SnipeitCompany [-search ] [-order ] [-limit ] [-offset ] [-all] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitCompany [-id ] -url -apiKey [] +Get-SnipeitCompany [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -58,14 +58,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -150,14 +151,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitComponent.md b/docs/Get-SnipeitComponent.md index c8a6cfe..ce7efb4 100644 --- a/docs/Get-SnipeitComponent.md +++ b/docs/Get-SnipeitComponent.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,13 +15,13 @@ Gets a list of Snipe-it Components ### Search (Default) ``` Get-SnipeitComponent [-search ] [-category_id ] [-company_id ] [-location_id ] - [-order ] [-sort ] [-limit ] [-offset ] [-all] -url -apiKey - [] + [-order ] [-sort ] [-limit ] [-offset ] [-all] [-url ] + [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitComponent [-id ] -url -apiKey [] +Get-SnipeitComponent [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -65,14 +65,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -217,14 +218,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system,can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitConsumable.md b/docs/Get-SnipeitConsumable.md index 5286b59..c94552b 100644 --- a/docs/Get-SnipeitConsumable.md +++ b/docs/Get-SnipeitConsumable.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,12 +16,12 @@ Gets a list of Snipe-it consumables ``` Get-SnipeitConsumable [-search ] [-category_id ] [-company_id ] [-manufacturer_id ] [-location_id ] [-order ] [-sort ] [-expand] - [-limit ] [-offset ] [-all] -url -apiKey [] + [-limit ] [-offset ] [-all] [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitConsumable [-id ] -url -apiKey [] +Get-SnipeitConsumable [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -65,14 +65,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -247,14 +248,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system,can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitCustomField.md b/docs/Get-SnipeitCustomField.md index 7e60a99..de31e6a 100644 --- a/docs/Get-SnipeitCustomField.md +++ b/docs/Get-SnipeitCustomField.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Returns specific Snipe-IT custom field or a list of all custom field ## SYNTAX ``` -Get-SnipeitCustomField [[-id] ] [-url] [-apiKey] [] +Get-SnipeitCustomField [[-id] ] [[-url] ] [[-apiKey] ] [] ``` ## DESCRIPTION @@ -23,20 +23,28 @@ Get-SnipeitCustomField [[-id] ] [-url] [-apiKey] [] [-order ] [-limit ] [-offset ] [-all] - [-sort ] -url -apiKey [] + [-sort ] [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitDepartment [-id ] -url -apiKey [] +Get-SnipeitDepartment [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -30,7 +30,7 @@ Get-SnipeitDepartment [-id ] -url -apiKey [] [-url] [-apiKey] [] +Get-SnipeitFieldset [[-id] ] [[-url] ] [[-apiKey] ] [] ``` ## DESCRIPTION @@ -23,25 +23,28 @@ Get-SnipeitFieldset [[-id] ] [-url] [-apiKey] [] [-name ] [-company_id ] [-product_key ] [-order_number ] [-purchase_order ] [-license_name ] [-license_email ] [-manufacturer_id ] [-supplier_id ] [-depreciation_id ] [-category_id ] - [-order ] [-sort ] [-limit ] [-offset ] [-all] -url -apiKey - [] + [-order ] [-sort ] [-limit ] [-offset ] [-all] [-url ] + [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitLicense [-id ] -url -apiKey [] +Get-SnipeitLicense [-id ] [-url ] [-apiKey ] [] ``` ### Get licenses checked out to user ID ``` -Get-SnipeitLicense [-user_id ] [-all] -url -apiKey [] +Get-SnipeitLicense [-user_id ] [-all] [-url ] [-apiKey ] [] ``` ### Get licenses checked out to asset ID ``` -Get-SnipeitLicense [-asset_id ] [-all] -url -apiKey [] +Get-SnipeitLicense [-asset_id ] [-all] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -69,14 +69,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -356,14 +357,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitLicenseSeat.md b/docs/Get-SnipeitLicenseSeat.md index 7f74a74..cb07d28 100644 --- a/docs/Get-SnipeitLicenseSeat.md +++ b/docs/Get-SnipeitLicenseSeat.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Gets a list of Snipe-it Licenses Seats or specific Seat ``` Get-SnipeitLicenseSeat [-id] [[-seat_id] ] [[-limit] ] [[-offset] ] [-all] - [-url] [-apiKey] [] + [[-url] ] [[-apiKey] ] [] ``` ## DESCRIPTION @@ -45,14 +45,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 6 Default value: None Accept pipeline input: False @@ -122,14 +123,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 5 Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitLocation.md b/docs/Get-SnipeitLocation.md index a45b9cd..0f068eb 100644 --- a/docs/Get-SnipeitLocation.md +++ b/docs/Get-SnipeitLocation.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,12 +15,12 @@ Gets a list of Snipe-it Locations ### Search (Default) ``` Get-SnipeitLocation [-search ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitLocation [-id ] -url -apiKey [] +Get-SnipeitLocation [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -56,14 +56,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -148,14 +149,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitManufacturer.md b/docs/Get-SnipeitManufacturer.md index 533212a..00c9e6c 100644 --- a/docs/Get-SnipeitManufacturer.md +++ b/docs/Get-SnipeitManufacturer.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,12 +15,12 @@ schema: 2.0.0 ### Search (Default) ``` Get-SnipeitManufacturer [-search ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitManufacturer [-id ] -url -apiKey [] +Get-SnipeitManufacturer [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -58,14 +58,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -150,14 +151,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitModel.md b/docs/Get-SnipeitModel.md index 0094e59..6878f2e 100644 --- a/docs/Get-SnipeitModel.md +++ b/docs/Get-SnipeitModel.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,13 +14,13 @@ Gets a list of Snipe-it Models ### Search (Default) ``` -Get-SnipeitModel [-search ] [-order ] [-limit ] [-offset ] [-all] -url - -apiKey [] +Get-SnipeitModel [-search ] [-order ] [-limit ] [-offset ] [-all] [-url ] + [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitModel [-id ] -url -apiKey [] +Get-SnipeitModel [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -56,14 +56,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -148,14 +149,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitStatus.md b/docs/Get-SnipeitStatus.md index 9740cb4..320e210 100644 --- a/docs/Get-SnipeitStatus.md +++ b/docs/Get-SnipeitStatus.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,13 +14,13 @@ Gets a list of Snipe-it Status Labels ### Search (Default) ``` -Get-SnipeitStatus [-search ] [-order ] [-limit ] [-offset ] [-all] -url - -apiKey [] +Get-SnipeitStatus [-search ] [-order ] [-limit ] [-offset ] [-all] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitStatus [-id ] -url -apiKey [] +Get-SnipeitStatus [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -56,14 +56,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -148,14 +149,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitSupplier.md b/docs/Get-SnipeitSupplier.md index 6b7be7b..697c094 100644 --- a/docs/Get-SnipeitSupplier.md +++ b/docs/Get-SnipeitSupplier.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,12 +15,12 @@ schema: 2.0.0 ### Search (Default) ``` Get-SnipeitSupplier [-search ] [-order ] [-limit ] [-offset ] [-all] - -url -apiKey [] + [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitSupplier [-id ] -url -apiKey [] +Get-SnipeitSupplier [-id ] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -56,14 +56,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -148,14 +149,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/Get-SnipeitUser.md b/docs/Get-SnipeitUser.md index 05e6766..36c8fd5 100644 --- a/docs/Get-SnipeitUser.md +++ b/docs/Get-SnipeitUser.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,17 +16,17 @@ schema: 2.0.0 ``` Get-SnipeitUser [-search ] [-company_id ] [-location_id ] [-group_id ] [-department_id ] [-username ] [-email ] [-order ] [-limit ] - [-offset ] [-all] -url -apiKey [] + [-offset ] [-all] [-url ] [-apiKey ] [] ``` ### Get with ID ``` -Get-SnipeitUser [-id ] -url -apiKey [] +Get-SnipeitUser [-id ] [-url ] [-apiKey ] [] ``` ### Get users a specific accessory id has been checked out to ``` -Get-SnipeitUser [-accessory_id ] [-all] -url -apiKey [] +Get-SnipeitUser [-accessory_id ] [-all] [-url ] [-apiKey ] [] ``` ## DESCRIPTION @@ -93,14 +93,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -260,14 +261,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitAccessory.md b/docs/New-SnipeitAccessory.md index 27acd04..2c40405 100644 --- a/docs/New-SnipeitAccessory.md +++ b/docs/New-SnipeitAccessory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,7 +16,7 @@ Creates new accessory on Snipe-It system New-SnipeitAccessory [-name] [-qty] [-category_id] [[-company_id] ] [[-manufacturer_id] ] [[-order_number] ] [[-model_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] [[-location_id] ] - [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -32,14 +32,15 @@ New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 15 Default value: None Accept pipeline input: False @@ -242,14 +243,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 14 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitAsset.md b/docs/New-SnipeitAsset.md index 47ef1fa..a9676fb 100644 --- a/docs/New-SnipeitAsset.md +++ b/docs/New-SnipeitAsset.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -17,7 +17,7 @@ Add a new Asset to Snipe-it asset system New-SnipeitAsset -status_id -model_id [-name ] [-asset_tag ] [-serial ] [-company_id ] [-order_number ] [-notes ] [-warranty_months ] [-purchase_cost ] [-purchase_date ] [-supplier_id ] [-rtd_location_id ] - [-image ] -url -apiKey [-customfields ] [-WhatIf] [-Confirm] + [-image ] [-url ] [-apiKey ] [-customfields ] [-WhatIf] [-Confirm] [] ``` @@ -26,7 +26,7 @@ New-SnipeitAsset -status_id -model_id [-name ] [-asset_t New-SnipeitAsset -status_id -model_id [-name ] [-asset_tag ] [-serial ] [-company_id ] [-order_number ] [-notes ] [-warranty_months ] [-purchase_cost ] [-purchase_date ] [-supplier_id ] [-rtd_location_id ] - [-image ] -assigned_id -checkout_to_type -url -apiKey + [-image ] -assigned_id -checkout_to_type [-url ] [-apiKey ] [-customfields ] [-WhatIf] [-Confirm] [] ``` @@ -56,14 +56,15 @@ Using customfields when creating asset. ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -312,14 +313,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitAssetMaintenance.md b/docs/New-SnipeitAssetMaintenance.md index 9e047b9..d0cd6be 100644 --- a/docs/New-SnipeitAssetMaintenance.md +++ b/docs/New-SnipeitAssetMaintenance.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Add a new Asset maintenence to Snipe-it asset system ``` New-SnipeitAssetMaintenance [-asset_id] [-supplier_id] [-asset_maintenance_type] [-title] [-start_date] [[-completion_date] ] [[-is_warranty] ] - [[-cost] ] [[-notes] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [[-cost] ] [[-notes] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -32,14 +32,15 @@ New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 11 Default value: None Accept pipeline input: False @@ -182,14 +183,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitAudit.md b/docs/New-SnipeitAudit.md index 5925779..742fa24 100644 --- a/docs/New-SnipeitAudit.md +++ b/docs/New-SnipeitAudit.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Add a new Audit to Snipe-it asset system ## SYNTAX ``` -New-SnipeitAudit [-tag] [[-location_id] ] [-url] [-apiKey] [-WhatIf] +New-SnipeitAudit [-tag] [[-location_id] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -37,7 +37,7 @@ Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 4 Default value: None Accept pipeline input: False @@ -82,7 +82,7 @@ Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitCategory.md b/docs/New-SnipeitCategory.md index 927766d..4586644 100644 --- a/docs/New-SnipeitCategory.md +++ b/docs/New-SnipeitCategory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Create a new Snipe-IT Category ``` New-SnipeitCategory [-name] [-category_type] [[-eula_text] ] [-use_default_eula] - [-require_acceptance] [-checkin_email] [[-image] ] [-url] [-apiKey] [-WhatIf] + [-require_acceptance] [-checkin_email] [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -25,20 +25,21 @@ New-SnipeitCategory [-name] [-category_type] [[-eula_text] [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] +New-SnipeitCompany [-name] [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -30,14 +30,15 @@ New-SnipeitCompany -name "Acme Company" ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 4 Default value: None Accept pipeline input: False @@ -75,14 +76,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitComponent.md b/docs/New-SnipeitComponent.md index 3f230a2..4680317 100644 --- a/docs/New-SnipeitComponent.md +++ b/docs/New-SnipeitComponent.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Create a new component ``` New-SnipeitComponent [-name] [-category_id] [-qty] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -25,20 +25,21 @@ Createa new componen on Snipe-It system ### EXAMPLE 1 ``` -An example +New-SnipeitComponent -name 'Display adapter' -catecory_id 3 -qty 10 ``` ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 11 Default value: None Accept pipeline input: False @@ -181,14 +182,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False @@ -234,6 +236,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS ## NOTES -General notes ## RELATED LINKS diff --git a/docs/New-SnipeitConsumable.md b/docs/New-SnipeitConsumable.md index 4778e65..e7bd1c2 100644 --- a/docs/New-SnipeitConsumable.md +++ b/docs/New-SnipeitConsumable.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,7 +16,7 @@ Add a new Consumable to Snipe-it asset system New-SnipeitConsumable [-name] [-qty] [-category_id] [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-model_number] ] [[-item_no] ] [[-image] ] [-url] [-apiKey] + [[-model_number] ] [[-item_no] ] [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,14 +34,15 @@ Create consumable with stock count 20 , alert when stock is 5 or lower ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 16 Default value: None Accept pipeline input: False @@ -259,14 +260,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 15 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitCustomField.md b/docs/New-SnipeitCustomField.md index e30a6ab..f0563eb 100644 --- a/docs/New-SnipeitCustomField.md +++ b/docs/New-SnipeitCustomField.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Add a new Custom Field to Snipe-it asset system ``` New-SnipeitCustomField [-name] [[-help_text] ] [-element] [-format] [[-field_values] ] [[-field_encrypted] ] [[-show_in_email] ] - [[-custom_format] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-custom_format] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -31,14 +31,15 @@ New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "I ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False @@ -167,14 +168,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitDepartment.md b/docs/New-SnipeitDepartment.md index cd96ed7..b9b65e6 100644 --- a/docs/New-SnipeitDepartment.md +++ b/docs/New-SnipeitDepartment.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Creates a department ``` New-SnipeitDepartment [-name] [[-company_id] ] [[-location_id] ] [[-manager_id] ] - [[-notes] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] + [[-notes] ] [[-image] ] [-image_delete] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -31,14 +31,15 @@ New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 8 Default value: None Accept pipeline input: False @@ -151,14 +152,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 7 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitLicense.md b/docs/New-SnipeitLicense.md index 73f46b1..b675686 100644 --- a/docs/New-SnipeitLicense.md +++ b/docs/New-SnipeitLicense.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -17,7 +17,7 @@ New-SnipeitLicense [-name] [-seats] [[-category_id] ] [[ [[-expiration_date] ] [[-license_email] ] [[-license_name] ] [[-maintained] ] [[-manufacturer_id] ] [[-notes] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-reassignable] ] [[-serial] ] - [[-supplier_id] ] [[-termination_date] ] [-url] [-apiKey] [-WhatIf] + [[-supplier_id] ] [[-termination_date] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,14 +34,15 @@ New-SnipeitLicence -name "License" -seats 3 -company_id 1 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 19 Default value: None Accept pipeline input: False @@ -304,14 +305,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 18 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitLocation.md b/docs/New-SnipeitLocation.md index 744b3f2..4d00b92 100644 --- a/docs/New-SnipeitLocation.md +++ b/docs/New-SnipeitLocation.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,8 +15,8 @@ Add a new Location to Snipe-it asset system ``` New-SnipeitLocation [-name] [[-address] ] [[-address2] ] [[-city] ] [[-state] ] [[-country] ] [[-zip] ] [[-currency] ] [[-parent_id] ] - [[-manager_id] ] [[-ldap_ou] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-manager_id] ] [[-ldap_ou] ] [[-image] ] [-image_delete] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -62,14 +62,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 14 Default value: None Accept pipeline input: False @@ -227,14 +228,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 13 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitManufacturer.md b/docs/New-SnipeitManufacturer.md index d5e266a..292c20e 100644 --- a/docs/New-SnipeitManufacturer.md +++ b/docs/New-SnipeitManufacturer.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,8 +13,8 @@ Add a new Manufacturer to Snipe-it asset system ## SYNTAX ``` -New-SnipeitManufacturer [-Name] [[-image] ] [-image_delete] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] +New-SnipeitManufacturer [-Name] [[-image] ] [-image_delete] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -30,14 +30,15 @@ New-SnipeitManufacturer -name "HP" ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 4 Default value: None Accept pipeline input: False @@ -90,14 +91,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitModel.md b/docs/New-SnipeitModel.md index 564f431..22ff905 100644 --- a/docs/New-SnipeitModel.md +++ b/docs/New-SnipeitModel.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Add a new Model to Snipe-it asset system ``` New-SnipeitModel [-name] [[-model_number] ] [-category_id] [-manufacturer_id] - [[-eol] ] [-fieldset_id] [[-image] ] [-url] [-apiKey] [-WhatIf] + [[-eol] ] [-fieldset_id] [[-image] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -31,14 +31,15 @@ New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False @@ -151,14 +152,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 8 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitSupplier.md b/docs/New-SnipeitSupplier.md index 3892b88..fd61645 100644 --- a/docs/New-SnipeitSupplier.md +++ b/docs/New-SnipeitSupplier.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,8 +15,8 @@ Creates a supplier ``` New-SnipeitSupplier [-name] [[-address] ] [[-address2] ] [[-city] ] [[-state] ] [[-country] ] [[-zip] ] [[-phone] ] [[-fax] ] - [[-email] ] [[-contact] ] [[-notes] ] [[-image] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-email] ] [[-contact] ] [[-notes] ] [[-image] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -62,14 +62,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 15 Default value: None Accept pipeline input: False @@ -227,14 +228,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 14 Default value: None Accept pipeline input: False diff --git a/docs/New-SnipeitUser.md b/docs/New-SnipeitUser.md index e830d0a..ce9d40d 100644 --- a/docs/New-SnipeitUser.md +++ b/docs/New-SnipeitUser.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,8 +16,8 @@ Creates a new user New-SnipeitUser [-first_name] [-last_name] [-username] [[-password] ] [[-activated] ] [[-notes] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] - [[-employee_num] ] [[-ldap_import] ] [[-image] ] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] + [[-employee_num] ] [[-ldap_import] ] [[-image] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -49,14 +49,15 @@ Accept wildcard characters: False ``` ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 18 Default value: None Accept pipeline input: False @@ -274,14 +275,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 17 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitAccessory.md b/docs/Remove-SnipeitAccessory.md index 51ea7a9..f2d23ac 100644 --- a/docs/Remove-SnipeitAccessory.md +++ b/docs/Remove-SnipeitAccessory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes Accessory from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitAccessory [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitAccessory [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,15 +34,16 @@ Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitAsset.md b/docs/Remove-SnipeitAsset.md index 8ee957a..e61ff5e 100644 --- a/docs/Remove-SnipeitAsset.md +++ b/docs/Remove-SnipeitAsset.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes Asset from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitAsset [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitAsset [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,15 +34,16 @@ Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitAssetMaintenance.md b/docs/Remove-SnipeitAssetMaintenance.md index 75f5e2f..4604a8a 100644 --- a/docs/Remove-SnipeitAssetMaintenance.md +++ b/docs/Remove-SnipeitAssetMaintenance.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Remove asset maintenance from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitAssetMaintenance [-id] [-url] [-apiKey] [-WhatIf] [-Confirm] +Remove-SnipeitAssetMaintenance [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,20 +24,20 @@ Removes asset maintenance event or events from Snipe-it asset system by ID ### EXAMPLE 1 ``` -Remove-SnipeitAssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose +Remove-SnipeitAssetMaintenance -ID 44 ``` ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +{{ Fill apiKey Description }} ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -60,14 +60,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitCategory.md b/docs/Remove-SnipeitCategory.md index 34734d6..39366e9 100644 --- a/docs/Remove-SnipeitCategory.md +++ b/docs/Remove-SnipeitCategory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes category from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitCategory [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitCategory [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes category or multiple categories from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitCategory -ID 44 -Verbose +Remove-SnipeitCategory -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitCategory -search something | Remove-SnipeitCategory ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitCompany.md b/docs/Remove-SnipeitCompany.md index b1609af..6d97257 100644 --- a/docs/Remove-SnipeitCompany.md +++ b/docs/Remove-SnipeitCompany.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes Company from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitCompany [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitCompany [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes Company or multiple Companies from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitCompany -ID 44 -Verbose +Remove-SnipeitCompany -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCom ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitComponent.md b/docs/Remove-SnipeitComponent.md index 0e68c5a..91a6ac7 100644 --- a/docs/Remove-SnipeitComponent.md +++ b/docs/Remove-SnipeitComponent.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes component from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitComponent [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitComponent [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes component or multiple components from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitComponent -ID 44 -Verbose +Remove-SnipeitComponent -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitConsumable.md b/docs/Remove-SnipeitConsumable.md index 82a0e2d..15f3726 100644 --- a/docs/Remove-SnipeitConsumable.md +++ b/docs/Remove-SnipeitConsumable.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes consumable from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitConsumable [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitConsumable [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,25 +24,26 @@ Removes consumable or multiple consumables from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitConsumable -ID 44 -Verbose +Remove-SnipeitConsumable -ID 44 ``` ### EXAMPLE 2 ``` -Get-SnipeitConsumable -search "paper" | Remove-Snipeitconsumable +Get-SnipeitConsumable -search "paper" | Remove-SnipeitConsumable ``` ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitCustomField.md b/docs/Remove-SnipeitCustomField.md index fa21c51..aa8c987 100644 --- a/docs/Remove-SnipeitCustomField.md +++ b/docs/Remove-SnipeitCustomField.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes custom field from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitCustomField [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitCustomField [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,15 +34,16 @@ Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-Snip ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitDepartment.md b/docs/Remove-SnipeitDepartment.md index a2f99e3..ca4f501 100644 --- a/docs/Remove-SnipeitDepartment.md +++ b/docs/Remove-SnipeitDepartment.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes department from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitDepartment [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitDepartment [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes department or multiple departments from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitDepartment -ID 44 -Verbose +Remove-SnipeitDepartment -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDe ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitLicense.md b/docs/Remove-SnipeitLicense.md index e778b67..390a507 100644 --- a/docs/Remove-SnipeitLicense.md +++ b/docs/Remove-SnipeitLicense.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes licence from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitLicense [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitLicense [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes licence or multiple licenses from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitLicence -ID 44 -Verbose +Remove-SnipeitLicence -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitLocation.md b/docs/Remove-SnipeitLocation.md index a7e8d11..bc20d98 100644 --- a/docs/Remove-SnipeitLocation.md +++ b/docs/Remove-SnipeitLocation.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes Location from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitLocation [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitLocation [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes localtion or multiple locations from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitLocation -ID 44 -Verbose +Remove-SnipeitLocation -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitManufacturer.md b/docs/Remove-SnipeitManufacturer.md index ab0a019..0d86a5f 100644 --- a/docs/Remove-SnipeitManufacturer.md +++ b/docs/Remove-SnipeitManufacturer.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes manufacturer from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitManufacturer [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitManufacturer [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes manufacturer or multiple manufacturers from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitManufacturer -ID 44 -Verbose +Remove-SnipeitManufacturer -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-S ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitModel.md b/docs/Remove-SnipeitModel.md index 04592bd..f42dd81 100644 --- a/docs/Remove-SnipeitModel.md +++ b/docs/Remove-SnipeitModel.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes Asset model from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitModel [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitModel [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Removes asset model or multiple assets models from Snipe-it asset system ### EXAMPLE 1 ``` -Remove-SnipeitModel -ID 44 -Verbose +Remove-SnipeitModel -ID 44 ``` ### EXAMPLE 2 @@ -34,15 +34,16 @@ Get-SnipeitModel -search needle | Remove-SnipeitModel ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitSupplier.md b/docs/Remove-SnipeitSupplier.md index 4fcae40..aebe6ae 100644 --- a/docs/Remove-SnipeitSupplier.md +++ b/docs/Remove-SnipeitSupplier.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Removes supplier from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitSupplier [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] +Remove-SnipeitSupplier [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -34,15 +34,16 @@ Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-Snipe ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -64,15 +65,16 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Remove-SnipeitUser.md b/docs/Remove-SnipeitUser.md index 850d37f..3241c7b 100644 --- a/docs/Remove-SnipeitUser.md +++ b/docs/Remove-SnipeitUser.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,8 @@ Removes User from Snipe-it asset system ## SYNTAX ``` -Remove-SnipeitUser [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] [] +Remove-SnipeitUser [-id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -28,15 +29,16 @@ Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose ## PARAMETERS -### -APIKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +### -apiKey +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -47,26 +49,27 @@ Accept wildcard characters: False Unique ID For User to be removed ```yaml -Type: Int32 +Type: Int32[] Parameter Sets: (All) Aliases: Required: True Position: 1 -Default value: 0 +Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -URL -URL of Snipeit system, can be set using Set-SnipeitInfo command +### -url +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Reset-SnipeitAccessoryOwner.md b/docs/Reset-SnipeitAccessoryOwner.md index 8d8e733..61c6025 100644 --- a/docs/Reset-SnipeitAccessoryOwner.md +++ b/docs/Reset-SnipeitAccessoryOwner.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,7 +13,7 @@ Checkin accessories ## SYNTAX ``` -Reset-SnipeitAccessoryOwner [-assigned_pivot_id] [-url] [-apiKey] [-WhatIf] +Reset-SnipeitAccessoryOwner [-assigned_pivot_id] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -36,14 +36,15 @@ Get-SnipeitAccessoryOwner -assigned_pivot_id xxx ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 3 Default value: None Accept pipeline input: False @@ -67,14 +68,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 2 Default value: None Accept pipeline input: False diff --git a/docs/Reset-SnipeitAssetOwner.md b/docs/Reset-SnipeitAssetOwner.md index f901aeb..d2488c5 100644 --- a/docs/Reset-SnipeitAssetOwner.md +++ b/docs/Reset-SnipeitAssetOwner.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Checkin asset ``` Reset-SnipeitAssetOwner [-id] [[-status_id] ] [[-location_id] ] [[-notes] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -24,20 +24,21 @@ Checks asset in from current user/localtion/asset ### EXAMPLE 1 ``` -Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose +Remove-SnipeitUser -ID 44 ``` ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 6 Default value: None Accept pipeline input: False @@ -105,14 +106,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 5 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitAccessory.md b/docs/Set-SnipeitAccessory.md index 3d689f6..5795ed7 100644 --- a/docs/Set-SnipeitAccessory.md +++ b/docs/Set-SnipeitAccessory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,8 +16,8 @@ Updates accessory on Snipe-It system Set-SnipeitAccessory [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-company_id] ] [[-manufacturer_id] ] [[-model_number] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] - [[-location_id] ] [[-image] ] [-image_delete] [[-RequestType] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-location_id] ] [[-image] ] [-image_delete] [[-RequestType] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -33,14 +33,15 @@ Set-SnipeitAccessory -id 1 -qty 3 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 17 Default value: None Accept pipeline input: False @@ -289,14 +290,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 16 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitAccessoryOwner.md b/docs/Set-SnipeitAccessoryOwner.md index 52f65bc..448ce7a 100644 --- a/docs/Set-SnipeitAccessoryOwner.md +++ b/docs/Set-SnipeitAccessoryOwner.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,8 +13,8 @@ Checkout accessory ## SYNTAX ``` -Set-SnipeitAccessoryOwner [-id] [-assigned_to] [[-note] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] +Set-SnipeitAccessoryOwner [-id] [-assigned_to] [[-note] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -30,14 +30,15 @@ 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 +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 5 Default value: None Accept pipeline input: False @@ -90,14 +91,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 4 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitAsset.md b/docs/Set-SnipeitAsset.md index 84476cf..190ce3c 100644 --- a/docs/Set-SnipeitAsset.md +++ b/docs/Set-SnipeitAsset.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -17,8 +17,8 @@ Set-SnipeitAsset [-id] [[-name] ] [[-status_id] ] [[-mo [[-last_checkout] ] [[-assigned_to] ] [[-company_id] ] [[-serial] ] [[-order_number] ] [[-warranty_months] ] [[-purchase_cost] ] [[-purchase_date] ] [[-requestable] ] [[-archived] ] [[-rtd_location_id] ] - [[-notes] ] [[-RequestType] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [[-customfields] ] [-WhatIf] [-Confirm] [] + [[-notes] ] [[-RequestType] ] [[-image] ] [-image_delete] [[-url] ] + [[-apiKey] ] [[-customfields] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -44,14 +44,15 @@ Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated' ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 20 Default value: None Accept pipeline input: False @@ -346,14 +347,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 19 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitAssetOwner.md b/docs/Set-SnipeitAssetOwner.md index 1408e93..3f6fbf8 100644 --- a/docs/Set-SnipeitAssetOwner.md +++ b/docs/Set-SnipeitAssetOwner.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,8 +14,8 @@ Checkout asset ``` Set-SnipeitAssetOwner [-id] [-assigned_id] [[-checkout_to_type] ] [[-name] ] - [[-note] ] [[-expected_checkin] ] [[-checkout_at] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-note] ] [[-expected_checkin] ] [[-checkout_at] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -31,14 +31,15 @@ Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False @@ -154,14 +155,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 8 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitCategory.md b/docs/Set-SnipeitCategory.md index ffa7b95..bd0e875 100644 --- a/docs/Set-SnipeitCategory.md +++ b/docs/Set-SnipeitCategory.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Create a new Snipe-IT Category ``` Set-SnipeitCategory [-id] [[-name] ] [[-category_type] ] [[-eula_text] ] [[-use_default_eula] ] [[-require_acceptance] ] [[-checkin_email] ] - [[-image] ] [-image_delete] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] + [[-image] ] [-image_delete] [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -32,14 +32,15 @@ Set-SnipeitCategory -id 4 -name "Laptops" ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 11 Default value: None Accept pipeline input: False @@ -183,14 +184,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitCompany.md b/docs/Set-SnipeitCompany.md index 6c32fed..f607bde 100644 --- a/docs/Set-SnipeitCompany.md +++ b/docs/Set-SnipeitCompany.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Updates company name ``` Set-SnipeitCompany [-id] [-name] [[-image] ] [-image_delete] - [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -30,14 +30,15 @@ An example ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 6 Default value: None Accept pipeline input: False @@ -121,14 +122,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 5 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitComponent.md b/docs/Set-SnipeitComponent.md index 38312ae..47cea8b 100644 --- a/docs/Set-SnipeitComponent.md +++ b/docs/Set-SnipeitComponent.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,8 +15,8 @@ Updates component ``` Set-SnipeitComponent [-id] [-qty] [[-min_amt] ] [[-name] ] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] - [[-purchase_cost] ] [[-image] ] [-image_delete] [[-RequestType] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-purchase_cost] ] [[-image] ] [-image_delete] [[-RequestType] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -26,20 +26,22 @@ Updates component on Snipe-It system ### EXAMPLE 1 ``` -An example +Set-SnipeitComponent -id 42 -qty 12 +Sets count of component with ID 42 to 12 ``` ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 13 Default value: None Accept pipeline input: False @@ -228,14 +230,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 12 Default value: None Accept pipeline input: False @@ -281,6 +284,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS ## NOTES -General notes ## RELATED LINKS diff --git a/docs/Set-SnipeitConsumable.md b/docs/Set-SnipeitConsumable.md index ec673c0..6cf3fb3 100644 --- a/docs/Set-SnipeitConsumable.md +++ b/docs/Set-SnipeitConsumable.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -17,7 +17,7 @@ Set-SnipeitConsumable [-id] [[-name] ] [[-qty] ] [[-cat [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [[-RequestType] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -34,14 +34,15 @@ Create consumable with stock count 20 , alert when stock is 5 or lower ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 18 Default value: None Accept pipeline input: False @@ -305,14 +306,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 17 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitCustomField.md b/docs/Set-SnipeitCustomField.md index 8606f6d..dba0b55 100644 --- a/docs/Set-SnipeitCustomField.md +++ b/docs/Set-SnipeitCustomField.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,8 +15,8 @@ Add a new Custom Field to Snipe-it asset system ``` Set-SnipeitCustomField [-id] [[-name] ] [[-help_text] ] [-element] [[-format] ] [[-field_values] ] [[-field_encrypted] ] [[-show_in_email] ] - [[-custom_format] ] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-custom_format] ] [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -32,14 +32,15 @@ New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "I ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 12 Default value: None Accept pipeline input: False @@ -199,14 +200,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 11 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitDepartment.md b/docs/Set-SnipeitDepartment.md index e3de315..84f5a07 100644 --- a/docs/Set-SnipeitDepartment.md +++ b/docs/Set-SnipeitDepartment.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Updates a department ``` Set-SnipeitDepartment [-id] [[-name] ] [[-company_id] ] [[-location_id] ] [[-manager_id] ] [[-notes] ] [[-image] ] [-image_delete] [[-RequestType] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -31,14 +31,15 @@ Set-SnipeitDepartment -id 4 -manager_id 3 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False @@ -182,14 +183,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitInfo.md b/docs/Set-SnipeitInfo.md index cb41bfc..6c004cf 100644 --- a/docs/Set-SnipeitInfo.md +++ b/docs/Set-SnipeitInfo.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -8,16 +8,18 @@ schema: 2.0.0 # Set-SnipeitInfo ## SYNOPSIS -Sets authetication information +Sets authetication information. +Deprecated, use Connect-SnipeitPS instead. ## SYNTAX ``` -Set-SnipeitInfo [[-url] ] [[-apiKey] ] [] +Set-SnipeitInfo [-url] [-apiKey] [] ``` ## DESCRIPTION -Set apikey and url user to connect Snipe-It system +Deprecated combatibilty function that Set apikey and url user to connect Snipe-It system. +Please use Connect-SnipeitPS instead. ## EXAMPLES @@ -29,14 +31,14 @@ Set-SnipeitInfo -url $url -apiKey -Verbose ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 2 Default value: None Accept pipeline input: False @@ -44,14 +46,14 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +URL of Snipeit system. ```yaml Type: Uri Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 1 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitLicense.md b/docs/Set-SnipeitLicense.md index 00a36ea..1482a72 100644 --- a/docs/Set-SnipeitLicense.md +++ b/docs/Set-SnipeitLicense.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -18,7 +18,7 @@ Set-SnipeitLicense [-id] [[-name] ] [[-seats] ] [[-cate [[-license_name] ] [[-maintained] ] [[-manufacturer_id] ] [[-notes] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-reassignable] ] [[-serial] ] [[-supplier_id] ] [[-termination_date] ] - [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -34,14 +34,15 @@ Set-SnipeitLicence -name "License" -seats 3 -company_id 1 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 21 Default value: None Accept pipeline input: False @@ -335,14 +336,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 20 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitLicenseSeat.md b/docs/Set-SnipeitLicenseSeat.md index f8ba02b..4948f93 100644 --- a/docs/Set-SnipeitLicenseSeat.md +++ b/docs/Set-SnipeitLicenseSeat.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Set license seat or checkout license seat ``` Set-SnipeitLicenseSeat [-id] [-seat_id] [[-assigned_to] ] [[-asset_id] ] - [[-note] ] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [[-note] ] [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -44,14 +44,15 @@ Checkin licence seat id 1 of licence id 1 ## PARAMETERS ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 8 Default value: None Accept pipeline input: False @@ -150,14 +151,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 7 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitLocation.md b/docs/Set-SnipeitLocation.md index c1ffa14..b5b37b6 100644 --- a/docs/Set-SnipeitLocation.md +++ b/docs/Set-SnipeitLocation.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,7 +16,7 @@ Updates Location in Snipe-it asset system Set-SnipeitLocation [-id] [[-name] ] [[-address] ] [[-address2] ] [[-state] ] [[-country] ] [[-zip] ] [[-city] ] [[-currency] ] [[-manager_id] ] [[-ldap_ou] ] [[-parent_id] ] [[-image] ] [-image_delete] - [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -62,14 +62,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 16 Default value: None Accept pipeline input: False @@ -258,14 +259,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 15 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitManufacturer.md b/docs/Set-SnipeitManufacturer.md index 18ea40e..9eac04b 100644 --- a/docs/Set-SnipeitManufacturer.md +++ b/docs/Set-SnipeitManufacturer.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,7 +14,7 @@ Add a new Manufacturer to Snipe-it asset system ``` Set-SnipeitManufacturer [-Name] [[-image] ] [-image_delete] [[-RequestType] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -30,14 +30,15 @@ New-SnipeitManufacturer -name "HP" ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 5 Default value: None Accept pipeline input: False @@ -106,14 +107,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 4 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitModel.md b/docs/Set-SnipeitModel.md index 41bb999..92a8c77 100644 --- a/docs/Set-SnipeitModel.md +++ b/docs/Set-SnipeitModel.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -15,7 +15,7 @@ Updates Model on Snipe-it asset system ``` Set-SnipeitModel [-id] [[-name] ] [[-model_number] ] [[-category_id] ] [[-manufacturer_id] ] [[-eol] ] [[-custom_fieldset_id] ] [[-image] ] - [-image_delete] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [-image_delete] [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` @@ -32,14 +32,15 @@ New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 11 Default value: None Accept pipeline input: False @@ -198,14 +199,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitStatus.md b/docs/Set-SnipeitStatus.md index e8f37c0..42f7f20 100644 --- a/docs/Set-SnipeitStatus.md +++ b/docs/Set-SnipeitStatus.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -14,8 +14,8 @@ Sets Snipe-it Status Labels ``` Set-SnipeitStatus [-id] [[-name] ] [-type] [[-notes] ] [[-color] ] - [[-show_in_nav] ] [[-default_label] ] [[-RequestType] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-show_in_nav] ] [[-default_label] ] [[-RequestType] ] [[-url] ] + [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -36,14 +36,15 @@ Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending ## PARAMETERS ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 10 Default value: None Accept pipeline input: False @@ -172,14 +173,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 9 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitSupplier.md b/docs/Set-SnipeitSupplier.md index c1e35e6..7431ec2 100644 --- a/docs/Set-SnipeitSupplier.md +++ b/docs/Set-SnipeitSupplier.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -16,7 +16,7 @@ Modify the supplier Set-SnipeitSupplier [-name] [[-address] ] [[-address2] ] [[-city] ] [[-state] ] [[-country] ] [[-zip] ] [[-phone] ] [[-fax] ] [[-email] ] [[-contact] ] [[-notes] ] [[-image] ] [-image_delete] - [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -62,14 +62,15 @@ Accept wildcard characters: False ``` ### -apiKey -Users API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +Users API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 16 Default value: None Accept pipeline input: False @@ -258,14 +259,15 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 15 Default value: None Accept pipeline input: False diff --git a/docs/Set-SnipeitUser.md b/docs/Set-SnipeitUser.md index d2ca9f5..6987a2e 100644 --- a/docs/Set-SnipeitUser.md +++ b/docs/Set-SnipeitUser.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- @@ -13,11 +13,11 @@ Creates a new user ## SYNTAX ``` -Set-SnipeitUser [-id] [[-first_name] ] [[-last_name] ] [[-userName] ] +Set-SnipeitUser [-id] [[-first_name] ] [[-last_name] ] [[-username] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-password] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] [[-employee_num] ] [[-activated] ] [[-notes] ] [[-image] ] [-image_delete] [[-RequestType] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-url] ] [[-apiKey] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -49,14 +49,15 @@ Accept wildcard characters: False ``` ### -apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +User's API Key for Snipeit. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 19 Default value: None Accept pipeline input: False @@ -305,21 +306,22 @@ Accept wildcard characters: False ``` ### -url -URL of Snipeit system, can be set using Set-SnipeitInfo command +Deprecated parameter, please use Connect-SnipeitPS instead. +URL of Snipeit system. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 18 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -userName +### -username Username for user ```yaml diff --git a/docs/SnipeitPS.md b/docs/SnipeitPS.md index 2378a40..37d1842 100644 --- a/docs/SnipeitPS.md +++ b/docs/SnipeitPS.md @@ -1,16 +1,19 @@ --- -Module Name: SnipeitPS +Module Name: snipeitps Module Guid: f86f4db4-1cb1-45c4-b7bf-6762531bfdeb Download Help Link: {{ Update Download Link }} Help Version: {{ Please enter version of help manually (X.X.X.X) format }} Locale: en-US --- -# SnipeitPS Module +# snipeitps Module ## Description {{ Fill in the Description }} -## SnipeitPS Cmdlets +## snipeitps Cmdlets +### [Connect-SnipeitPS](Connect-SnipeitPS.md) +Sets authetication information + ### [Get-SnipeitAccessory](Get-SnipeitAccessory.md) Gets a list of Snipe-it Accessories @@ -192,7 +195,8 @@ Add a new Custom Field to Snipe-it asset system Updates a department ### [Set-SnipeitInfo](Set-SnipeitInfo.md) -Sets authetication information +Sets authetication information. +Deprecated, use Connect-SnipeitPS instead. ### [Set-SnipeitLicense](Set-SnipeitLicense.md) Updates a licence diff --git a/docs/Update-SnipeitAlias.md b/docs/Update-SnipeitAlias.md index 1dd3141..1ef58b5 100644 --- a/docs/Update-SnipeitAlias.md +++ b/docs/Update-SnipeitAlias.md @@ -1,6 +1,6 @@ --- external help file: SnipeitPS-help.xml -Module Name: SnipeitPS +Module Name: snipeitps online version: schema: 2.0.0 --- diff --git a/docs/about_SnipeitPS.md b/docs/about_SnipeitPS.md index fcb3f69..346ae92 100644 --- a/docs/about_SnipeitPS.md +++ b/docs/about_SnipeitPS.md @@ -10,7 +10,9 @@ Collection of tools that makes interacting with Snipe-it api more pleasant. # EXAMPLES Prepare connection Snipe-It with: -Set-SnipeitInfo -url https://your.site -apikey YourVeryLongApiKey.... +Connect-SnipeitPS -url https://your.site -apikey YourVeryLongApiKey.... + +For secure ways to pass apikey to script, see Get-Help Connect-SnipeitPS -full To search assets use: