Compare commits

..

No commits in common. "master" and "v1.9.179" have entirely different histories.

159 changed files with 1989 additions and 4168 deletions

View file

@ -5,24 +5,6 @@ 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

View file

@ -19,23 +19,9 @@ Install-Module SnipeitPS
# Check for updates occasionally:
Update-Module SnipeitPS
# import module to session:
# To use each session:
Import-Module SnipeitPS
# 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'
Set-SnipeitInfo -URL 'https://asset.example.com' -apiKey 'tokenKey'
```
### Usage

View file

@ -1,62 +1,31 @@
<#
function Invoke-SnipeitMethod {
<#
.SYNOPSIS
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 {
Extracted invokation of the REST method to own function.
#>
[OutputType(
[PSObject]
)]
param (
# REST API to invoke
[Parameter(Mandatory = $true)]
[string]$Api,
[Uri]$URi,
# Method of the invokation
[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"
if($PSVersionTable.PSVersion -ge '7.0'){
$Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.legacyApiKey
} else {
#convert to plaintext via credential
$Token = (New-Object PSCredential "user",$SnipeitPSSession.legacyApiKey).GetNetworkCredential().Password
}
} elseif ($null -ne $SnipeitPSSession.url -and $null -ne $SnipeitPSSession.apiKey) {
[string]$Url = $SnipeitPSSession.url
Write-Debug "Invoke-SnipeitMethod url: $Url"
if($PSVersionTable.PSVersion -ge '7.0'){
$Token = ConvertFrom-SecureString -AsPlainText -SecureString $SnipeitPSSession.apiKey
} else {
#convert to plaintext via credential
$Token = (New-Object PSCredential "user",$SnipeitPSSession.apiKey).GetNetworkCredential().Password
}
} 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."
@ -64,36 +33,35 @@ function Invoke-SnipeitMethod {
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 {
# This can be done using $Body, maybe some day - PetriAsi
if ($GetParameters -and ($apiUri -notlike "*\?*")){
if ($GetParameters -and ($URi -notlike "*\?*"))
{
Write-Debug "Using `$GetParameters: $($GetParameters | Out-String)"
[string]$apiUri = $apiUri + (ConvertTo-GetParameter $GetParameters)
[string]$URI += (ConvertTo-GetParameter $GetParameters)
# Prevent recursive appends
$GetParameters = $null
}
# set mandatory parameters
$splatParameters = @{
Uri = $apiUri
Uri = $URi
Method = $Method
Headers = $_headers
UseBasicParsing = $true
ErrorAction = 'SilentlyContinue'
}
# Send image requests as multipart/form-data if supported
# Place holder for intended image manipulation
# if and when snipe it API gets support for images
if($null -ne $body -and $Body.Keys -contains 'image' ){
if($PSVersionTable.PSVersion -ge '7.0'){
$Body['image'] = get-item $body['image']
@ -111,65 +79,13 @@ function Invoke-SnipeitMethod {
}
if ($Body -and $splatParameters.Keys -notcontains 'Form') {
$splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes(($Body | Convertto-Json))
$splatParameters["Body"] = $Body | Convertto-Json
}
$script:PSDefaultParameterValues = $global:PSDefaultParameterValues
Write-Debug "$($Body | ConvertTo-Json)"
#Check throttle limit
if ($SnipeitPSSession.throttleLimit -gt 0) {
Write-Verbose "Check for request throttling"
Write-debug "ThrottleMode: $($SnipeitPSSession.throttleMode)"
Write-debug "ThrottleLimit: $($SnipeitPSSession.throttleLimit)"
Write-debug "ThrottlePeriod: $($SnipeitPSSession.throttlePeriod)"
Write-debug "ThrottleThreshold: $($SnipeitPSSession.throttleThreshold)"
Write-debug "Current count: $($SnipeitPSSession.throttledRequests.count)"
#current request timestamps in period
$SnipeitPSSession.throttledRequests = ($SnipeitPSSession.throttledRequests).where({$_ -gt (get-date).AddMilliseconds( 0 - $SnipeitPSSession.throttlePeriod).ToFileTime()})
#make sure that we alway have list here
if($null -eq $SnipeitPSSession.throttledRequests) {
$SnipeitPSSession.throttledRequests = [System.Collections.ArrayList]::new()
}
$naptime = 0
switch ($SnipeitPSSession.throttleMode) {
"Burst" {
if ($SnipeitPSSession.throttledRequests.count -ge $SnipeitPSSession.throttleLimit) {
$naptime = [Math]::Round(((get-date).ToFileTime() - ($SnipeitPSSession.throttledRequests[0]))/10000)
}
}
"Constant" {
$prevrequesttime =[Math]::Round(((get-date).ToFileTime() - ($SnipeitPSSession.throttledRequests[$SnipeitPSSession.throttledRequests.count - 1]))/10000)
$naptime = [Math]::Round($SnipeitPSSession.throttlePeriod / $SnipeitPSSession.throttleLimit) - $prevrequesttime
}
"Adaptive" {
$unThrottledRequests = $SnipeitPSSession.throttleLimit * ($SnipeitPSSession.throttleThreshold / 100)
if($SnipeitPSSession.throttledRequests.count -ge $unThrottledRequests) {
#calculate time left in throttlePeriod and devide it for remaining requests
$remaining = $SnipeitPSSession.throttleLimit - $SnipeitPSSession.throttledRequests.count
if ($remaining -lt 1) {
$remaining = 1
}
$naptime = [Math]::Round((((get-date).ToFileTime() - ($SnipeitPSSession.throttledRequests[0]))/ 10000) / $remaining)
}
}
}
#Do we need a nap
if ($naptime -gt 0) {
Write-verbose "Throttling request for $naptime ms"
Start-Sleep -Milliseconds $naptime
}
$SnipeitPSSession.throttledRequests.Add((Get-Date).ToFileTime())
}
# Invoke the API
try {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Invoking method $Method to URI $URi"
@ -189,20 +105,18 @@ function Invoke-SnipeitMethod {
if ($webResponse) {
Write-Verbose $webResponse
# API returned a Content: lets work with it
# API returned a Content: lets work wit it
try{
if ($webResponse.status -eq "error") {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received ... resolving"
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received from; resolving"
# This could be handled nicely in an function such as:
# ResolveError $response -WriteError
Write-Error $($webResponse.messages | Out-String)
} elseif ( $webResponse.StatusCode -eq 'Unauthorized') {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An Unauthorized response was received"
Write-Error "Cannot connect to Snipe It: Unauthorized."
return $false
} else {
}
else {
#update operations return payload
if ($webResponse.payload) {
if ($webResponse.payload){
$result = $webResponse.payload
}
#Search operations return rows
@ -210,13 +124,9 @@ function Invoke-SnipeitMethod {
$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
elseif ($webResponse.total -eq 0){
$result = $null
}
#get operations with id returns just one object
else {
$result = $webResponse
@ -226,6 +136,9 @@ function Invoke-SnipeitMethod {
Write-Verbose "Messages: $($webResponse.messages)"
$result
}
}
catch {
@ -234,7 +147,7 @@ function Invoke-SnipeitMethod {
}
elseif ($webResponse.StatusCode -eq "Unauthorized") {
Write-Error "[$($MyInvocation.MyCommand.Name)] You are not Authorized to access the resource, check your apiKey is correct"
Write-Error "[$($MyInvocation.MyCommand.Name)] You are not Authorized to access the resource, check your token is correct"
}
else {
# No content, although statusCode < 400
@ -252,4 +165,3 @@ function Invoke-SnipeitMethod {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
}
}

View file

@ -1,16 +0,0 @@
function Reset-SnipeitPSLegacyApi {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
param(
)
process {
Write-Verbose 'Reset-SnipeitPSLegacyApi'
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$SnipeitPSSession.legacyUrl = $null
$SnipeitPSSession.legacyApiKey = $null
}
}
}

View file

@ -1,18 +0,0 @@
function Set-SnipeitPSLegacyApiKey {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
param(
[string]$apiKey
)
process {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
if($PSVersionTable.PSVersion -ge '7.0'){
$SnipeitPSSession.legacyApiKey = ConvertTo-SecureString -AsPlainText -String $apiKey
} else {
$SnipeitPSSession.legacyApiKey = ConvertTo-SecureString -Force -AsPlainText -String $apiKey
}
}
}
}

View file

@ -1,14 +0,0 @@
function Set-SnipeitPSLegacyUrl {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
param(
$url
)
process {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$SnipeitPSSession.legacyUrl = $url.TrimEnd('/')
}
}
}

View file

@ -1,18 +0,0 @@
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
}
}

View file

@ -1,149 +0,0 @@
<#
.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.
.PARAMETER throttleLimit
Throttle request rate to nro of requests per throttlePeriod. Defaults to 0 that means no requests are not throttled.
.PARAMETER throttlePeriod
Throttle period time span in milliseconds defaults to 60 milliseconds.
.PARAMETER throttleThreshold
Threshold percentage of used request on period after request are throttled.
.PARAMETER throttleMode
RequestThrottling type. "Burst" allows all requests to be used in ThrottlePeriod without delays and then waits
until there's new requests avalable. With "Contant" mode there always delay between requests. Delay is calculated
by dividing throttlePeriod with throttleLimit. "Adaptive" mode allows throttleThreshold percentage of request to be
used with out delay, after threshold limit is reached next requests are delayded by dividing available requests
over throttlePeriod.
.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,
[Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with credential',Mandatory=$false)]
[int]$throttleLimit,
[Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with credential',Mandatory=$false)]
[int]$throttlePeriod,
[Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with credential',Mandatory=$false)]
[int]$throttleThreshold,
[Parameter(ParameterSetName='Connect with url and apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with url and secure apikey',Mandatory=$false)]
[Parameter(ParameterSetName='Connect with credential',Mandatory=$false)]
[ValidateSet("Burst","Constant","Adaptive")]
[string]$throttleMode
)
PROCESS {
switch ($PsCmdlet.ParameterSetName) {
'Connect with url and apikey' {
$SnipeitPSSession.url = $url.AbsoluteUri.TrimEnd('/')
if($PSVersionTable.PSVersion -ge '7.0'){
$SnipeitPSSession.apiKey = ConvertTo-SecureString -AsPlainText -String $apiKey
} else {
$SnipeitPSSession.apiKey = ConvertTo-SecureString -String $apiKey -AsPlainText -Force
}
}
'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
}
}
if($null -eq $throttleLimit) { $throttleLimit = 0}
$SnipeitPSSession.throttleLimit = $throttleLimit
if($throttleThreshold -lt 1) { $throttleThreshold = 90}
$SnipeitPSSession.throttleThreshold = $throttleThreshold
if('' -eq $throttleMode) { $throttleMode = "Burst"}
$SnipeitPSSession.throttleMode = $throttleMode
if ($SnipeitPSSession.throttleLimit -gt 0) {
if($null -eq $throttlePeriod) { $throttlePeriod = 60000}
$SnipeitPSSession.throttlePeriod = $throttlePeriod
$SnipeitPSSession.throttledRequests = [System.Collections.ArrayList]::new()
}
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"
}
}
}

View file

@ -8,24 +8,9 @@ Gets a list of Snipe-it Accessories
.PARAMETER search
A text string to search the Accessory data
.PARAMETER user_id
Return Accessories checked out to user id
.PARAMETER id
A id of specific Accessory
.PARAMETER company_id
Optionally restrict Accessory results to this company_id field
.PARAMETER category_id
Optionally restrict Accessory results to this category_id field
.PARAMETER manufacturer_id
Optionally restrict Accessory results to this manufacturer_id field
.PARAMETER supplier_id
Optionally restrict Accessory results to this supplier_id field
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -36,10 +21,10 @@ Result offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitAccessory -search Keyboard
@ -94,43 +79,31 @@ function Get-SnipeitAccessory() {
[parameter(ParameterSetName='Accessories checked out to user id')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
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"}
'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 = @{
Api = $api
Uri = $apiurl
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -148,14 +121,6 @@ function Get-SnipeitAccessory() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,15 +8,16 @@
Unique ID For accessory to list
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitAccessoryOwner -id 1
#>
function Get-SnipeitAccessoryOwner() {
function Get-SnipeitAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -26,39 +27,23 @@ function Get-SnipeitAccessoryOwner() {
[parameter(mandatory = $true)]
[int]$id,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
$Parameters = @{
Api = "/api/v1/accessories/$id/checkedout"
Uri = "$url/api/v1/accessories/$id/checkedout"
Method = 'GET'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
return $result
}

View file

@ -30,10 +30,10 @@ Result offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitAccessory -search Keyboard
@ -71,19 +71,19 @@ function Get-SnipeitActivity() {
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
if (($target_type -and -not $target_id) -or
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
if(($item_type -and -not $item_id) -or
($item_id -and -not $item_type)) {
throw "Please specify both item_type and item_id"
}
@ -92,25 +92,14 @@ function Get-SnipeitActivity() {
$Parameters = @{
Api = "/api/v1/reports/activity"
Uri = "$url/api/v1/reports/activity"
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -128,14 +117,6 @@ function Get-SnipeitActivity() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -20,15 +20,6 @@ Retrieve a list of assets that are due for auditing soon.
.PARAMETER audit_overdue
Retrieve a list of assets that are overdue for auditing.
.PARAMETER user_id
Retrieve a list of assets checked out to user id.
.PARAMETER component_id
Retrieve a list of assets assigned this component id.
.PARAMETER name
Optionally restrict asset results to this asset name
.PARAMETER order_number
Optionally restrict asset results to this order number
@ -47,22 +38,12 @@ Optionally restrict asset results to this company ID
.PARAMETER location_id
Optionally restrict asset results to this location ID
.PARAMETER depreciation_id
Optionally restrict asset results to this depreciation ID
.PARAMETER requestable
Optionally restrict asset results to those set as requestable
.PARAMETER status
Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable
.PARAMETER status_id
Optionally restrict asset results to this status label ID
.PARAMETER customfields
Hastable of custom fields and extra fields for searching assets in Snipe-It.
Use internal field names from Snipe-It. You can use Get-CustomField to get internal field names.
.PARAMETER sort
Specify the column name you wish to sort by
@ -79,13 +60,13 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitAsset -all
Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..."
Returens all assets
.EXAMPLE
@ -151,9 +132,6 @@ function Get-SnipeitAsset() {
[parameter(ParameterSetName='Assets with component id')]
[int]$component_id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[string]$order_number,
@ -184,9 +162,6 @@ function Get-SnipeitAsset() {
[parameter(ParameterSetName='Search')]
[int]$status_id,
[parameter(ParameterSetName='Search')]
[hashtable]$customfields,
[parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
@ -224,58 +199,37 @@ function Get-SnipeitAsset() {
[parameter(ParameterSetName='Assets with component id')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
# Add in custom fields.
if ($customfields.Count -gt 0) {
foreach ($pair in $customfields.GetEnumerator()) {
if (-Not $SearchParameter.ContainsKey($pair.Name)) {
$SearchParameter.Add($pair.Name, $pair.Value)
}
}
}
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"}
'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 = @{
Api = $api
Uri = $apiurl
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if ($offset){$offset} Else {0})
$callargs = $SearchParameter
Write-Verbose "Callargs: $($callargs | convertto-json)"
$callargs.Remove('all')
@ -294,14 +248,7 @@ function Get-SnipeitAsset() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -24,18 +24,19 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitAssetMaintenances
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine"
Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine"
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
#>
function Get-SnipeitAssetMaintenance() {
Param(
@ -54,37 +55,26 @@ function Get-SnipeitAssetMaintenance() {
[int]$offset,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/maintenances"
Uri = "$url/api/v1/maintenances"
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -102,14 +92,6 @@ function Get-SnipeitAssetMaintenance() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@ A text string to search the Categories data
.PARAMETER id
A id of specific Category
.PARAMETER name
Optionally restrict Category results to this Category name.
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -21,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. Url of Snipeit system.
Url of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitCategory -id 1
@ -34,7 +31,8 @@ Get-SnipeitCategory -search "Laptop"
#>
function Get-SnipeitCategory() {
function Get-SnipeitCategory()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -43,9 +41,6 @@ function Get-SnipeitCategory() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -59,47 +54,35 @@ function Get-SnipeitCategory() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/categories"
$apiurl = "$url/api/v1/categories"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/categories/$id"
$apiurl= "$url/api/v1/categories/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -117,12 +100,4 @@ function Get-SnipeitCategory() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@ A text string to search the Companies data
.PARAMETER id
A id of specific Company
.PARAMETER name
Optionally restrict company results to this company name.
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -20,10 +17,10 @@ Offset to use
.PARAMETER all
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitCompany
@ -35,7 +32,8 @@ Gets specific company
#>
function Get-SnipeitCompany() {
function Get-SnipeitCompany()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -44,9 +42,6 @@ function Get-SnipeitCompany() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -60,47 +55,36 @@ function Get-SnipeitCompany() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory=$false)]
[parameter(mandatory=$true)]
[string]$url,
[parameter(mandatory=$false)]
[parameter(mandatory=$true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/companies"
$apiurl = "$url/api/v1/companies"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/companies/$id"
$apiurl= "$url/api/v1/companies/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -118,12 +102,4 @@ function Get-SnipeitCompany() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,18 +8,6 @@ A text string to search the Components data
.PARAMETER id
A id of specific Component
.PARAMETER name
Optionally restrict Component results to this name field
.PARAMETER company_id
Optionally restrict Component results to this company_id field
.PARAMETER category_id
Optionally restrict Component results to this category_id field
.PARAMETER location_id
Optionally restrict Component results to this location_id field
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -30,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system,can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitComponent
@ -57,9 +45,6 @@ function Get-SnipeitComponent() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[int]$category_id,
@ -86,48 +71,36 @@ function Get-SnipeitComponent() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/components"
$apiurl = "$url/api/v1/components"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/components/$id"
$apiurl= "$url/api/v1/components/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -145,12 +118,4 @@ function Get-SnipeitComponent() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@ A text string to search the consumables
.PARAMETER id
A id of specific consumable
.PARAMETER name
Optionally restrict consumable results to this name field
.PARAMETER company_id
Id number of company
@ -39,10 +36,10 @@ Offset to use
A return all results
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system,can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitConsumable -all
@ -66,9 +63,6 @@ function Get-SnipeitConsumable() {
[parameter(ParameterSetName='Get with ID')]
[int[]]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[int]$category_id,
@ -102,38 +96,29 @@ function Get-SnipeitConsumable() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
}
process {
switch ($PSCmdlet.ParameterSetName) {
'Search' {
$Parameters = @{
Api = "/api/v1/consumables"
Uri = "$url/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')
@ -156,23 +141,16 @@ function Get-SnipeitConsumable() {
'Get with ID' {
foreach($consumable_id in $id) {
$Parameters = @{
Api = "$url/api/v1/consumables/$consumable_id"
Uri = "$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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,67 +6,44 @@
A id of specific field
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitCustomField
Get all custom fields
.EXAMPLE
Get-SnipeitCustomField -id 1
Get custom field with ID 1
Get-SnipeitCustomField -url "https://assets.example.com" -token "token..."
#>
function Get-SnipeitCustomField() {
function Get-SnipeitCustomField()
{
Param(
[int]$id,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) {
$api= "/api/v1/fields/$id"
$apiurl= "$url/api/v1/fields/$id"
} else {
$api = "/api/v1/fields"
$apiurl = "$url/api/v1/fields"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
}
process {
$result = Invoke-SnipeitMethod @Parameters
$result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
$result
}

View file

@ -8,18 +8,6 @@ A text string to search the Departments data
.PARAMETER id
A id of specific Department
.PARAMETER name
Optionally restrict department results to this department name.
.PARAMETER manager_id
Optionally restrict department results to this manager ID.
.PARAMETER company_id
Optionally restrict department results to this company ID.
.PARAMETER location_id
Optionally restrict department results to this location ID.
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -30,13 +18,13 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitDepartment
Get-SnipeitDepartment -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-SnipeitDepartment -search Department1
@ -46,7 +34,8 @@ Get-SnipeitDepartment -id 1
#>
function Get-SnipeitDepartment() {
function Get-SnipeitDepartment()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -55,18 +44,6 @@ function Get-SnipeitDepartment() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[int]$manager_id,
[parameter(ParameterSetName='Search')]
[int]$company_id,
[parameter(ParameterSetName='Search')]
[int]$location_id,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -84,47 +61,36 @@ function Get-SnipeitDepartment() {
[ValidateSet('id', 'name', 'image', 'users_count', 'created_at')]
[string]$sort = "created_at",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/departments"
$apiurl = "$url/api/v1/departments"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/departments/$id"
$apiurl= "$url/api/v1/departments/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -142,13 +108,5 @@ function Get-SnipeitDepartment() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,18 +6,16 @@ Returns a fieldset or list of Snipe-it Fieldsets
A id of specific fieldset
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitFieldset
Get all fieldsets
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-SnipeitFieldset | Where-Object {$_.name -eq "Windows" }
Gets fieldset by name
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Windows" }
#>
@ -25,45 +23,28 @@ function Get-SnipeitFieldset() {
Param(
[int]$id,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) {
$api = "/api/v1/fieldsets/$id"
$apiurl = "$url/api/v1/fieldsets/$id"
} else {
$api = "/api/v1/fieldsets"
$apiurl = "$url/api/v1/fieldsets"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
}
process {
$result = Invoke-SnipeitMethod @Parameters
$result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -19,10 +19,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitLicense -search SomeLicense
@ -98,44 +98,33 @@ function Get-SnipeitLicense() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
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"}
'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 = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -153,13 +142,5 @@ function Get-SnipeitLicense() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -22,10 +22,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitLicenseSeat -id 1
@ -47,44 +47,33 @@ function Get-SnipeitLicenseSeat() {
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters -DefaultExcludeParameter 'url', 'apiKey', 'Debug', 'Verbose','RequestType'
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/licenses/$id/seats"
$apiurl = "$url/api/v1/licenses/$id/seats"
if ($seat_id) {
$api= "/api/v1/licenses/$id/seats/$seat_id"
$apiurl= "$url/api/v1/licenses/$id/seats/$seat_id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -102,13 +91,5 @@ function Get-SnipeitLicenseSeat() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,24 +8,6 @@ A text string to search the Locations data
.PARAMETER id
A id of specific Location
.PARAMETER name
Optionally restrict Location results to this Location name.
.PARAMETER address
Optionally restrict Location results to this Location address.
.PARAMETER address2
Optionally restrict Location results to this Location address2.
.PARAMETER city
Optionally restrict Location results to this Location city.
.PARAMETER zip
Optionally restrict Location results to this Location zip.
.PARAMETER country
Optionally restrict Location results to this Location country.
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -36,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitLocation -search Location1
@ -49,7 +31,8 @@ Get-SnipeitLocation -id 3
#>
function Get-SnipeitLocation() {
function Get-SnipeitLocation()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -58,24 +41,6 @@ function Get-SnipeitLocation() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[string]$address,
[parameter(ParameterSetName='Search')]
[string]$address2,
[parameter(ParameterSetName='Search')]
[string]$city,
[parameter(ParameterSetName='Search')]
[string]$zip,
[parameter(ParameterSetName='Search')]
[string]$country,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -89,47 +54,36 @@ function Get-SnipeitLocation() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$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) {
$api= "/api/v1/locations/$id"
$apiurl= "$url/api/v1/locations/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -147,13 +101,5 @@ function Get-SnipeitLocation() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@
.PARAMETER id
A id of specific Manufactuter
.PARAMETER name
Optionally restrict Manufacturer results to this name field
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -21,10 +18,10 @@
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitManufacturer -search HP
@ -35,7 +32,8 @@
Returns manufacturer with id 3
#>
function Get-SnipeitManufacturer() {
function Get-SnipeitManufacturer()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -44,9 +42,6 @@ function Get-SnipeitManufacturer() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -60,47 +55,36 @@ function Get-SnipeitManufacturer() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$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) {
$api= "/api/v1/manufacturers/$id"
$apiurl= "$url/api/v1/manufacturers/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -118,12 +102,4 @@ function Get-SnipeitManufacturer() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitModel -search "DL380"
@ -31,7 +31,8 @@ Get-SnipeitModel -id 1
#>
function Get-SnipeitModel() {
function Get-SnipeitModel()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -53,48 +54,36 @@ function Get-SnipeitModel() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/models"
$apiurl = "$url/api/v1/models"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/models/$id"
$apiurl= "$url/api/v1/models/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -112,12 +101,4 @@ function Get-SnipeitModel() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@ A text string to search the Status Labels data
.PARAMETER id
A id of specific Status Label
.PARAMETER name
Optionally restrict Status Label results to this name field
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -21,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy"
@ -34,7 +31,8 @@ Get-SnipeitStatus -id 3
#>
function Get-SnipeitStatus() {
function Get-SnipeitStatus()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -43,9 +41,6 @@ function Get-SnipeitStatus() {
[parameter(ParameterSetName='Get with ID')]
[int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -59,47 +54,36 @@ function Get-SnipeitStatus() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$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) {
$api= "/api/v1/statuslabels/$id"
$apiurl= "$url/api/v1/statuslabels/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -117,12 +101,4 @@ function Get-SnipeitStatus() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,33 +8,6 @@ A text string to search the Supliers data
.PARAMETER id
A id of specific Suplier
.PARAMETER name
Optionally restrict Supplier results to this Supplier name.
.PARAMETER address
Optionally restrict Supplier results to this Supplier address.
.PARAMETER address2
Optionally restrict Supplier results to this Supplier address2.
.PARAMETER city
Optionally restrict Supplier results to this Supplier city.
.PARAMETER zip
Optionally restrict Supplier results to this Supplier zip.
.PARAMETER country
Optionally restrict Supplier results to this Supplier country.
.PARAMETER fax
Optionally restrict Supplier results to this Supplier fax number.
.PARAMETER email
Optionally restrict Supplier results to this Supplier email address.
.PARAMETER notes
Optionally restrict Supplier results to this Supplier notes field.
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -45,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitSupplier -search MySupplier
@ -57,7 +30,8 @@ Get-SnipeitSupplier -search MySupplier
Get-SnipeitSupplier -id 2
#>
function Get-SnipeitSupplier() {
function Get-SnipeitSupplier()
{
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
@ -70,33 +44,6 @@ function Get-SnipeitSupplier() {
[ValidateSet("asc", "desc")]
[string]$order = "desc",
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[string]$address,
[parameter(ParameterSetName='Search')]
[string]$address2,
[parameter(ParameterSetName='Search')]
[string]$city,
[parameter(ParameterSetName='Search')]
[string]$zip,
[parameter(ParameterSetName='Search')]
[string]$country,
[parameter(ParameterSetName='Search')]
[string]$fax,
[parameter(ParameterSetName='Search')]
[string]$email,
[parameter(ParameterSetName='Search')]
[string]$notes,
[parameter(ParameterSetName='Search')]
[int]$limit = 50,
@ -106,48 +53,36 @@ function Get-SnipeitSupplier() {
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/suppliers"
$apiurl = "$url/api/v1/suppliers"
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/suppliers/$id"
$apiurl= "$url/api/v1/suppliers/$id"
}
$Parameters = @{
Api = $api
Uri = $apiurl
Method = 'Get'
Token = $apiKey
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -165,12 +100,5 @@ function Get-SnipeitSupplier() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,56 +8,11 @@ A text string to search the User data
.PARAMETER id
A id of specific User
.PARAMETER accessory_id
Get users a specific accessory id has been checked out to
.PARAMETER username
Optionally restrict User results to this username field
Search string for username field
.PARAMETER email
Optionally restrict User results to this email field
.PARAMETER employee_num
Optionally restrict User results to this employee_num field
.PARAMETER state
Optionally restrict User results to this state field
.PARAMETER country
Optionally restrict User results to this country field
.PARAMETER zip
Optionally restrict User results to this zip field
.PARAMETER company_id
Optionally restrict User results to this company_id field
.PARAMETER location_id
Optionally restrict User results to this location_id field
.PARAMETER department_id
Optionally restrict User results to this department_id field
.PARAMETER deleted
Optionally restrict User results to deleted users only
.PARAMETER ldap_import
Optionally restrict User results to those with specified ldap_import value
.PARAMETER remote
Optionally restrict User results to those with specified remote worker value
.PARAMETER assets_count
Optionally restrict User results to those with the specified assets count
.PARAMETER licenses_count
Optionally restrict User results to those with the specified licenses count
.PARAMETER accessories_count
Optionally restrict User results to those with the specified accessories count
.PARAMETER consumables_count
Optionally restrict User results to those with the specified consumables count
Search string for email field
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
@ -69,10 +24,10 @@ Offset to use
A return all results, works with -offset and other parameters
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitUser -search SomeSurname
@ -121,39 +76,6 @@ function Get-SnipeitUser() {
[parameter(ParameterSetName='Search')]
[string]$email,
[parameter(ParameterSetName='Search')]
[string]$employee_num,
[parameter(ParameterSetName='Search')]
[string]$state,
[parameter(ParameterSetName='Search')]
[string]$zip,
[parameter(ParameterSetName='Search')]
[string]$country,
[parameter(ParameterSetName='Search')]
[Nullable[bool]]$deleted,
[parameter(ParameterSetName='Search')]
[Nullable[bool]]$ldap_import,
[parameter(ParameterSetName='Search')]
[Nullable[bool]]$remote,
[parameter(ParameterSetName='Search')]
[int]$assets_count,
[parameter(ParameterSetName='Search')]
[int]$licenses_count,
[parameter(ParameterSetName='Search')]
[int]$accessories_count,
[parameter(ParameterSetName='Search')]
[int]$consumables_count,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
@ -168,42 +90,31 @@ function Get-SnipeitUser() {
[parameter(ParameterSetName='Get users a specific accessory id has been checked out to')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$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"}
'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 = @{
Api = $api
Uri = $apiurl
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$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})
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
@ -221,12 +132,4 @@ function Get-SnipeitUser() {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -57,10 +57,10 @@ Min quantity of the accessory before alert is triggered
Accessory image fileame and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1
@ -109,13 +109,13 @@ function New-SnipeitAccessory() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -125,34 +125,16 @@ function New-SnipeitAccessory() {
}
$Parameters = @{
Api = "/api/v1/accessories"
Uri = "$url/api/v1/accessories"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
$result
}

View file

@ -39,10 +39,6 @@ Optional Purchase cost of the Asset
.PARAMETER purchase_date
Optional Purchase cost of the Asset
.PARAMETER supplier_id
Optional Supplier id of the Asset
.PARAMETER rtd_location_id
Optional Default location id for the asset
@ -56,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
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit.
@ -78,7 +74,8 @@ 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",
@ -138,17 +135,16 @@ function New-SnipeitAsset() {
[ValidateSet("location","asset","user")]
[string] $checkout_to_type = "user",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey,
[Alias('CustomValues')]
[hashtable] $customfields
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -157,52 +153,35 @@ function New-SnipeitAsset() {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
}
if ($customfields) {
if ($customfields)
{
$Values += $customfields
}
#Checkout asset when creating it
if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') {
switch ($checkout_to_type) {
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')}
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"
Uri = "$url/api/v1/hardware"
Method = 'Post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -31,10 +31,10 @@ Optional completion date
Optional cost
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01
@ -70,13 +70,13 @@ function New-SnipeitAssetMaintenance() {
[string]$notes,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -91,34 +91,15 @@ function New-SnipeitAssetMaintenance() {
$Parameters = @{
Api = "/api/v1/maintenances"
Uri = "$url/api/v1/maintenances"
Method = 'Post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@ Long description
.PARAMETER Tag
The asset tag of the asset you wish to audit
.PARAMETER next_audit_date
Due date for the asset's next audit
.PARAMETER Location_id
ID of the location you want to associate with the audit
@ -19,7 +16,8 @@ New-SnipeitAudit -tag 1 -location_id 1
#>
function New-SnipeitAudit() {
function New-SnipeitAudit()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -31,60 +29,36 @@ function New-SnipeitAudit() {
[int]$location_id,
[parameter(mandatory = $false)]
[datetime]$next_audit_date,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"location_id" = $location_id
}
if ($PSBoundParameters.ContainsKey('tag')) {
if ($PSBoundParameters.ContainsKey('tag'))
{
$Values += @{"asset_tag" = $tag}
}
if ($PSBoundParameters.ContainsKey('next_audit_date')) {
$Values += @{"next_audit_date" = ($next_audit_date).ToString("yyyy-MM-dd")}
}
$Parameters = @{
Api = "/api/v1/hardware/audit"
Uri = "$url/api/v1/hardware/audit"
Method = 'Post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -24,16 +24,17 @@ If switch is present, send email to user on checkin/checkout
Category image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitCategory -name "Laptops" -category_type asset
New-SnipeitCategory -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..."
#>
function New-SnipeitCategory() {
function New-SnipeitCategory()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -58,17 +59,17 @@ function New-SnipeitCategory() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[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'
}
@ -78,32 +79,17 @@ function New-SnipeitCategory() {
process {
$Parameters = @{
Api = "/api/v1/categories"
Uri = "$url/api/v1/categories"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -12,17 +12,18 @@ Comapany name
Company image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitCompany -name "Acme Company"
#>
function New-SnipeitCompany() {
function New-SnipeitCompany()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -35,47 +36,29 @@ function New-SnipeitCompany() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/companies"
Uri = "$url/api/v1/companies"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -30,15 +30,16 @@ Cost of item being purchased.
Component image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitComponent -name 'Display adapter' -catecory_id 3 -qty 10
An example
.NOTES
General notes
#>
function New-SnipeitComponent() {
@ -70,13 +71,13 @@ function New-SnipeitComponent() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -86,35 +87,16 @@ function New-SnipeitComponent() {
}
$Parameters = @{
Api = "/api/v1/components"
Uri = "$url/api/v1/components"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -48,10 +48,10 @@ Item number for the consumable
Consumable Image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
@ -60,7 +60,8 @@ Create consumable with stock count 20 , alert when stock is 5 or lower
#>
function New-SnipeitConsumable() {
function New-SnipeitConsumable()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -109,10 +110,10 @@ function New-SnipeitConsumable() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -122,36 +123,21 @@ 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') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
}
process {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$Parameters = @{
Uri = "$url/api/v1/consumables"
Method = 'Post'
Body = $Values
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -30,16 +30,17 @@
Any additional text you wish to display under the new form field to make it clearer what the gauges should be.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#>
function New-SnipeitCustomField() {
function New-SnipeitCustomField()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -67,10 +68,10 @@ function New-SnipeitCustomField() {
[string]$custom_format,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -83,33 +84,20 @@ function New-SnipeitCustomField() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/fields"
Uri = "$url/api/v1/fields"
Method = 'post'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Set-SnipeitPSLegacyUrl -url $url
Token = $apiKey
}
}
process{
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -21,10 +21,10 @@
Department Image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -54,47 +54,28 @@ function New-SnipeitDepartment() {
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/departments"
Uri = "$url/api/v1/departments"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -57,10 +57,10 @@
Termination date for license.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitLicence -name "License" -seats 3 -company_id 1
@ -117,13 +117,13 @@ function New-SnipeitLicense() {
[datetime]$termination_date,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -141,34 +141,16 @@ function New-SnipeitLicense() {
}
$Parameters = @{
Api = "/api/v1/licenses"
Uri = "$url/api/v1/licenses"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -42,10 +42,10 @@
Location Image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14
@ -86,47 +86,27 @@ function New-SnipeitLocation() {
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/locations"
Uri = "$url/api/v1/locations"
Method = 'post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -15,16 +15,17 @@
Remove current image
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitManufacturer -name "HP"
#>
function New-SnipeitManufacturer() {
function New-SnipeitManufacturer()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -39,14 +40,13 @@ function New-SnipeitManufacturer() {
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
@ -54,32 +54,16 @@ function New-SnipeitManufacturer() {
}
$Parameters = @{
Api = "/api/v1/manufacturers"
Uri = "$url/api/v1/manufacturers"
Method = 'post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -24,16 +24,17 @@
Asset model Image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.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"
@ -53,20 +54,19 @@ function New-SnipeitModel() {
[int]$eol,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[int]$fieldset_id,
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
@ -81,34 +81,16 @@ function New-SnipeitModel() {
$Parameters = @{
Api = "/api/v1/models"
Uri = "$url/api/v1/models"
Method = 'post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -45,10 +45,10 @@
Image file name and path for item
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -90,47 +90,28 @@ function New-SnipeitSupplier() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/suppilers"
Uri = "$url/api/v1/suppilers"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -44,9 +44,6 @@
.PARAMETER manager_id
ID number of manager
.PARAMETER groups
ID numbers of groups
.PARAMETER employee_num
Employeenumber
@ -57,10 +54,10 @@
User Image file name and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -106,8 +103,6 @@ function New-SnipeitUser() {
[int]$manager_id,
[int[]]$groups,
[string]$employee_num,
[bool]$ldap_import = $false,
@ -115,13 +110,13 @@ function New-SnipeitUser() {
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
@ -131,34 +126,15 @@ function New-SnipeitUser() {
}
$Parameters = @{
Api = "/api/v1/users"
Uri = "$url/api/v1/users"
Method = 'post'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
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') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,10 +6,10 @@
.PARAMETER ID
Unique ID For accessory to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitAccessory -ID 44 -Verbose
@ -18,7 +18,8 @@
Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory
#>
function Remove-SnipeitAccessory () {
function Remove-SnipeitAccessory ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitAccessory () {
Param(
[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 = @{
Api = "/api/v1/accessories/$accessory_id"
Uri = "$url/api/v1/accessories/$accessory_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,10 +6,10 @@
.PARAMETER ID
Unique ID For Asset to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitAsset -ID 44 -Verbose
@ -18,7 +18,8 @@
Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset
#>
function Remove-SnipeitAsset () {
function Remove-SnipeitAsset ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,47 +28,28 @@ function Remove-SnipeitAsset () {
Param(
[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 = @{
Api = "/api/v1/hardware/$asset_id"
Uri = "$url/api/v1/hardware/$asset_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -1,4 +1,5 @@
<#
function Remove-SnipeitAssetMaintenance {
<#
.SYNOPSIS
Remove asset maintenance from Snipe-it asset system
@ -9,64 +10,51 @@
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.
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
#>
function Remove-SnipeitAssetMaintenance {
Remove-SnipeitAssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose
#>
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
param (
# Asset maintenance ID
[Parameter(Mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]
$id,
[parameter(mandatory = $false)]
[string]$url,
# Snipeit URL
[Parameter(Mandatory = $true)]
[string]
$url,
[parameter(mandatory = $false)]
[string]$apiKey
# Snipeit ApiKey
[Parameter(Mandatory = $true)]
[string]
$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
}
process {
foreach($maintenance_id in $id) {
foreach($maintenance_id in $id){
$Parameters = @{
Api = "/api/v1/maintenances/$maintenance_id"
Uri = "$url/api/v1/maintenances/$maintenance_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For categoryto be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitCategory -ID 44
Remove-SnipeitCategory -ID 44 -Verbose
.EXAMPLE
Get-SnipeitCategory -search something | Remove-SnipeitCategory
#>
function Remove-SnipeitCategory () {
function Remove-SnipeitCategory ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,45 +28,27 @@ function Remove-SnipeitCategory () {
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
begin {
}
process {
foreach($category_id in $id) {
foreach($category_id in $id){
$Parameters = @{
Api = "/api/v1/categories/$category_id"
Uri = "$url/api/v1/categories/$category_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For Company to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitCompany -ID 44
Remove-SnipeitCompany -ID 44 -Verbose
.EXAMPLE
Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCompany
#>
function Remove-SnipeitCompany () {
function Remove-SnipeitCompany ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,45 +28,27 @@ function Remove-SnipeitCompany () {
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
begin {
}
process {
foreach($company_id in $id) {
foreach($company_id in $id){
$Parameters = @{
Api = "/api/v1/companies/$company_id"
Uri = "$url/api/v1/companies/$company_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER IDs
Unique ID For component to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitComponent -ID 44
Remove-SnipeitComponent -ID 44 -Verbose
.EXAMPLE
Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent
#>
function Remove-SnipeitComponent () {
function Remove-SnipeitComponent ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitComponent () {
Param(
[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 = @{
Api = "/api/v1/components/$component_id"
Uri = "$url/api/v1/components/$component_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -7,19 +7,20 @@
Unique ID For consumable to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitConsumable -ID 44
Remove-SnipeitConsumable -ID 44 -Verbose
.EXAMPLE
Get-SnipeitConsumable -search "paper" | Remove-SnipeitConsumable
Get-SnipeitConsumable -search "paper" | Remove-Snipeitconsumable
#>
function Remove-SnipeitConsumable () {
function Remove-SnipeitConsumable ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -28,46 +29,27 @@ function Remove-SnipeitConsumable () {
Param(
[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 = @{
Api = "/api/v1/consumables/$consumable_id"
Uri = "$url/api/v1/consumables/$consumable_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,10 +6,10 @@
.PARAMETER ID
Unique ID For field to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitCustomField -ID 44 -Verbose
@ -18,7 +18,8 @@
Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-SnipeitCustomField
#>
function Remove-SnipeitCustomField () {
function Remove-SnipeitCustomField ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,44 +28,27 @@ function Remove-SnipeitCustomField () {
Param(
[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 = @{
Api = "/api/v1/fields/$field_id"
Uri = "$url/api/v1/fields/$field_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For department to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitDepartment -ID 44
Remove-SnipeitDepartment -ID 44 -Verbose
.EXAMPLE
Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDepartment
#>
function Remove-SnipeitDepartment () {
function Remove-SnipeitDepartment ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,45 +28,27 @@ function Remove-SnipeitDepartment () {
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
begin {
}
process {
foreach($department_id in $id) {
foreach($department_id in $id){
$Parameters = @{
Api = "/api/v1/departments/$department_id"
Uri = "$url/api/v1/departments/$department_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For licence to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitLicence -ID 44
Remove-SnipeitLicence -ID 44 -Verbose
.EXAMPLE
Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense
#>
function Remove-SnipeitLicense () {
function Remove-SnipeitLicense ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitLicense () {
Param(
[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 = @{
Api = "/api/v1/licenses/$license_id"
Uri = "$url/api/v1/licenses/$license_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For location to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitLocation -ID 44
Remove-SnipeitLocation -ID 44 -Verbose
.EXAMPLE
Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation
#>
function Remove-SnipeitLocation () {
function Remove-SnipeitLocation ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitLocation () {
Param(
[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 = @{
Api = "/api/v1/locations/$asset_id"
Uri = "$url/api/v1/locations/$asset_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For manufacturer to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitManufacturer -ID 44
Remove-SnipeitManufacturer -ID 44 -Verbose
.EXAMPLE
Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-SnipeitManufacturer
#>
function Remove-SnipeitManufacturer () {
function Remove-SnipeitManufacturer ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,47 +28,27 @@ function Remove-SnipeitManufacturer () {
Param(
[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 = @{
Api = "/api/v1/manufacturers/$manufacturer_id"
Uri = "$url/api/v1/manufacturers/$manufacturer_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,19 +6,20 @@
.PARAMETER ID
Unique ID For Model to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitModel -ID 44
Remove-SnipeitModel -ID 44 -Verbose
.EXAMPLE
Get-SnipeitModel -search needle | Remove-SnipeitModel
#>
function Remove-SnipeitModel () {
function Remove-SnipeitModel ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitModel () {
Param(
[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 = @{
Api = "/api/v1/models/$model_id"
Uri = "$url/api/v1/models/$model_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -6,10 +6,10 @@
.PARAMETER ID
Unique ID For supplier to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitSupplier -ID 44
@ -18,7 +18,8 @@ Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for S
Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier
#>
function Remove-SnipeitSupplier () {
function Remove-SnipeitSupplier ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -27,46 +28,27 @@ function Remove-SnipeitSupplier () {
Param(
[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 = @{
Api = "/api/v1/suppliers/$supplier_id"
Uri = "$url/api/v1/suppliers/$supplier_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -7,16 +7,17 @@
Unique ID For User to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#>
function Remove-SnipeitUser () {
function Remove-SnipeitUser ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -24,15 +25,13 @@ function Remove-SnipeitUser () {
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[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
}
@ -40,32 +39,17 @@ function Remove-SnipeitUser () {
process {
foreach($user_id in $id) {
$Parameters = @{
Api = "/api/v1/users/$user_id"
Uri = "$url/api/v1/users/$user_id"
Method = 'Delete'
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -10,10 +10,10 @@
Use Get-SnipeitAccessoryOwner to find out nooded value
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
To get the accessories_users table for specific accessory id number
@ -25,7 +25,8 @@
Get-SnipeitAccessoryOwner -assigned_pivot_id xxx
#>
function Reset-SnipeitAccessoryOwner() {
function Reset-SnipeitAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -35,38 +36,24 @@ function Reset-SnipeitAccessoryOwner() {
[parameter(mandatory = $true)]
[int]$assigned_pivot_id,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
$Parameters = @{
Api = "/api/v1/accessories/$assigned_pivot_id/checkin"
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
Method = 'Post'
Body = @{}
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
return $result
}

View file

@ -13,15 +13,17 @@
.PARAMETER location_id
Location id to change asset location to
.PARAMETER note
.PARAMETER notes
Notes about checkin
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command
.EXAMPLE
Remove-SnipeitUser -ID 44
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#>
function Reset-SnipeitAssetOwner() {
[CmdletBinding(
@ -37,48 +39,34 @@ function Reset-SnipeitAssetOwner() {
[int]$location_id,
[string]$note,
[string]$notes,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"note" = $note
"notes" = $notes
}
if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) }
if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) }
$Parameters = @{
Api = "/api/v1/hardware/$id/checkin"
Uri = "$url/api/v1/hardware/$id/checkin"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
return $result
}

View file

@ -54,10 +54,11 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfoeItInfo command
.EXAMPLE
Set-SnipeitAccessory -id 1 -qty 3
@ -106,10 +107,10 @@ function Set-SnipeitAccessory() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -125,36 +126,20 @@ function Set-SnipeitAccessory() {
}
process {
foreach($accessory_id in $id) {
foreach($accessory_id in $id){
$Parameters = @{
Api = "/api/v1/accessories/$accessory_id"
Uri = "$url/api/v1/accessories/$accessory_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -14,15 +14,16 @@
Notes about checkout
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.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"
@ -37,10 +38,10 @@ function Set-SnipeitAccessoryOwner() {
[string] $note,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin{
@ -48,35 +49,20 @@ function Set-SnipeitAccessoryOwner() {
}
process {
foreach($accessory_id in $id) {
foreach($accessory_id in $id){
$Parameters = @{
Api = "/api/v1/accessories/$accessory_id/checkout"
Uri = "$url/api/v1/accessories/$accessory_id/checkout"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -8,9 +8,6 @@
.PARAMETER id
ID of the Asset or array of IDs
.PARAMETER asset_tag
New tag for asset.
.PARAMETER Name
Asset name
@ -44,9 +41,6 @@
.PARAMETER purchase_date
Date of asset purchase
.PARAMETER supplier_id
Supplier id of the Asset
.PARAMETER requestable
Whether or not the asset can be requested by users with the permission to request assets
@ -69,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit
@ -87,7 +81,8 @@
Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated'
#>
function Set-SnipeitAsset() {
function Set-SnipeitAsset()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -97,9 +92,6 @@ function Set-SnipeitAsset() {
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(Mandatory=$false)]
[string]
$asset_tag,
[string]$name,
@ -125,9 +117,6 @@ function Set-SnipeitAsset() {
[datetime]$purchase_date,
[parameter(mandatory = $false)]
[int]$supplier_id,
[bool]$requestable,
[bool]$archived,
@ -144,10 +133,10 @@ function Set-SnipeitAsset() {
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey,
[Alias('CustomValues')]
@ -162,42 +151,28 @@ 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 = @{
Api = "/api/v1/hardware/$asset_id"
Uri = "$url/api/v1/hardware/$asset_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -28,15 +28,16 @@
Optional date to override the checkout time of now
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.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"
@ -60,10 +61,10 @@ function Set-SnipeitAssetOwner() {
[datetime]$checkout_at,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -80,47 +81,33 @@ 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 = @{
Api = "/api/v1/hardware/$asset_id/checkout"
Uri = "$url/api/v1/hardware/$asset_id/checkout"
Method = 'POST'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -30,16 +30,17 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Set-SnipeitCategory -id 4 -name "Laptops"
#>
function Set-SnipeitCategory() {
function Set-SnipeitCategory()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -70,10 +71,10 @@ function Set-SnipeitCategory() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -85,35 +86,20 @@ function Set-SnipeitCategory() {
}
process {
foreach($category_id in $id) {
foreach($category_id in $id){
$Parameters = @{
Api = "/api/v1/categories/$category_id"
Uri = "$url/api/v1/categories/$category_id"
Method = $RequestType
Body = $values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -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
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
An example
@ -32,7 +32,8 @@ An example
.NOTES
General notes
#>
function Set-SnipeitCompany() {
function Set-SnipeitCompany()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -53,10 +54,10 @@ function Set-SnipeitCompany() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -65,34 +66,20 @@ function Set-SnipeitCompany() {
}
process{
foreach($company_id in $id) {
foreach($company_id in $id){
$Parameters = @{
Api = "/api/v1/companies/$company_id"
Uri = "$url/api/v1/companies/$company_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -42,17 +42,19 @@ Remove current image
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Set-SnipeitComponent -id 42 -qty 12
Sets count of component with ID 42 to 12
An example
.NOTES
General notes
#>
function Set-SnipeitComponent() {
function Set-SnipeitComponent()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -88,10 +90,10 @@ function Set-SnipeitComponent() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
@ -105,35 +107,20 @@ function Set-SnipeitComponent() {
}
process {
foreach($component_id in $id) {
foreach($component_id in $id){
$Parameters = @{
Api = "/api/v1/components/$component_id"
Uri = "$url/api/v1/components/$component_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -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
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
@ -69,7 +69,8 @@ Create consumable with stock count 20 , alert when stock is 5 or lower
#>
function Set-SnipeitConsumable() {
function Set-SnipeitConsumable()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -128,10 +129,10 @@ function Set-SnipeitConsumable() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -145,35 +146,20 @@ function Set-SnipeitConsumable() {
}
process {
foreach($consumable_id in $id ) {
foreach($consumable_id in $id ){
$Parameters = @{
Api = "/api/v1/consumables/$consumable_id"
Uri = "$url/api/v1/consumables/$consumable_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -33,16 +33,17 @@
Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#>
function Set-SnipeitCustomField() {
function Set-SnipeitCustomField()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -74,10 +75,10 @@ function Set-SnipeitCustomField() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Put",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin {
@ -92,33 +93,19 @@ function Set-SnipeitCustomField() {
process{
foreach($field_id in $id) {
$Parameters = @{
Api = "/api/v1/fields/$field_id"
Uri = "$url/api/v1/fields/$field_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -30,10 +30,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Set-SnipeitDepartment -id 4 -manager_id 3
@ -68,10 +68,10 @@ function Set-SnipeitDepartment() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -83,33 +83,18 @@ function Set-SnipeitDepartment() {
process {
foreach ($department_id in $id) {
$Parameters = @{
Api = "/api/v1/departments/$department_id"
Uri = "$url/api/v1/departments/$department_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -1,16 +1,14 @@
<#
.SYNOPSIS
Sets authetication information. Deprecated, use Connect-SnipeitPS instead.
Sets authetication information
.DESCRIPTION
Deprecated combatibilty function that Set apikey and url user to connect Snipe-It system.
Please use Connect-SnipeitPS instead.
Set apikey and url user to connect Snipe-It system
.PARAMETER url
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Set-SnipeitInfo -url $url -apiKey -Verbose
@ -19,18 +17,50 @@ 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,
Write-Warning "Deprecated $($MyInvocation.InvocationName) is still working, please use Connect-SnipeitPS instead."
[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
}
PROCESS {
Connect-SnipeitPS -Url $url -apiKey $apiKey
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
}
}
}
}

View file

@ -63,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.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 = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -154,34 +154,19 @@ function Set-SnipeitLicense() {
}
process {
foreach($license_id in $id) {
foreach($license_id in $id){
$Parameters = @{
Api = "/api/v1/licenses/$license_id"
Uri = "$url/api/v1/licenses/$license_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -20,10 +20,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3
@ -38,7 +38,8 @@
Checkin licence seat id 1 of licence id 1
#>
function Set-SnipeitLicenseSeat() {
function Set-SnipeitLicenseSeat()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -63,10 +64,10 @@ function Set-SnipeitLicenseSeat() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -77,33 +78,18 @@ function Set-SnipeitLicenseSeat() {
process{
foreach($license_id in $id) {
$Parameters = @{
Api = "/api/v1/licenses/$license_id/seats/$seat_id"
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}
}

View file

@ -54,10 +54,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.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 = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -121,34 +121,18 @@ function Set-SnipeitLocation() {
process{
foreach ($location_id in $id) {
$Parameters = @{
Api = "/api/v1/locations/$location_id"
Uri = "$url/api/v1/locations/$location_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -18,16 +18,17 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
New-SnipeitManufacturer -name "HP"
#>
function Set-SnipeitManufacturer() {
function Set-SnipeitManufacturer()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
@ -45,10 +46,10 @@ function Set-SnipeitManufacturer() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -61,33 +62,17 @@ function Set-SnipeitManufacturer() {
process{
foreach ($manufacturer_id in $id) {
$Parameters = @{
Api = "/api/v1/manufacturers/$manufacturer_id"
Uri = "$url/api/v1/manufacturers/$manufacturer_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -33,10 +33,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.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 = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -90,33 +90,17 @@ function Set-SnipeitModel() {
process {
foreach ($model_id in $id) {
$Parameters = @{
Api = "/api/v1/models/$model_id"
Uri = "$url/api/v1/models/$model_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -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
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy"
@ -32,7 +32,8 @@ Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending
#>
function Set-SnipeitStatus() {
function Set-SnipeitStatus()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
@ -58,10 +59,10 @@ function Set-SnipeitStatus() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -72,32 +73,16 @@ function Set-SnipeitStatus() {
process {
foreach($status_id in $id) {
$Parameters = @{
Api = "/api/v1/statuslabels/$status_id"
Uri = "$url/api/v1/statuslabels/$status_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -51,10 +51,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
.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 = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
@ -117,34 +117,18 @@ function Set-SnipeitSupplier() {
process {
foreach ($supplier_id in $id) {
$Parameters = @{
Api = "/api/v1/suppliers/$supplier_id"
Uri = "$url/api/v1/suppliers/$supplier_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -47,9 +47,6 @@
.PARAMETER manager_id
ID number of manager
.PARAMETER groups
ID numbers of groups
.PARAMETER employee_num
Employeenumber
@ -66,10 +63,10 @@
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -95,7 +92,7 @@ function Set-SnipeitUser() {
[string]$last_name,
[ValidateLength(1,256)]
[string]$username,
[string]$userName,
[string]$jobtitle,
@ -113,16 +110,12 @@ function Set-SnipeitUser() {
[Nullable[System.Int32]]$manager_id,
[int[]]$groups,
[string]$employee_num,
[bool]$activated,
[string]$notes,
[bool]$ldap_import,
[ValidateScript({Test-Path $_})]
[string]$image,
@ -131,10 +124,10 @@ function Set-SnipeitUser() {
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $false)]
[parameter(mandatory = $true)]
[string]$apiKey
)
begin{
@ -151,33 +144,17 @@ function Set-SnipeitUser() {
process{
foreach($user_id in $id) {
$Parameters = @{
Api = "/api/v1/users/$user_id"
Uri = "$url/api/v1/users/$user_id"
Method = 'PATCH'
Body = $Values
Token = $apiKey
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyUrl -url $url
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
}

View file

@ -15,7 +15,8 @@ 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"
@ -33,8 +34,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])"

View file

@ -12,7 +12,7 @@
RootModule = 'SnipeitPS'
# Version number of this module.
ModuleVersion = '1.10'
ModuleVersion = '1.9'
# Supported PSEditions
# CompatiblePSEditions = @()
@ -70,7 +70,6 @@ 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',

View file

@ -5,22 +5,14 @@ Powershell API for Snipeit Asset Management
$scriptRoot = $PSScriptRoot + '\Public'
Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
. $_.FullName
Import-Module $_.FullName
}
$scriptRoot = $PSScriptRoot + '\Private'
Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
. $_.FullName
Import-Module $_.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

View file

@ -17,7 +17,7 @@ environment:
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
PShell: '5'
version: 1.10.{build}
version: 1.9.{build}
# Don't rebuild when I tag a release on GitHub
skip_tags: true

View file

@ -1,137 +0,0 @@
---
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 <Uri> -apiKey <String> [<CommonParameters>]
```
### Connect with url and secure apikey
```
Connect-SnipeitPS -url <Uri> -secureApiKey <SecureString> [<CommonParameters>]
```
### Connect with credential
```
Connect-SnipeitPS -siteCred <PSCredential> [<CommonParameters>]
```
## 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
## 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

View file

@ -16,17 +16,17 @@ Gets a list of Snipe-it Accessories
```
Get-SnipeitAccessory [-search <String>] [-company_id <Int32>] [-category_id <Int32>] [-manufacturer_id <Int32>]
[-supplier_id <Int32>] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
-url <String> -apiKey <String> [<CommonParameters>]
```
### Get by ID
```
Get-SnipeitAccessory [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitAccessory [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Accessories checked out to user id
```
Get-SnipeitAccessory [-user_id <Int32>] [-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitAccessory [-user_id <Int32>] [-all] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -68,15 +68,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -236,15 +235,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -13,7 +13,7 @@ Get list of checked out accessories
## SYNTAX
```
Get-SnipeitAccessoryOwner [-id] <Int32> [[-url] <String>] [[-apiKey] <String>] [-WhatIf] [-Confirm]
Get-SnipeitAccessoryOwner [-id] <Int32> [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
[<CommonParameters>]
```
@ -30,15 +30,14 @@ Get-SnipeitAccessoryOwner -id 1
## PARAMETERS
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
User's API Key for Snipeit.
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 3
Default value: None
Accept pipeline input: False
@ -61,15 +60,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 2
Default value: None
Accept pipeline input: False

View file

@ -15,7 +15,7 @@ Gets and search Snipe-it Activity history
```
Get-SnipeitActivity [[-search] <String>] [[-target_type] <String>] [[-target_id] <Int32>]
[[-item_type] <String>] [[-item_id] <Int32>] [[-action_type] <String>] [[-limit] <Int32>] [[-offset] <Int32>]
[-all] [[-url] <String>] [[-apiKey] <String>] [<CommonParameters>]
[-all] [-url] <String> [-apiKey] <String> [<CommonParameters>]
```
## DESCRIPTION
@ -67,15 +67,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 10
Default value: None
Accept pipeline input: False
@ -190,15 +189,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 9
Default value: None
Accept pipeline input: False

View file

@ -17,46 +17,46 @@ Gets a list of Snipe-it Assets or specific asset
Get-SnipeitAsset [-search <String>] [-order_number <String>] [-model_id <Int32>] [-category_id <Int32>]
[-manufacturer_id <Int32>] [-company_id <Int32>] [-location_id <Int32>] [-depreciation_id <Int32>]
[-requestable <Boolean>] [-status <String>] [-status_id <Int32>] [-sort <String>] [-order <String>]
[-limit <Int32>] [-offset <Int32>] [-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
[-limit <Int32>] [-offset <Int32>] [-all] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get with id
```
Get-SnipeitAsset [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitAsset [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get with asset tag
```
Get-SnipeitAsset [-asset_tag <String>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitAsset [-asset_tag <String>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get with serial
```
Get-SnipeitAsset [-serial <String>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitAsset [-serial <String>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Assets due auditing soon
```
Get-SnipeitAsset [-audit_due] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
-url <String> -apiKey <String> [<CommonParameters>]
```
### Assets overdue for auditing
```
Get-SnipeitAsset [-audit_overdue] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
-url <String> -apiKey <String> [<CommonParameters>]
```
### Assets checked out to user id
```
Get-SnipeitAsset [-user_id <Int32>] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>]
[-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
[-all] -url <String> -apiKey <String> [<CommonParameters>]
```
### Assets with component id
```
Get-SnipeitAsset [-component_id <Int32>] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>]
[-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
[-all] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -66,7 +66,7 @@ Get-SnipeitAsset [-component_id <Int32>] [-sort <String>] [-order <String>] [-li
### EXAMPLE 1
```
Get-SnipeitAsset -all
Get-SnipeitAsset -all -url "https://assets.example.com"-token "token..."
Returens all assets
```
@ -136,15 +136,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -469,15 +468,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -14,7 +14,7 @@ Lists Snipe-it Assets Maintenances
```
Get-SnipeitAssetMaintenance [[-search] <String>] [[-asset_id] <Int32>] [[-sort] <String>] [[-order] <String>]
[[-limit] <Int32>] [-all] [[-offset] <Int32>] [[-url] <String>] [[-apiKey] <String>] [<CommonParameters>]
[[-limit] <Int32>] [-all] [[-offset] <Int32>] [-url] <String> [-apiKey] <String> [<CommonParameters>]
```
## DESCRIPTION
@ -24,17 +24,17 @@ Get-SnipeitAssetMaintenance [[-search] <String>] [[-asset_id] <Int32>] [[-sort]
### EXAMPLE 1
```
Get-SnipeitAssetMaintenances
Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..."
```
### EXAMPLE 2
```
Get-SnipeitAssetMaintenances -search "myMachine"
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
```
### EXAMPLE 3
```
Get-SnipeitAssetMaintenances -search "myMachine"
Get-SnipeitAssetMaintenances -search "myMachine" -url "https://assets.example.com" -token "token..."
```
## PARAMETERS
@ -55,15 +55,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 8
Default value: None
Accept pipeline input: False
@ -163,15 +162,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 7
Default value: None
Accept pipeline input: False

View file

@ -15,12 +15,12 @@ Gets a list of Snipe-it Categories
### Search (Default)
```
Get-SnipeitCategory [-search <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
-url <String> -apiKey <String> [<CommonParameters>]
```
### Get with ID
```
Get-SnipeitCategory [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitCategory [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -56,15 +56,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -149,15 +148,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
Url of Snipeit system.
Url of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -14,13 +14,13 @@ Gets a list of Snipe-it Companies
### Search (Default)
```
Get-SnipeitCompany [-search <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitCompany [-search <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all] -url <String>
-apiKey <String> [<CommonParameters>]
```
### Get with ID
```
Get-SnipeitCompany [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitCompany [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -58,15 +58,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -151,15 +150,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -15,13 +15,13 @@ Gets a list of Snipe-it Components
### Search (Default)
```
Get-SnipeitComponent [-search <String>] [-category_id <Int32>] [-company_id <Int32>] [-location_id <Int32>]
[-order <String>] [-sort <String>] [-limit <Int32>] [-offset <Int32>] [-all] [-url <String>]
[-apiKey <String>] [<CommonParameters>]
[-order <String>] [-sort <String>] [-limit <Int32>] [-offset <Int32>] [-all] -url <String> -apiKey <String>
[<CommonParameters>]
```
### Get with ID
```
Get-SnipeitComponent [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitComponent [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -65,15 +65,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -218,15 +217,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system,can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -16,12 +16,12 @@ Gets a list of Snipe-it consumables
```
Get-SnipeitConsumable [-search <String>] [-category_id <Int32>] [-company_id <Int32>]
[-manufacturer_id <Int32>] [-location_id <Int32>] [-order <String>] [-sort <String>] [-expand]
[-limit <Int32>] [-offset <Int32>] [-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
[-limit <Int32>] [-offset <Int32>] [-all] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get with ID
```
Get-SnipeitConsumable [-id <Int32[]>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitConsumable [-id <Int32[]>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -65,15 +65,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -248,15 +247,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system,can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -13,7 +13,7 @@ Returns specific Snipe-IT custom field or a list of all custom field
## SYNTAX
```
Get-SnipeitCustomField [[-id] <Int32>] [[-url] <String>] [[-apiKey] <String>] [<CommonParameters>]
Get-SnipeitCustomField [[-id] <Int32>] [-url] <String> [-apiKey] <String> [<CommonParameters>]
```
## DESCRIPTION
@ -23,28 +23,20 @@ Get-SnipeitCustomField [[-id] <Int32>] [[-url] <String>] [[-apiKey] <String>] [<
### EXAMPLE 1
```
Get-SnipeitCustomField
Get all custom fields
```
### EXAMPLE 2
```
Get-SnipeitCustomField -id 1
Get custom field with ID 1
Get-SnipeitCustomField -url "https://assets.example.com" -token "token..."
```
## PARAMETERS
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 3
Default value: None
Accept pipeline input: False
@ -67,15 +59,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 2
Default value: None
Accept pipeline input: False

View file

@ -15,12 +15,12 @@ Gets a list of Snipe-it Departments
### Search (Default)
```
Get-SnipeitDepartment [-search <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-sort <String>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
[-sort <String>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get with ID
```
Get-SnipeitDepartment [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitDepartment [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -30,7 +30,7 @@ Get-SnipeitDepartment [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonP
### EXAMPLE 1
```
Get-SnipeitDepartment
Get-SnipeitDepartment -url "https://assets.example.com" -token "token..."
```
### EXAMPLE 2
@ -61,15 +61,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -169,15 +168,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -13,7 +13,7 @@ Returns a fieldset or list of Snipe-it Fieldsets
## SYNTAX
```
Get-SnipeitFieldset [[-id] <Int32>] [[-url] <String>] [[-apiKey] <String>] [<CommonParameters>]
Get-SnipeitFieldset [[-id] <Int32>] [-url] <String> [-apiKey] <String> [<CommonParameters>]
```
## DESCRIPTION
@ -23,28 +23,25 @@ Get-SnipeitFieldset [[-id] <Int32>] [[-url] <String>] [[-apiKey] <String>] [<Com
### EXAMPLE 1
```
Get-SnipeitFieldset
Get all fieldsets
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..."
```
### EXAMPLE 2
```
Get-SnipeitFieldset | Where-Object {$_.name -eq "Windows" }
Gets fieldset by name
Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Windows" }
```
## PARAMETERS
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 3
Default value: None
Accept pipeline input: False
@ -67,15 +64,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 2
Default value: None
Accept pipeline input: False

View file

@ -17,23 +17,23 @@ Gets a list of Snipe-it Licenses
Get-SnipeitLicense [-search <String>] [-name <String>] [-company_id <Int32>] [-product_key <String>]
[-order_number <String>] [-purchase_order <String>] [-license_name <String>] [-license_email <MailAddress>]
[-manufacturer_id <Int32>] [-supplier_id <Int32>] [-depreciation_id <Int32>] [-category_id <Int32>]
[-order <String>] [-sort <String>] [-limit <Int32>] [-offset <Int32>] [-all] [-url <String>]
[-apiKey <String>] [<CommonParameters>]
[-order <String>] [-sort <String>] [-limit <Int32>] [-offset <Int32>] [-all] -url <String> -apiKey <String>
[<CommonParameters>]
```
### Get with ID
```
Get-SnipeitLicense [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitLicense [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get licenses checked out to user ID
```
Get-SnipeitLicense [-user_id <Int32>] [-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitLicense [-user_id <Int32>] [-all] -url <String> -apiKey <String> [<CommonParameters>]
```
### Get licenses checked out to asset ID
```
Get-SnipeitLicense [-asset_id <Int32>] [-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitLicense [-asset_id <Int32>] [-all] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -69,15 +69,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -357,15 +356,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

View file

@ -14,7 +14,7 @@ Gets a list of Snipe-it Licenses Seats or specific Seat
```
Get-SnipeitLicenseSeat [-id] <Int32> [[-seat_id] <Int32>] [[-limit] <Int32>] [[-offset] <Int32>] [-all]
[[-url] <String>] [[-apiKey] <String>] [<CommonParameters>]
[-url] <String> [-apiKey] <String> [<CommonParameters>]
```
## DESCRIPTION
@ -45,15 +45,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 6
Default value: None
Accept pipeline input: False
@ -123,15 +122,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: 5
Default value: None
Accept pipeline input: False

View file

@ -15,12 +15,12 @@ Gets a list of Snipe-it Locations
### Search (Default)
```
Get-SnipeitLocation [-search <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-url <String>] [-apiKey <String>] [<CommonParameters>]
-url <String> -apiKey <String> [<CommonParameters>]
```
### Get with ID
```
Get-SnipeitLocation [-id <Int32>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
Get-SnipeitLocation [-id <Int32>] -url <String> -apiKey <String> [<CommonParameters>]
```
## DESCRIPTION
@ -56,15 +56,14 @@ Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
@ -149,15 +148,14 @@ Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False

Some files were not shown because too many files have changed in this diff Show more