Compare commits

..

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

164 changed files with 2033 additions and 12816 deletions

View file

@ -1,32 +0,0 @@
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* SnipitPS Module version used:
* Operating System and PowerShell version:
* Snipe It version:
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- Please add command output with -Verbose and if possible -Debug switches -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

View file

@ -5,110 +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/), The format is based on [Keep a Changelog](http://keepachangelog.com/),
and this project adheres to [Semantic Versioning](http://semver.org/). 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
## New features
Support for image upload and removes. Just specify filename for -image para-
meter when creating or updating item on snipe.
Remove image use -image_delete parameter.
*Snipe It version greater than 5.1.8 is needed to support image parameters.*
Most of set-commands have new -RequestType parameter that defaults to Patch.
If needed request method can be changed from default.
## New Functions
Following new commands have been added to SnipeitPS:
- New-Supplier
- Set-Supplier
- Remove-Supplier
- Set-Manufacturer
# [v.1.8.x] - 2021-06-17
## Support for new Snipe it endpoints
## New features
Get-SnipeitAccessories -user_id
returns accessories checked out to user id
Get-SnipeitAsset -user_id
Return Assets checked out to user id
Get-SnipeitAsset -component_id
Returns assets with specific component id
Get-SnipeitLicense -user_id
Get licenses checked out to user ID
Get-SnipeitLicense -asset_id
Get licenses checked out to asset ID
Get-SnipeitUser -accessory_id
Get users that have specific accessory id checked out
# [v.1.7.x] - 2021-06-14
## Consumables
## New features
Added support for consumables
## New functions
- New-SnipeitConsumable
- Get-SnipeitConsumable
- Set-SnipeitConsumable
- Remove-SnipeitConsumable
# [v.1.6.x] - 2021-06-14
## Remove more things ja set some more
### New features
Added some set and remove functions. Pipelineinput supported
for all remove functions.
### New functions
- Remove-SnipeitAccessory
- Remove-SnipeitCategory
- Remove-SnipeitCompany
- Remove-SnipeitComponent
- Remove-SnipeitCustomField
- Remove-SnipeitDepartment
- Remove-SnipeitLicense
- Remove-SnipeitLocation
- Remove-SnipeitManufacturer
- Remove-SnipeitModel
- Set-SnipeitCategory
- Set-SnipeitCompany
- Set-SnipeitCustomField
- Set-SnipeitDepartment
- Set-SnipeitStatus
# [v1.5.x] - 2021-06-08 # [v1.5.x] - 2021-06-08
## Piping input ## Piping input

View file

@ -19,30 +19,15 @@ Install-Module SnipeitPS
# Check for updates occasionally: # Check for updates occasionally:
Update-Module SnipeitPS Update-Module SnipeitPS
# import module to session: # To use each session:
Import-Module SnipeitPS Import-Module SnipeitPS
Set-SnipeitInfo -URL 'https://asset.example.com' -apiKey 'tokenKey'
# Set connection
Connect-SnipeitPS -URL 'https://asset.example.com' -apiKey 'tokenKey'
# Or set connection with safely saved credentials, first save credentials
$SnipeCred =Get-Credential -message "Use url as username and apikey as password"
$SnipeCred | Export-CliXml snipecred.xml
# ..then use your saved credentials like
Connect-SnipeitPS -siteCred (Import-CliXml snipecred.xml)
# OR use -secureApiKey that allow pass apiKey as SecureString
# if you are usin Microsoft.PowerShell.SecretManagement or like
Connect-SnipeitPS -URL 'https://asset.example.com' -secureApiKey 'tokenKey'
``` ```
### Usage ### Usage
```powershell ```powershell
# Review the help at any time! # Review the help at any time!
Get-Help about_SnipeitPS
Get-Command -Module SnipeitPS Get-Command -Module SnipeitPS
Get-Help Get-SnipeitAsset -Full # or any other command Get-Help Get-SnipeitAsset -Full # or any other command
``` ```

View file

@ -88,14 +88,15 @@ task GitStatus -If (Test-Path .git) {
} }
} }
task TestVersions TestPS task TestVersions TestPS3, TestPS4, TestPS4, TestPS5
task TestPS3 {
task TestPS { exec {powershell.exe -Version 3 -NoProfile Invoke-Build PesterTests}
if($env:PShell -eq '7') { }
exec {pwsh.exe -NoProfile Invoke-Build PesterTests} task TestPS4 {
}else { exec {powershell.exe -Version 4 -NoProfile Invoke-Build PesterTests}
exec {powershell.exe -NoProfile Invoke-Build PesterTests} }
} task TestPS5 {
exec {powershell.exe -Version 5 -NoProfile Invoke-Build PesterTests}
} }
# Synopsis: Invoke Pester Tests # Synopsis: Invoke Pester Tests
@ -191,9 +192,7 @@ task Deploy -If (
(-not ($env:APPVEYOR_PULL_REQUEST_NUMBER)) -and (-not ($env:APPVEYOR_PULL_REQUEST_NUMBER)) -and
# Do not deploy if the commit contains the string "skip-deploy" # Do not deploy if the commit contains the string "skip-deploy"
# Meant for major/minor version publishes with a .0 build/patch version (like 2.1.0) # Meant for major/minor version publishes with a .0 build/patch version (like 2.1.0)
$env:APPVEYOR_REPO_COMMIT_MESSAGE -notlike '*skip-deploy*' -and $env:APPVEYOR_REPO_COMMIT_MESSAGE -notlike '*skip-deploy*'
# publish from one powershell version is enought
$env:PShell -eq '5'
) { ) {
Remove-Module SnipeitPS -ErrorAction SilentlyContinue Remove-Module SnipeitPS -ErrorAction SilentlyContinue
}, PublishToGallery }, PublishToGallery

View file

@ -57,13 +57,5 @@ function Get-ParameterValue {
} }
finally {} finally {}
} }
#Convert switch parameters to booleans so it converts nicely to json
foreach ( $key in @($ParameterValues.Keys)) {
if ($true -eq $ParameterValues[$key].IsPresent){
$ParameterValues[$key]=$true;
}
}
return $ParameterValues return $ParameterValues
} }

View file

@ -1,62 +1,32 @@
<# function Invoke-SnipeitMethod {
<#
.SYNOPSIS .SYNOPSIS
Make api request to Snipe it Extracted invokation of the REST method to own function.
#>
.PARAMETER Api
Api part of url. prefix with slash ie. "/api/v1/hardware"
.PARAMETER Method
Method of the invokation, one of following "GET", "POST", "PUT", "PATCH" or "DELETE"
.PARAMETER Body
Request body as hashtable. Needed for post, put and patch
.PARAMETER GetParameters
Get-Parameters as hastable.
#>
function Invoke-SnipeitMethod {
[OutputType( [OutputType(
[PSObject] [PSObject]
)] )]
param ( param (
# REST API to invoke
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$Api, [Uri]$URi,
# Method of the invokation
[ValidateSet("GET", "POST", "PUT", "PATCH", "DELETE")] [ValidateSet("GET", "POST", "PUT", "PATCH", "DELETE")]
[string]$Method = "GET", [string]$Method = "GET",
[Hashtable]$Body, # Body of the request
[ValidateNotNullOrEmpty()]
[string]$Body,
[string] $Token,
# GET Parameters
[Hashtable]$GetParameters [Hashtable]$GetParameters
) )
BEGIN { 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 # Validation of parameters
if (($Method -in ("POST", "PUT", "PATCH")) -and (!($Body))) { if (($Method -in ("POST", "PUT", "PATCH")) -and (!($Body))) {
$message = "The following parameters are required when using the ${Method} parameter: Body." $message = "The following parameters are required when using the ${Method} parameter: Body."
@ -64,117 +34,42 @@ function Invoke-SnipeitMethod {
Throw $exception Throw $exception
} }
#Build request uri
$apiUri = "$Url$Api"
#To support images "image" property have be handled before this
$_headers = @{ $_headers = @{
"Authorization" = "Bearer $($Token)" "Authorization" = "Bearer $($token)"
'Content-Type' = 'application/json; charset=utf-8' 'Content-Type' = 'application/json; charset=utf-8'
"Accept" = "application/json" "Accept" = "application/json"
} }
} }
Process { Process {
# This can be done using $Body, maybe some day - PetriAsi if ($GetParameters -and ($URi -notlike "*\?*"))
if ($GetParameters -and ($apiUri -notlike "*\?*")){ {
Write-Debug "Using `$GetParameters: $($GetParameters | Out-String)" Write-Debug "Using `$GetParameters: $($GetParameters | Out-String)"
[string]$apiUri = $apiUri + (ConvertTo-GetParameter $GetParameters) [string]$URI += (ConvertTo-GetParameter $GetParameters)
# Prevent recursive appends # Prevent recursive appends
$GetParameters = $null $GetParameters = $null
} }
# set mandatory parameters # set mandatory parameters
$splatParameters = @{ $splatParameters = @{
Uri = $apiUri Uri = $URi
Method = $Method Method = $Method
Headers = $_headers Headers = $_headers
UseBasicParsing = $true UseBasicParsing = $true
ErrorAction = 'SilentlyContinue' ErrorAction = 'SilentlyContinue'
} }
# Send image requests as multipart/form-data if supported if ($Body) {$splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes($Body)}
if($null -ne $body -and $Body.Keys -contains 'image' ){
if($PSVersionTable.PSVersion -ge '7.0'){
$Body['image'] = get-item $body['image']
# As multipart/form-data is always POST we need add
# requested method for laravel named as '_method'
$Body['_method'] = $Method
$splatParameters["Method"] = 'POST'
$splatParameters["Form"] = $Body
} else {
# use base64 encoded images for powershell version < 7
Add-Type -AssemblyName "System.Web"
$mimetype = [System.Web.MimeMapping]::GetMimeMapping($body['image'])
$Body['image'] = 'data:@'+$mimetype+';base64,'+[Convert]::ToBase64String([IO.File]::ReadAllBytes($Body['image']))
}
}
if ($Body -and $splatParameters.Keys -notcontains 'Form') {
$splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes(($Body | Convertto-Json))
}
$script:PSDefaultParameterValues = $global:PSDefaultParameterValues $script:PSDefaultParameterValues = $global:PSDefaultParameterValues
Write-Debug "$($Body | ConvertTo-Json)" Write-Debug $Body
#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 # Invoke the API
try { try {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Invoking method $Method to URI $URi" Write-Verbose "[$($MyInvocation.MyCommand.Name)] Invoking method $Method to URI $URi"
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoke-WebRequest with: $($splatParameters | Out-String)" Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoke-WebRequest with: $($splatParameters | Out-String)"
$webResponse = Invoke-RestMethod @splatParameters $webResponse = Invoke-WebRequest @splatParameters
} }
catch { catch {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server" Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server"
@ -186,44 +81,28 @@ function Invoke-SnipeitMethod {
if ($webResponse) { if ($webResponse) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Status code: $($webResponse.StatusCode)" Write-Verbose "[$($MyInvocation.MyCommand.Name)] Status code: $($webResponse.StatusCode)"
if ($webResponse) { if ($webResponse.Content) {
Write-Verbose $webResponse Write-Verbose $webResponse.Content
# API returned a Content: lets work with it # API returned a Content: lets work wit it
try{ try{
if ($webResponse.status -eq "error") { $response = ConvertFrom-Json -InputObject $webResponse.Content
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received ... resolving"
if ($response.status -eq "error") {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received from; resolving"
# This could be handled nicely in an function such as: # This could be handled nicely in an function such as:
# ResolveError $response -WriteError # ResolveError $response -WriteError
Write-Error $($webResponse.messages | Out-String) Write-Error $($response.messages | Out-String)
} elseif ( $webResponse.StatusCode -eq 'Unauthorized') { }
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An Unauthorized response was received" else {
Write-Error "Cannot connect to Snipe It: Unauthorized." $result = $response
return $false if (($response) -and ($response | Get-Member -Name payload))
} else { {
#update operations return payload $result = $response.payload
if ($webResponse.payload) {
$result = $webResponse.payload
} }
#Search operations return rows elseif (($response) -and ($response | Get-Member -Name rows)) {
elseif ($webResponse.rows) { $result = $response.rows
$result = $webResponse.rows
} }
#Remove operations returns status and message
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
}
Write-Verbose "Status: $($webResponse.status)"
Write-Verbose "Messages: $($webResponse.messages)"
$result $result
} }
@ -234,7 +113,7 @@ function Invoke-SnipeitMethod {
} }
elseif ($webResponse.StatusCode -eq "Unauthorized") { 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 { else {
# No content, although statusCode < 400 # No content, although statusCode < 400
@ -252,4 +131,3 @@ function Invoke-SnipeitMethod {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended" 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 .PARAMETER search
A text string to search the Accessory data A text string to search the Accessory data
.PARAMETER user_id
Return Accessories checked out to user id
.PARAMETER id .PARAMETER id
A id of specific Accessory 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 .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitAccessory -search Keyboard Get-SnipeitAccessory -search Keyboard
@ -47,14 +32,9 @@ Get-SnipeitAccessory -search Keyboard
.EXAMPLE .EXAMPLE
Get-SnipeitAccessory -id 1 Get-SnipeitAccessory -id 1
.EXAMPLE
Get-SnipeitAccessory -user_id 1
Get accessories checked out to user ID 1
#> #>
function Get-SnipeitAccessory() { function Get-SnipeitAccessory() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -62,9 +42,6 @@ function Get-SnipeitAccessory() {
[parameter(ParameterSetName='Get by ID')] [parameter(ParameterSetName='Get by ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Accessories checked out to user id')]
[int]$user_id,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[int]$company_id, [int]$company_id,
@ -91,70 +68,51 @@ function Get-SnipeitAccessory() {
[int]$offset, [int]$offset,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Accessories checked out to user id')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
switch($PsCmdlet.ParameterSetName) { if ($id -and $search){
'Search' {$api = "/api/v1/accessories"} throw "Please specify only one of -id or -search parameter"
'Get by ID' {$api= "/api/v1/accessories/$id"}
'Accessories checked out to user id' {$api = "/api/v1/users/$user_id/accessories"}
}
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($all) {
$offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = "$url/api/v1/accessories"
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitAccessory @callargs GetParameters = $SearchParameter
$res Token = $apiKey
if ($res.count -lt $limit) { }
break
} if($id){
$offstart = $offstart + $limit $Parameters.Uri ="$url/api/v1/accessories/$id"
}
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitAccessory @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,15 +8,16 @@
Unique ID For accessory to list Unique ID For accessory to list
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitAccessoryOwner -id 1 Get-SnipeitAccessoryOwner -id 1
#> #>
function Get-SnipeitAccessoryOwner() { function Get-SnipeitAccessoryOwner()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -26,39 +27,23 @@ function Get-SnipeitAccessoryOwner() {
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[int]$id, [int]$id,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
$Parameters = @{
Api = "/api/v1/accessories/$id/checkedout"
Method = 'GET'
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/accessories/$id/checkedout"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'GET'
} Token = $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?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
# reset legacy sessions {
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $result = Invoke-SnipeitMethod @Parameters
Reset-SnipeitPSLegacyApi
}
} }
return $result
} }

View file

@ -30,10 +30,10 @@ Result offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitAccessory -search Keyboard Get-SnipeitAccessory -search Keyboard
@ -71,70 +71,51 @@ function Get-SnipeitActivity() {
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
if (($target_type -and -not $target_id) -or
($target_id -and -not $target_type)) {
throw "Please specify both target_type and target_id"
}
if (($item_type -and -not $item_id) -or if(($target_type -and -not $target_id) -or
($item_id -and -not $item_type)) { ($target_id -and -not $target_type)) {
throw "Please specify both item_type and item_id" throw "Please specify both target_type and target_id"
}
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/reports/activity"
Method = 'Get'
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(($item_type -and -not $item_id) -or
if ($all) { ($item_id -and -not $item_type)) {
$offstart = $(if ($offset) {$offset} Else {0}) throw "Please specify both item_type and item_id"
$callargs = $SearchParameter }
$callargs.Remove('all')
while ($true) { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitActivity @callargs $Parameters = @{
$res Uri = "$url/api/v1/reports/activity"
if ($res.count -lt $limit) { Method = 'Get'
break GetParameters = $SearchParameter
} Token = $apiKey
$offstart = $offstart + $limit }
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitActivity @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -14,27 +14,12 @@ Exact asset tag to query
.PARAMETER asset_serial .PARAMETER asset_serial
Exact asset serialnumber to query Exact asset serialnumber to query
.PARAMETER audit_due
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 .PARAMETER order_number
Optionally restrict asset results to this order number Optionally restrict asset results to this order number
.PARAMETER model_id .PARAMETER model_id
Optionally restrict asset results to this asset model ID Optionally restrict asset results to this asset model ID
.PARAMETER category_id .PARAMETER category_id
Optionally restrict asset results to this category ID Optionally restrict asset results to this category ID
@ -47,22 +32,12 @@ Optionally restrict asset results to this company ID
.PARAMETER location_id .PARAMETER location_id
Optionally restrict asset results to this 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 .PARAMETER status
Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable
.PARAMETER status_id .PARAMETER status_id
Optionally restrict asset results to this status label 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 .PARAMETER sort
Specify the column name you wish to sort by Specify the column name you wish to sort by
@ -79,52 +54,25 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitAsset -all Get-SnipeitAsset -url "https://assets.example.com"-token "token..."
Returens all assets
.EXAMPLE .EXAMPLE
Get-SnipeitAsset -search "myMachine" Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
Search for specific asset
.EXAMPLE .EXAMPLE
Get-SnipeitAsset -id 3 Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
Get asset with id number 3
.EXAMPLE .EXAMPLE
Get-SnipeitAsset -asset_tag snipe0003 Get-SnipeitAsset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
Get asset with asset tag snipe00033
.EXAMPLE
Get-SnipeitAsset -serial 1234
Get asset with searial number 1234
.EXAMPLE
Get-SnipeitAsser -audit_due
Get Assets due auditing soon
.EXAMPLE
Get-SnipeitAsser -audit_overdue
Get Assets overdue for auditing
.EXAMPLE
Get-AnipeitAsset -user_id 4
Get Assets checked out to user id 4
.EXAMPLE
Get-SnipeitAsset -component_id 5
Get Assets with component id 5
#> #>
function Get-SnipeitAsset() { function Get-SnipeitAsset() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -139,21 +87,6 @@ function Get-SnipeitAsset() {
[Alias('asset_serial')] [Alias('asset_serial')]
[string]$serial, [string]$serial,
[parameter(ParameterSetName='Assets due auditing soon')]
[switch]$audit_due,
[parameter(ParameterSetName='Assets overdue for auditing')]
[switch]$audit_overdue,
[parameter(ParameterSetName='Assets checked out to user id')]
[int]$user_id,
[parameter(ParameterSetName='Assets with component id')]
[int]$component_id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$order_number, [string]$order_number,
@ -185,123 +118,85 @@ function Get-SnipeitAsset() {
[int]$status_id, [int]$status_id,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[hashtable]$customfields, [string]$sort = "created_at",
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
[parameter(ParameterSetName='Assets checked out to user id')]
[parameter(ParameterSetName='Assets with component id')]
[ValidateSet('id','created_at','asset_tag','serial','order_number','model_id','category_id','manufacturer_id','company_id','location_id','status','status_id')]
[string]$sort,
[parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
[parameter(ParameterSetName='Assets checked out to user id')]
[parameter(ParameterSetName='Assets with component id')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order, [string]$order = "desc",
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
[parameter(ParameterSetName='Assets checked out to user id')]
[parameter(ParameterSetName='Assets with component id')]
[int]$limit = 50, [int]$limit = 50,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
[parameter(ParameterSetName='Assets checked out to user id')]
[parameter(ParameterSetName='Assets with component id')]
[int]$offset, [int]$offset,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Assets due auditing soon')]
[parameter(ParameterSetName='Assets overdue for auditing')]
[parameter(ParameterSetName='Assets checked out to user id')]
[parameter(ParameterSetName='Assets with component id')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $true)]
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
begin { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
# Add in custom fields. $apiurl = "$url/api/v1/hardware"
if ($customfields.Count -gt 0) {
foreach ($pair in $customfields.GetEnumerator()) { if ($search -and ($asset_tag -or $asset_serial -or $id)) {
if (-Not $SearchParameter.ContainsKey($pair.Name)) { Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
$SearchParameter.Add($pair.Name, $pair.Value) }
}
if ($id) {
if ( $search -or $asset_serial -or $asset_tag) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
}
$apiurl= "$url/api/v1/hardware/$id"
}
if ($asset_tag) {
if ( $search -or $asset_serial -or $id) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of -search , -asset_tag or -asset_serial parameter"
}
$apiurl= "$url/api/v1/hardware/bytag/$asset_tag"
}
if ($asset_serial) {
if ( $search -or $asset_tag) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only one of-search , -asset_tag or -asset_serial parameter"
}
$apiurl= "$url/api/v1/hardware/byserial/$asset_serial"
}
$Parameters = @{
Uri = $apiurl
Method = 'Get'
GetParameters = $SearchParameter
Token = $apiKey
}
if ($all) {
$offstart = $(if ($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitAsset @callargs
$res
if ( $res.count -lt $limit) {
break
} }
$offstart = $offstart + $limit
} }
} else {
switch ($PsCmdlet.ParameterSetName) { $result = Invoke-SnipeitMethod @Parameters
'Search' { $api = "/api/v1/hardware" } $result
'Get with id' {$api= "/api/v1/hardware/$id"}
'Get with asset tag' {$api= "/api/v1/hardware/bytag/$asset_tag"}
'Get with serial' { $api= "/api/v1/hardware/byserial/$serial"}
'Assets due auditing soon' {$api = "/api/v1/hardware/audit/due"}
'Assets overdue for auditing' {$api = "/api/v1/hardware/audit/overdue"}
'Assets checked out to user id'{$api = "/api/v1/users/$user_id/assets"}
'Assets with component id' {$api = "/api/v1/components/$component_id/assets"}
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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})
$callargs = $SearchParameter
Write-Verbose "Callargs: $($callargs | convertto-json)"
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitAsset @callargs
$res
if ( $res.count -lt $limit) {
break
}
$offstart = $offstart + $limit
}
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
end {
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitAssetMaintenances Get-SnipeitAssetMaintenances -url "https://assets.example.com" -token "token..."
.EXAMPLE
Get-SnipeitAssetMaintenances -search "myMachine"
.EXAMPLE .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() { function Get-SnipeitAssetMaintenance() {
Param( Param(
@ -54,61 +55,42 @@ function Get-SnipeitAssetMaintenance() {
[int]$offset, [int]$offset,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Parameters = @{ $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
Api = "/api/v1/maintenances"
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/maintenances"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'Get'
} GetParameters = $SearchParameter
Token = $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) {
if ($all) { $offstart = $(if($offset){$offset} Else {0})
$offstart = $(if ($offset) {$offset} Else {0}) $callargs = $SearchParameter
$callargs = $SearchParameter $callargs.Remove('all')
$callargs.Remove('all')
while ($true) { while ($true) {
$callargs['offset'] = $offstart $callargs['offset'] = $offstart
$callargs['limit'] = $limit $callargs['limit'] = $limit
$res=Get-SnipeitAssetMaintenance @callargs $res=Get-SnipeitAssetMaintenance @callargs
$res $res
if ($res.count -lt $limit) { if ($res.count -lt $limit) {
break break
}
$offstart = $offstart + $limit
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,9 +8,6 @@ A text string to search the Categories data
.PARAMETER id .PARAMETER id
A id of specific Category A id of specific Category
.PARAMETER name
Optionally restrict Category results to this Category name.
.PARAMETER limit .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitCategory -id 1 Get-SnipeitCategory -id 1
@ -34,8 +31,8 @@ Get-SnipeitCategory -search "Laptop"
#> #>
function Get-SnipeitCategory() { function Get-SnipeitCategory()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -43,9 +40,6 @@ function Get-SnipeitCategory() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -59,70 +53,50 @@ function Get-SnipeitCategory() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
begin { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $apiurl = "$url/api/v1/categories"
$api = "/api/v1/categories" if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/categories/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { if ($id) {
$callargs['offset'] = $offstart $apiurl= "$url/api/v1/categories/$id"
$callargs['limit'] = $limit }
$res=Get-SnipeitCategory @callargs
$res $Parameters = @{
if ($res.count -lt $limit) { Uri = $apiurl
break Method = 'Get'
} Token = $apiKey
$offstart = $offstart + $limit GetParameters = $SearchParameter
}
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitCategory @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,9 +8,6 @@ A text string to search the Companies data
.PARAMETER id .PARAMETER id
A id of specific Company A id of specific Company
.PARAMETER name
Optionally restrict company results to this company name.
.PARAMETER limit .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 .PARAMETER all
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitCompany Get-SnipeitCompany
@ -35,8 +32,8 @@ Gets specific company
#> #>
function Get-SnipeitCompany() { function Get-SnipeitCompany()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -44,9 +41,6 @@ function Get-SnipeitCompany() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -60,70 +54,51 @@ function Get-SnipeitCompany() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory=$false)] [parameter(mandatory=$true)]
[string]$url, [string]$url,
[parameter(mandatory=$false)] [parameter(mandatory=$true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/companies" $apiurl = "$url/api/v1/companies"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/companies/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { if ($id) {
$callargs['offset'] = $offstart $apiurl= "$url/api/v1/companies/$id"
$callargs['limit'] = $limit }
$res=Get-SnipeitCompany @callargs
$res $Parameters = @{
if ($res.count -lt $limit) { Uri = $apiurl
break Method = 'Get'
} Token = $apiKey
$offstart = $offstart + $limit GetParameters = $SearchParameter
}
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitCompany @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,18 +8,6 @@ A text string to search the Components data
.PARAMETER id .PARAMETER id
A id of specific Component 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 .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitComponent Get-SnipeitComponent
@ -48,8 +36,8 @@ Get-SnipeitComponent -id
Returns specific component Returns specific component
#> #>
function Get-SnipeitComponent() { function Get-SnipeitComponent() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -57,9 +45,6 @@ function Get-SnipeitComponent() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[int]$category_id, [int]$category_id,
@ -86,71 +71,51 @@ function Get-SnipeitComponent() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/components" $apiurl = "$url/api/v1/components"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/components/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($id) {
if ($all) { $apiurl= "$url/api/v1/components/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitComponent @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitComponent @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -1,178 +0,0 @@
<#
.SYNOPSIS
Gets a list of Snipe-it consumables
.PARAMETER search
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
.PARAMETER category_id
Id number of category
.PARAMETER manufacturer_id
Id number of manufacturer
.PARAMETER sort
Sort results by column
.PARAMETER order
Specify the order (asc or desc) you wish to order by on your sort column
.PARAMETER expand
Whether to include detailed information on categories, etc (true) or just the text name (false)
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
.PARAMETER offset
Offset to use
.PARAMETER all
A return all results
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
Get-SnipeitConsumable -all
Returns all consumables
.EXAMPLE
Get-SnipeitConsumable -search paper
Returns search results containeing string display
.EXAMPLE
Get-Snipeitconsumable -id
Returns specific consumable
#>
function Get-SnipeitConsumable() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param(
[parameter(ParameterSetName='Search')]
[string]$search,
[parameter(ParameterSetName='Get with ID')]
[int[]]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')]
[int]$category_id,
[parameter(ParameterSetName='Search')]
[int]$company_id,
[parameter(ParameterSetName='Search')]
[int]$manufacturer_id,
[parameter(ParameterSetName='Search')]
[int]$location_id,
[parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")]
[string]$order = "desc",
[parameter(ParameterSetName='Search')]
[ValidateSet('id', 'name', 'min_amt', 'order_number', 'serial', 'purchase_date', 'purchase_cost', 'company', 'category', 'qty', 'location', 'image', 'created_at')]
[string]$sort = "created_at",
[Parameter(ParameterSetName='Search')]
[switch]$expand,
[parameter(ParameterSetName='Search')]
[int]$limit = 50,
[parameter(ParameterSetName='Search')]
[int]$offset,
[parameter(ParameterSetName='Search')]
[switch]$all = $false,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[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"
Method = 'Get'
GetParameters = $SearchParameter
}
if ($all) {
$offstart = $(if ($offset) {$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-Snipeitconsumable @callargs
$res
if ($res.count -ne $limit) {
break
}
$offstart = $offstart + $limit
}
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
}
}
'Get with ID' {
foreach($consumable_id in $id) {
$Parameters = @{
Api = "$url/api/v1/consumables/$consumable_id"
Method = 'Get'
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 A id of specific field
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitCustomField Get-SnipeitCustomField -url "https://assets.example.com" -token "token..."
Get all custom fields
.EXAMPLE
Get-SnipeitCustomField -id 1
Get custom field with ID 1
#> #>
function Get-SnipeitCustomField() { function Get-SnipeitCustomField()
{
Param( Param(
[int]$id, [int]$id,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) { if ($id) {
$api= "/api/v1/fields/$id" $apiurl= "$url/api/v1/fields/$id"
} else { } else {
$api = "/api/v1/fields" $apiurl = "$url/api/v1/fields"
}
$Parameters = @{
Api = $api
Method = 'Get'
}
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 { $Parameters = @{
$result = Invoke-SnipeitMethod @Parameters Uri = $apiurl
$result Method = 'Get'
Token = $apiKey
} }
end {
# reset legacy sessions $result = Invoke-SnipeitMethod @Parameters
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 .PARAMETER id
A id of specific Department 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 .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitDepartment Get-SnipeitDepartment -url "https://assets.example.com" -token "token..."
.EXAMPLE .EXAMPLE
Get-SnipeitDepartment -search Department1 Get-SnipeitDepartment -search Department1
@ -46,8 +34,8 @@ Get-SnipeitDepartment -id 1
#> #>
function Get-SnipeitDepartment() { function Get-SnipeitDepartment()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -55,18 +43,6 @@ function Get-SnipeitDepartment() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$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')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -84,71 +60,52 @@ function Get-SnipeitDepartment() {
[ValidateSet('id', 'name', 'image', 'users_count', 'created_at')] [ValidateSet('id', 'name', 'image', 'users_count', 'created_at')]
[string]$sort = "created_at", [string]$sort = "created_at",
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/departments" $apiurl = "$url/api/v1/departments"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/departments/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { if ($id) {
$callargs['offset'] = $offstart $apiurl= "$url/api/v1/departments/$id"
$callargs['limit'] = $limit }
$res=Get-SnipeitDepartment @callargs
$res $Parameters = @{
if ($res.count -lt $limit) { Uri = $apiurl
break Method = 'Get'
} Token = $apiKey
$offstart = $offstart + $limit GetParameters = $SearchParameter
}
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitDepartment @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -6,18 +6,16 @@ Returns a fieldset or list of Snipe-it Fieldsets
A id of specific fieldset A id of specific fieldset
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitFieldset Get-SnipeitFieldset -url "https://assets.example.com" -token "token..."
Get all fieldsets
.EXAMPLE .EXAMPLE
Get-SnipeitFieldset | Where-Object {$_.name -eq "Windows" } Get-SnipeitFieldset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Windows" }
Gets fieldset by name
#> #>
@ -25,45 +23,28 @@ function Get-SnipeitFieldset() {
Param( Param(
[int]$id, [int]$id,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($id) { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$api = "/api/v1/fieldsets/$id"
} else {
$api = "/api/v1/fieldsets"
}
$Parameters = @{ if ($id) {
Api = $api $apiurl = "$url/api/v1/fieldsets/$id"
Method = 'Get' } else {
} $apiurl = "$url/api/v1/fieldsets"
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 $Parameters = @{
} Uri = $apiurl
end { Method = 'Get'
# reset legacy sessions Token = $apiKey
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
} }
$result = Invoke-SnipeitMethod @Parameters
$result
} }

View file

@ -19,10 +19,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitLicense -search SomeLicense Get-SnipeitLicense -search SomeLicense
@ -33,7 +33,6 @@ Get-SnipeitLicense -id 1
#> #>
function Get-SnipeitLicense() { function Get-SnipeitLicense() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -41,12 +40,6 @@ function Get-SnipeitLicense() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Get licenses checked out to user ID')]
[int]$user_id,
[parameter(ParameterSetName='Get licenses checked out to asset ID')]
[int]$asset_id,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$name, [string]$name,
@ -93,73 +86,56 @@ function Get-SnipeitLicense() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[int]$offset, [int]$offset,
[parameter(ParameterSetName='Get licenses checked out to user ID')]
[parameter(ParameterSetName='Get licenses checked out to asset ID')]
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
switch($PsCmdlet.ParameterSetName) { $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
'Search' {$api = "/api/v1/licenses"}
'Get with ID' {$api= "/api/v1/licenses/$id"}
'Get licenses checked out to user ID' {$api= "/api/v1/users/$user_id/licenses"}
'Get licenses checked out to asset ID' {$api= "/api/v1/hardware/$asset_id/licenses"}
}
$Parameters = @{ $apiurl = "$url/api/v1/licenses"
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { if ($search -and $id ) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
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 ($id) {
if ($all) { $apiurl= "$url/api/v1/licenses/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitLicense @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitLicense @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -22,10 +22,10 @@ A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitLicenseSeat -id 1 Get-SnipeitLicenseSeat -id 1
@ -47,68 +47,49 @@ function Get-SnipeitLicenseSeat() {
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [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' Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$api = "/api/v1/licenses/$id/seats" $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$apiurl = "$url/api/v1/licenses/$id/seats"
if ($seat_id) { if ($seat_id) {
$api= "/api/v1/licenses/$id/seats/$seat_id" $apiurl= "$url/api/v1/licenses/$id/seats/$seat_id"
}
$Parameters = @{
Api = $api
Method = 'Get'
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 { $Parameters = @{
if ($all) { Uri = $apiurl
$offstart = $(if ($offset) {$offset} Else {0}) Method = 'Get'
$callargs = $SearchParameter Token = $apiKey
$callargs.Remove('all') GetParameters = $SearchParameter
}
while ($true) { if ($all) {
$callargs['offset'] = $offstart $offstart = $(if($offset){$offset} Else {0})
$callargs['limit'] = $limit $callargs = $SearchParameter
$res=Get-SnipeitLicenseSeat @callargs $callargs.Remove('all')
$res
if ($res.count -lt $limit) { while ($true) {
break $callargs['offset'] = $offstart
} $callargs['limit'] = $limit
$offstart = $offstart + $limit $res=Get-SnipeitLicenseSeat @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,24 +8,6 @@ A text string to search the Locations data
.PARAMETER id .PARAMETER id
A id of specific Location 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 .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitLocation -search Location1 Get-SnipeitLocation -search Location1
@ -49,8 +31,8 @@ Get-SnipeitLocation -id 3
#> #>
function Get-SnipeitLocation() { function Get-SnipeitLocation()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -58,24 +40,6 @@ function Get-SnipeitLocation() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$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')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -89,71 +53,52 @@ function Get-SnipeitLocation() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$api = "/api/v1/locations" $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($search -and $id ) { $apiurl = "$url/api/v1/locations"
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) { if ($search -and $id ) {
$api= "/api/v1/locations/$id" Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
$Parameters = @{
Api = $api
Method = 'Get'
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 ($id) {
if ($all) { $apiurl= "$url/api/v1/locations/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitLocation @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitLocation @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -1,42 +1,40 @@
<# <#
.SYNOPSIS .SYNOPSIS
# Gets a list of Snipe-it Manufacturers # Gets a list of Snipe-it Manufacturers
.PARAMETER search .PARAMETER search
A text string to search the Manufactures data A text string to search the Manufactures data
.PARAMETER id .PARAMETER id
A id of specific Manufactuter A id of specific Manufactuter
.PARAMETER name .PARAMETER limit
Optionally restrict Manufacturer results to this name field Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
.PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all
.PARAMETER offset .PARAMETER offset
Offset to use Offset to use
.PARAMETER all .PARAMETER all
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitManufacturer -search HP Get-SnipeitManufacturer -search HP
Search all manufacturers for string HP Search all manufacturers for string HP
.EXAMPLE .EXAMPLE
Get-SnipeitManufacturer -id 3 Get-SnipeitManufacturer -id 3
Returns manufacturer with id 3 Returns manufacturer with id 3
#> #>
function Get-SnipeitManufacturer() {
[CmdletBinding(DefaultParameterSetName = 'Search')] function Get-SnipeitManufacturer()
{
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -44,9 +42,6 @@ function Get-SnipeitManufacturer() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -60,70 +55,51 @@ function Get-SnipeitManufacturer() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$api = "/api/v1/manufacturers" $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($search -and $id ) { $apiurl = "$url/api/v1/manufacturers"
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) { if ($search -and $id ) {
$api= "/api/v1/manufacturers/$id" Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
$Parameters = @{
Api = $api
Method = 'Get'
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 ($id) {
if ($all) { $apiurl= "$url/api/v1/manufacturers/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitManufacturer @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitManufacturer @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -18,10 +18,10 @@ Offset to use
A return all results, works with -offset and other parameters A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitModel -search "DL380" Get-SnipeitModel -search "DL380"
@ -31,8 +31,8 @@ Get-SnipeitModel -id 1
#> #>
function Get-SnipeitModel() { function Get-SnipeitModel()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -53,71 +53,51 @@ function Get-SnipeitModel() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/models" $apiurl = "$url/api/v1/models"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/models/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($id) {
if ($all) { $apiurl= "$url/api/v1/models/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitModel @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -ne $limit ) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitModel @callargs
$res
if ($res.count -ne $limit ) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,9 +8,6 @@ A text string to search the Status Labels data
.PARAMETER id .PARAMETER id
A id of specific Status Label A id of specific Status Label
.PARAMETER name
Optionally restrict Status Label results to this name field
.PARAMETER limit .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy" Get-SnipeitStatus -search "Ready to Deploy"
@ -34,8 +31,8 @@ Get-SnipeitStatus -id 3
#> #>
function Get-SnipeitStatus() { function Get-SnipeitStatus()
[CmdletBinding(DefaultParameterSetName = 'Search')] {
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -43,9 +40,6 @@ function Get-SnipeitStatus() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[int]$id, [int]$id,
[parameter(ParameterSetName='Search')]
[string]$name,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -59,70 +53,51 @@ function Get-SnipeitStatus() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$api = "/api/v1/statuslabels" $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($search -and $id ) { $apiurl = "$url/api/v1/statuslabels"
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) { if ($search -and $id ) {
$api= "/api/v1/statuslabels/$id" Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
$Parameters = @{
Api = $api
Method = 'Get'
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 ($id) {
if ($all) { $apiurl= "$url/api/v1/statuslabels/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitStatus @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitStatus @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,33 +8,6 @@ A text string to search the Supliers data
.PARAMETER id .PARAMETER id
A id of specific Suplier 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 .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitSupplier -search MySupplier Get-SnipeitSupplier -search MySupplier
@ -57,8 +30,9 @@ Get-SnipeitSupplier -search MySupplier
Get-SnipeitSupplier -id 2 Get-SnipeitSupplier -id 2
#> #>
function Get-SnipeitSupplier() {
[CmdletBinding(DefaultParameterSetName = 'Search')] function Get-SnipeitSupplier()
{
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -70,33 +44,6 @@ function Get-SnipeitSupplier() {
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "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')] [parameter(ParameterSetName='Search')]
[int]$limit = 50, [int]$limit = 50,
@ -106,71 +53,52 @@ function Get-SnipeitSupplier() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$api = "/api/v1/suppliers" $apiurl = "$url/api/v1/suppliers"
if ($search -and $id ) { if ($search -and $id ) {
Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both " Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
}
if ($id) {
$api= "/api/v1/suppliers/$id"
}
$Parameters = @{
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($id) {
if ($all) { $apiurl= "$url/api/v1/suppliers/$id"
$offstart = $(if ($offset) {$offset} Else {0}) }
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { $Parameters = @{
$callargs['offset'] = $offstart Uri = $apiurl
$callargs['limit'] = $limit Method = 'Get'
$res=Get-SnipeitSupplier @callargs Token = $apiKey
$res GetParameters = $SearchParameter
if ($res.count -lt $limit) { }
break
} if ($all) {
$offstart = $offstart + $limit $offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitSupplier @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -8,56 +8,11 @@ A text string to search the User data
.PARAMETER id .PARAMETER id
A id of specific User A id of specific User
.PARAMETER accessory_id
Get users a specific accessory id has been checked out to
.PARAMETER username .PARAMETER username
Optionally restrict User results to this username field Search string for username field
.PARAMETER email .PARAMETER email
Optionally restrict User results to this email field Search string for 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
.PARAMETER limit .PARAMETER limit
Specify the number of results you wish to return. Defaults to 50. Defines batch size for -all 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 A return all results, works with -offset and other parameters
.PARAMETER url .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 .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 .EXAMPLE
Get-SnipeitUser -search SomeSurname Get-SnipeitUser -search SomeSurname
@ -85,14 +40,9 @@ Get-SnipeitUser -username someuser
.EXAMPLE .EXAMPLE
Get-SnipeitUser -email user@somedomain.com Get-SnipeitUser -email user@somedomain.com
.EXAMPLE
Get-SnipeitUser -accessory_id 3
Get users with accessory id 3 has been checked out to
#> #>
function Get-SnipeitUser() { function Get-SnipeitUser() {
[CmdletBinding(DefaultParameterSetName = 'Search')]
Param( Param(
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$search, [string]$search,
@ -100,9 +50,6 @@ function Get-SnipeitUser() {
[parameter(ParameterSetName='Get with ID')] [parameter(ParameterSetName='Get with ID')]
[string]$id, [string]$id,
[parameter(ParameterSetName='Get users a specific accessory id has been checked out to')]
[string]$accessory_id,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[int]$company_id, [int]$company_id,
@ -120,40 +67,7 @@ function Get-SnipeitUser() {
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[string]$email, [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')] [parameter(ParameterSetName='Search')]
[ValidateSet("asc", "desc")] [ValidateSet("asc", "desc")]
[string]$order = "desc", [string]$order = "desc",
@ -165,68 +79,52 @@ function Get-SnipeitUser() {
[int]$offset, [int]$offset,
[parameter(ParameterSetName='Search')] [parameter(ParameterSetName='Search')]
[parameter(ParameterSetName='Get users a specific accessory id has been checked out to')]
[switch]$all = $false, [switch]$all = $false,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $SearchParameter = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
switch ($PsCmdlet.ParameterSetName) {
'Search' { $api = "/api/v1/users"}
'Get with id' {$api= "/api/v1/users/$id"}
'Get users a specific accessory id has been checked out to' {$api= "/api/v1/accessories/$accessory_id/checkedout"}
}
$Parameters = @{ $apiurl = "$url/api/v1/users"
Api = $api
Method = 'Get'
GetParameters = $SearchParameter
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { if ($search -and $id ) {
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -id parameter , not both "
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})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) { if ($id) {
$callargs['offset'] = $offstart $apiurl= "$url/api/v1/users/$id"
$callargs['limit'] = $limit }
$res=Get-SnipeitUser @callargs $Parameters = @{
$res Uri = $apiurl
if ($res.count -lt $limit) { Method = 'Get'
break GetParameters = $SearchParameter
} Token = $apiKey
$offstart = $offstart + $limit }
if ($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while ($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-SnipeitUser @callargs
$res
if ($res.count -lt $limit) {
break
} }
} else { $offstart = $offstart + $limit
$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
} }
} else {
$result = Invoke-SnipeitMethod @Parameters
$result
} }
} }

View file

@ -23,9 +23,6 @@ ID Number of the company the accessory is assigned to
.PARAMETER manufacturer_id .PARAMETER manufacturer_id
ID number of the manufacturer for this accessory. ID number of the manufacturer for this accessory.
.PARAMETER model_number
Model number for this accessory
.PARAMETER order_number .PARAMETER order_number
Order number for this accessory. Order number for this accessory.
@ -50,17 +47,14 @@ ID number of the supplier for this accessory
.PARAMETER location_id .PARAMETER location_id
ID number of the location the accessory is assigned to ID number of the location the accessory is assigned to
.PARAMETER min_amt .PARAMETER min_qty
Min quantity of the accessory before alert is triggered Min quantity of the accessory before alert is triggered
.PARAMETER image
Accessory image fileame and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1 New-SnipeitAccessory -name "Accessory" -qty 3 -category_id 1
@ -92,13 +86,11 @@ function New-SnipeitAccessory() {
[string]$order_number, [string]$order_number,
[string]$model_number,
[float]$purchase_cost, [float]$purchase_cost,
[datetime]$purchase_date, [datetime]$purchase_date,
[int]$min_amt, [int]$min_qty,
[ValidateRange(1, [int]::MaxValue)] [ValidateRange(1, [int]::MaxValue)]
[int]$supplier_id, [int]$supplier_id,
@ -106,53 +98,34 @@ function New-SnipeitAccessory() {
[ValidateRange(1, [int]::MaxValue)] [ValidateRange(1, [int]::MaxValue)]
[int]$location_id, [int]$location_id,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($values['purchase_date']) { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
}
$Parameters = @{ if ($values['purchase_date']) {
Api = "/api/v1/accessories" $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
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 { $Body = $Values | ConvertTo-Json;
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters $Parameters = @{
} Uri = "$url/api/v1/accessories"
$result Method = 'POST'
Body = $Body
Token = $apiKey
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
# reset legacy sessions $result = Invoke-SnipeitMethod @Parameters
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -39,27 +39,14 @@ Optional Purchase cost of the Asset
.PARAMETER purchase_date .PARAMETER purchase_date
Optional Purchase cost of the Asset Optional Purchase cost of the Asset
.PARAMETER supplier_id
Optional Supplier id of the Asset
.PARAMETER rtd_location_id .PARAMETER rtd_location_id
Optional Default location id for the asset Optional Default location id for the asset
.PARAMETER image
Asset image filename and path
.PARAMETER assigned_id
Id of target user , location or asset
.PARAMETER checkout_to_type
Checkout asset when creating to one of following types user, location or asset.
.PARAMETER url .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 .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 .PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit. Hastable of custom fields and extra fields that need passing through to Snipeit.
@ -74,21 +61,20 @@ New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -asset_tag "DEV123"
Specifying asset tag when creating asset Specifying asset tag when creating asset
.EXAMPLE .EXAMPLE
New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -customfields = @{ "_snipeit_os_5" = "Windows 10 Pro" } New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5" = "Windows 10 Pro" }
Using customfields when creating asset. Using customfields when creating asset.
#> #>
function New-SnipeitAsset() { function New-SnipeitAsset()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low", ConfirmImpact = "Low"
DefaultParameterSetName = 'Create asset'
)] )]
Param( Param(
[parameter(ParameterSetName='Create asset',mandatory = $true)] [parameter(mandatory = $true)]
[parameter(ParameterSetName='Checkout asset when creating',mandatory = $true)]
[int]$status_id, [int]$status_id,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
@ -128,81 +114,41 @@ function New-SnipeitAsset() {
[parameter(mandatory = $false)] [parameter(mandatory = $false)]
[int]$rtd_location_id, [int]$rtd_location_id,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[parameter(ParameterSetName='Checkout asset when creating',mandatory = $true)]
[int]$assigned_id,
[parameter(ParameterSetName='Checkout asset when creating',mandatory = $true)]
[ValidateSet("location","asset","user")]
[string] $checkout_to_type = "user",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey, [string]$apiKey,
[Alias('CustomValues')]
[hashtable] $customfields [hashtable] $customfields
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
}
if ($customfields) {
$Values += $customfields
}
#Checkout asset when creating it
if ($PsCmdlet.ParameterSetName -eq 'Checkout asset when creating') {
switch ($checkout_to_type) {
'location' { $Values += @{ "assigned_location" = $assigned_id } }
'user' { $Values += @{ "assigned_user" = $assigned_id } }
'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
}
#This are not needed for API
if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')}
if ($Values.ContainsKey('checkout_to_type')) {$Values.Remove('checkout_to_type')}
}
$Parameters = @{
Api = "/api/v1/hardware"
Method = 'Post'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($customfields)
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { {
$result = Invoke-SnipeitMethod @Parameters $Values += $customfields
}
$result
} }
end { $Body = $Values | ConvertTo-Json;
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Reset-SnipeitPSLegacyApi Uri = "$url/api/v1/hardware"
} Method = 'Post'
Body = $Body
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }

View file

@ -31,10 +31,10 @@ Optional completion date
Optional cost Optional cost
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01 New-SnipeitAssetMaintenence -asset_id 1 -supplier_id 1 -title "replace keyboard" -start_date 2021-01-01
@ -70,55 +70,37 @@ function New-SnipeitAssetMaintenance() {
[string]$notes, [string]$notes,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($Values['start_date']) { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd")
}
if ($Values['completion_date']) { if ($values['start_date']) {
$Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd") $values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
}
$Parameters = @{
Api = "/api/v1/maintenances"
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 ($values['completion_date']) {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $values['completion_date'] = $values['completion_date'].ToString("yyyy-MM-dd")
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { $Body = $Values | ConvertTo-Json;
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Reset-SnipeitPSLegacyApi Uri = "$url/api/v1/maintenances"
} Method = 'Post'
Body = $Body
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }

View file

@ -8,9 +8,6 @@ Long description
.PARAMETER Tag .PARAMETER Tag
The asset tag of the asset you wish to audit 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 .PARAMETER Location_id
ID of the location you want to associate with the audit 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( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -31,60 +29,38 @@ function New-SnipeitAudit() {
[int]$location_id, [int]$location_id,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[datetime]$next_audit_date,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{ Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
"location_id" = $location_id
}
if ($PSBoundParameters.ContainsKey('tag')) { $Values = @{
$Values += @{"asset_tag" = $tag} "location_id" = $location_id
}
if ($PSBoundParameters.ContainsKey('next_audit_date')) {
$Values += @{"next_audit_date" = ($next_audit_date).ToString("yyyy-MM-dd")}
}
$Parameters = @{
Api = "/api/v1/hardware/audit"
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 ($PSBoundParameters.ContainsKey('tag'))
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { {
$result = Invoke-SnipeitMethod @Parameters $Values += @{"asset_tag" = $tag}
}
$result
} }
end { $Body = $Values | ConvertTo-Json;
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Reset-SnipeitPSLegacyApi Uri = "$url/api/v1/hardware/audit"
} Method = 'Post'
Body = $Body
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }

View file

@ -8,8 +8,11 @@ Name of new category to be created
.PARAMETER type .PARAMETER type
Type of new category to be created (asset, accessory, consumable, component, license) Type of new category to be created (asset, accessory, consumable, component, license)
.PARAMETER eula_text .PARAMETER url
This allows you to customize your EULAs for specific types of assets URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.PARAMETER use_default_eula .PARAMETER use_default_eula
If switch is present, use the primary default EULA If switch is present, use the primary default EULA
@ -20,20 +23,12 @@ If switch is present, require users to confirm acceptance of assets in this cate
.PARAMETER checkin_email .PARAMETER checkin_email
If switch is present, send email to user on checkin/checkout If switch is present, send email to user on checkin/checkout
.PARAMETER image
Category image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE .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( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -47,63 +42,51 @@ function New-SnipeitCategory() {
[ValidateSet("asset", "accessory", "consumable", "component", "license")] [ValidateSet("asset", "accessory", "consumable", "component", "license")]
[string]$category_type, [string]$category_type,
[string]$eula_text, [parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey,
[switch]$use_default_eula, [switch]$use_default_eula,
[switch]$require_acceptance, [switch]$require_acceptance,
[switch]$checkin_email, [switch]$checkin_email
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($eula_text -and $use_default_eula) { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
throw 'Dont use -use_defalt_eula if -eula_text is set'
}
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = @{
"name" = $name
"category_type" = $category_type
} }
process { if ($use_default_eula) {
$Values += @{"use_default_eula" = $true}
$Parameters = @{
Api = "/api/v1/categories"
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
}
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { if ($require_acceptance) {
# reset legacy sessions $Values += @{"require_acceptance" = $true}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
} }
if ($checkin_email) {
$Values += @{"checkin_email" = $true}
}
$Body = $Values | ConvertTo-Json;
$Parameters = @{
Uri = "$url/api/v1/categories"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }

View file

@ -8,21 +8,19 @@ Creates new company on Snipe-It system
.PARAMETER name .PARAMETER name
Comapany name Comapany name
.PARAMETER image
Company image filename and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitCompany -name "Acme Company" New-SnipeitCompany -name "Acme Company"
#> #>
function New-SnipeitCompany() { function New-SnipeitCompany()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -32,50 +30,31 @@ function New-SnipeitCompany() {
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$name, [string]$name,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Parameters = @{ $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
Api = "/api/v1/companies"
Method = 'POST'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Body = $Values | ConvertTo-Json;
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) { $Parameters = @{
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/companies"
Set-SnipeitPSLegacyUrl -url $url Method = 'POST'
} Body = $Body
Token = $apiKey
} }
process { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { $result
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
} }

View file

@ -26,19 +26,17 @@ Date accessory was purchased
.PARAMETER purchase_cost .PARAMETER purchase_cost
Cost of item being purchased. Cost of item being purchased.
.PARAMETER image
Component image filename and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitComponent -name 'Display adapter' -catecory_id 3 -qty 10 An example
.NOTES
General notes
#> #>
function New-SnipeitComponent() { function New-SnipeitComponent() {
@ -67,54 +65,34 @@ function New-SnipeitComponent() {
[float]$purchase_cost, [float]$purchase_cost,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($Values['purchase_date']) { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
}
$Parameters = @{ if ($values['purchase_date']) {
Api = "/api/v1/components" $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
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 { $Body = $Values | ConvertTo-Json;
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result $Parameters = @{
Uri = "$url/api/v1/components"
Method = 'POST'
Body = $Body
Token = $apiKey
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
# reset legacy sessions $result = Invoke-SnipeitMethod @Parameters
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -1,157 +0,0 @@
<#
.SYNOPSIS
Add a new Consumable to Snipe-it asset system
.DESCRIPTION
Long description
.PARAMETER name
Required Name of the Consumable
.PARAMETER qty
Required Quantity of comsumable
.PARAMETER category_id
Required Category ID of the Consumable, this can be got using Get-SnipeitCategory
.PARAMETER min_amt
Optional minimum quantity of comsumable
.PARAMETER company_id
Optional Company id
.PARAMETER order_number
Optional Order number
.PARAMETER manufacturer_id
Manufaturer id number of the consumable
.PARAMETER location_id
Location id number of the consumable
.PARAMETER requestable
Is consumable requestable?
.PARAMETER purchase_date
Optional Purchase cost of the consumable
.PARAMETER purchase_cost
Optional Purchase cost of the consumable
.PARAMETER model_number
Model number of the consumable in months
.PARAMETER item_no
Item number for the consumable
.PARAMETER image
Consumable Image filename and path
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-Snipeitconsumable -name "Ink pack" -qty 20 -category_id 3 -min_amt 5
Create consumable with stock count 20 , alert when stock is 5 or lower
#>
function New-SnipeitConsumable() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$name,
[parameter(mandatory = $true)]
[int]$qty,
[parameter(mandatory = $true)]
[int]$category_id,
[parameter(mandatory = $false)]
[int]$min_amt,
[parameter(mandatory = $false)]
[int]$company_id,
[parameter(mandatory = $false)]
[string]$order_number,
[parameter(mandatory = $false)]
[int]$manufacturer_id,
[parameter(mandatory = $false)]
[int]$location_id,
[parameter(mandatory = $false)]
[bool]$requestable,
[parameter(mandatory = $false)]
[datetime]$purchase_date,
[parameter(mandatory = $false)]
[string]$purchase_cost,
[parameter(mandatory = $false)]
[string]$model_number,
[parameter(mandatory = $false)]
[string]$item_no,
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
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?")) {
$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

@ -5,41 +5,21 @@
.DESCRIPTION .DESCRIPTION
Add a new Custom Field to Snipe-it asset system Add a new Custom Field to Snipe-it asset system
.PARAMETER name .PARAMETER Name
The field's name, which is also the form label Name of the Custom Field
.PARAMETER element
Form field type that should be displayed.
.PARAMETER field_values
In the case of list boxes, etc, this should be a list of the options available
.PARAMETER show_in_email
Whether or not to show the custom field in email notifications
.PARAMETER format
How the field should be validated
.PARAMETER custom_format
In the case of format 'CUSTOM REGEX', this should be validation regex this field
.PARAMETER field_encrypted
Whether the field should be encrypted. (This can cause issues if you change it after the field was created.)
.PARAMETER help_text
Any additional text you wish to display under the new form field to make it clearer what the gauges should be.
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset" New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#> #>
function New-SnipeitCustomField() { function New-SnipeitCustomField()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -47,69 +27,43 @@ function New-SnipeitCustomField() {
Param( Param(
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$name, [string]$Name,
[string]$help_text, [string]$HelpText,
[string]$Element = "text",
[string]$Format = "ANY",
[bool]$field_encrypted,
[string]$CustomFormat,
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[ValidateSet('text','textarea','listbox','checkbox','radio')]
[string]$element ,
[parameter(mandatory = $true)]
[ValidateSet('ANY','CUSTOM REGEX','ALPHA','ALPHA-DASH','NUMERIC','ALPHA-NUMERIC','EMAIL','DATE','URL','IP','IPV4','IPV6','MAC','BOOLEAN')]
[string]$format,
[string]$field_values,
[bool]$field_encrypted=$false,
[bool]$show_in_email=$false,
[string]$custom_format,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($format -eq 'CUSTOM REGEX' -and (-not $custom_format)) {
throw "Please specify regex validation with -custom_format when using -format 'CUSTOM REGEX'"
}
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ #Convert Values to JSON format
Api = "/api/v1/fields" $Body = $Values | ConvertTo-Json;
Method = 'post'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Set-SnipeitPSLegacyApiKey -apiKey $apikey Uri = "$url/api/v1/fields"
} Method = 'post'
Body = $Body
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) { Token = $apiKey
Set-SnipeitPSLegacyUrl -url $url
}
} }
process{ If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { $result
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
} }

View file

@ -17,14 +17,11 @@
.PARAMETER manager_id .PARAMETER manager_id
ID number of manager ID number of manager
.PARAMETER image
Department Image filename and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
@ -49,52 +46,30 @@ function New-SnipeitDepartment() {
[string]$notes, [string]$notes,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Parameters = @{ $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
Api = "/api/v1/departments"
Method = 'POST'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Body = $Values | ConvertTo-Json;
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
Set-SnipeitPSLegacyApiKey -apiKey $apikey
}
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) { $Parameters = @{
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/departments"
Set-SnipeitPSLegacyUrl -url $url Method = 'POST'
} Body = $Body
Token = $apiKey
} }
process { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { $result
# 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. Termination date for license.
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitLicence -name "License" -seats 3 -company_id 1 New-SnipeitLicence -name "License" -seats 3 -company_id 1
@ -117,58 +117,42 @@ function New-SnipeitLicense() {
[datetime]$termination_date, [datetime]$termination_date,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($Values['expiration_date']) { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd")
}
if ($Values['purchase_date']) { if ($values['expiration_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
}
if ($Values['termination_date']) {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
}
$Parameters = @{
Api = "/api/v1/licenses"
Method = 'POST'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($values['purchase_date']) {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
$result = Invoke-SnipeitMethod @Parameters }
}
$result if ($values['termination_date']) {
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
} }
end {
# reset legacy sessions $Body = $Values | ConvertTo-Json;
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi $Parameters = @{
} Uri = "$url/api/v1/licenses"
Method = 'POST'
Body = $Body
Token = $apiKey
} }
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
} }

View file

@ -38,14 +38,11 @@
.PARAMETER manager_id .PARAMETER manager_id
The manager ID of the location The manager ID of the location
.PARAMETER image
Location Image filename and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14 New-SnipeitLocation -name "Room 1" -address "123 Asset Street" -parent_id 14
@ -81,52 +78,29 @@ function New-SnipeitLocation() {
[string]$ldap_ou, [string]$ldap_ou,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Body = $Values | ConvertTo-Json;
Api = "/api/v1/locations"
Method = 'post'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/locations"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'post'
} Body = $Body
Token = $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 = Invoke-SnipeitMethod @Parameters
}
$result
} }
end { $result
# reset legacy sessions
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
}
} }

View file

@ -8,23 +8,18 @@
.PARAMETER Name .PARAMETER Name
Name of the Manufacturer Name of the Manufacturer
.PARAMETER image
Manufacturer Image filename and path
.PARAMETER image_delete
Remove current image
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitManufacturer -name "HP" New-SnipeitManufacturer -name "HP"
#> #>
function New-SnipeitManufacturer() { function New-SnipeitManufacturer()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -34,52 +29,33 @@ function New-SnipeitManufacturer() {
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[string]$Name, [string]$Name,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{ $Values = @{
"name" = $Name "name" = $Name
}
$Parameters = @{
Api = "/api/v1/manufacturers"
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?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result #Convert Values to JSON format
$Body = $Values | ConvertTo-Json;
$Parameters = @{
Uri = "$url/api/v1/manufacturers"
Method = 'post'
Body = $Body
Token = $apiKey
} }
end {
# reset legacy sessions If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { {
Reset-SnipeitPSLegacyApi $result = Invoke-SnipeitMethod @Parameters
}
} }
$result
} }

View file

@ -20,20 +20,18 @@
.PARAMETER fieldset_id .PARAMETER fieldset_id
Fieldset ID that the asset uses (Custom fields) Fieldset ID that the asset uses (Custom fields)
.PARAMETER image
Asset model Image filename and path
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
#> #>
function New-SnipeitModel() { function New-SnipeitModel()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -53,62 +51,41 @@ function New-SnipeitModel() {
[int]$eol, [int]$eol,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[int]$fieldset_id, [int]$fieldset_id,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{ $Values = @{
name = $name name = $name
category_id = $category_id category_id = $category_id
manufacturer_id = $manufacturer_id manufacturer_id = $manufacturer_id
fieldset_id = $fieldset_id fieldset_id = $fieldset_id
}
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
$Parameters = @{
Api = "/api/v1/models"
Method = 'post'
Body = $Values
}
if ($PSBoundParameters.ContainsKey('apiKey') -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 ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
$result = Invoke-SnipeitMethod @Parameters
}
$result $Body = $Values | ConvertTo-Json;
$Parameters = @{
Uri = "$url/api/v1/models"
Method = 'post'
Body = $Body
Token = $apiKey
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
# reset legacy sessions {
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $result = Invoke-SnipeitMethod @Parameters
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -1,136 +0,0 @@
<#
.SYNOPSIS
Creates a supplier
.DESCRIPTION
Creates a new supplier on Snipe-It system
.PARAMETER name
Department Name
.PARAMETER address
Address line 1 of supplier
.PARAMETER address2
Address line 1 of supplier
.PARAMETER city
City
.PARAMETER state
State
.PARAMETER country
Country
.PARAMETER zip
Zip code
.PARAMETER phone
Phone number
.PARAMETER fax
Fax number
.PARAMETER email
Email address
.PARAMETER contact
Contact person
.PARAMETER notes
Email address
.PARAMETER image
Image file name and path for item
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
#>
function New-SnipeitSupplier() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$name,
[string]$address,
[string]$address2,
[string]$city,
[string]$state,
[string]$country,
[string]$zip,
[string]$phone,
[string]$fax,
[string]$email,
[string]$contact,
[string]$notes,
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[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"
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?")) {
$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

@ -17,9 +17,6 @@
.PARAMETER active .PARAMETER active
Can user log in to snipe-it? Can user log in to snipe-it?
.PARAMETER password
Password for user
.PARAMETER notes .PARAMETER notes
User Notes User Notes
@ -44,23 +41,17 @@
.PARAMETER manager_id .PARAMETER manager_id
ID number of manager ID number of manager
.PARAMETER groups
ID numbers of groups
.PARAMETER employee_num .PARAMETER employee_num
Employeenumber Employeenumber
.PARAMETER ldap_import .PARAMETER ldap_import
Mark user as import from ldap Mark user as import from ldap
.PARAMETER image
User Image file name and path
.PARAMETER url .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 .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 .EXAMPLE
New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -106,59 +97,38 @@ function New-SnipeitUser() {
[int]$manager_id, [int]$manager_id,
[int[]]$groups,
[string]$employee_num, [string]$employee_num,
[bool]$ldap_import = $false, [bool]$ldap_import = $false,
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($password ) { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Values['password_confirmation'] = $password
}
$Parameters = @{ if ($password ) {
Api = "/api/v1/users" $Values['password_confirmation'] = $password
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 { $Body = $Values | ConvertTo-Json;
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result $Parameters = @{
Uri = "$url/api/v1/users"
Method = 'post'
Body = $Body
Token = $apiKey
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
# reset legacy sessions $result = Invoke-SnipeitMethod @Parameters
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -1,72 +0,0 @@
<#
.SYNOPSIS
Removes Accessory from Snipe-it asset system
.DESCRIPTION
Removes Accessory or multiple Accessoriers from Snipe-it asset system
.PARAMETER ID
Unique ID For accessory to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitAccessory -ID 44 -Verbose
.EXAMPLE
Get-SnipeitAccessory -search needle | Remove-SnipeitAccessory
#>
function Remove-SnipeitAccessory () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($accessory_id in $id) {
$Parameters = @{
Api = "/api/v1/accessories/$accessory_id"
Method = 'Delete'
}
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?")) {
$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

@ -2,72 +2,55 @@
.SYNOPSIS .SYNOPSIS
Removes Asset from Snipe-it asset system Removes Asset from Snipe-it asset system
.DESCRIPTION .DESCRIPTION
Removes asset or multiple assets from Snipe-it asset system Removes Asset from Snipe-it asset system
.PARAMETER ID .PARAMETER ID
Unique ID For Asset to be removed Unique ID For Asset to be removed
.PARAMETER url .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 .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 .EXAMPLE
Remove-SnipeitAsset -ID 44 -Verbose Remove-SnipeitAsset -ID 44 -Verbose
.EXAMPLE
Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset
#> #>
function Remove-SnipeitAsset () { function Remove-SnipeitAsset ()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
)] )]
Param( Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [parameter(mandatory = $true)]
[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
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $id
} }
process { $Body = $Values | ConvertTo-Json
foreach($asset_id in $id) {
$Parameters = @{
Api = "/api/v1/hardware/$asset_id"
Method = 'Delete'
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/hardware/$ID"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'Delete'
} Body = $Body
Token = $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?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
# reset legacy sessions {
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $result = Invoke-SnipeitMethod @Parameters
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -1,72 +1,60 @@
<#
.SYNOPSIS
Remove asset maintenance from Snipe-it asset system
.DESCRIPTION
Removes asset maintenance event or events from Snipe-it asset system by ID
.PARAMETER ID
Unique ID of the asset maintenance to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitAssetMaintenance -ID 44
#>
function Remove-SnipeitAssetMaintenance { function Remove-SnipeitAssetMaintenance {
<#
.SYNOPSIS
Remove asset maintenance from Snipe-it asset system
.DESCRIPTION
Removes asset maintenance event from Snipe-it asset system by ID
.PARAMETER ID
Unique ID of the asset maintenance to be removed
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
Remove-SnipeitAssetMaintenance -ID 44 -url $url -apiKey $secret -Verbose
#>
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
)] )]
param ( param (
[Parameter(Mandatory = $true,ValueFromPipelineByPropertyName)] # Asset maintenance ID
[int[]] [Parameter(Mandatory = $true)]
[int]
$id, $id,
[parameter(mandatory = $false)] # Snipeit URL
[string]$url, [Parameter(Mandatory = $true)]
[string]
$url,
[parameter(mandatory = $false)] # Snipeit ApiKey
[string]$apiKey [Parameter(Mandatory = $true)]
[string]
$apiKey
) )
begin { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $id
} }
process { $Body = $Values | ConvertTo-Json
foreach($maintenance_id in $id) {
$Parameters = @{
Api = "/api/v1/maintenances/$maintenance_id"
Method = 'Delete'
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/maintenances/$ID"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'Delete'
} Body = $Body
Token = $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?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
# reset legacy sessions {
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $result = Invoke-SnipeitMethod @Parameters
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -1,71 +0,0 @@
<#
.SYNOPSIS
Removes category from Snipe-it asset system
.DESCRIPTION
Removes category or multiple categories from Snipe-it asset system
.PARAMETER ID
Unique ID For categoryto be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitCategory -ID 44
.EXAMPLE
Get-SnipeitCategory -search something | Remove-SnipeitCategory
#>
function Remove-SnipeitCategory () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($category_id in $id) {
$Parameters = @{
Api = "/api/v1/categories/$category_id"
Method = 'Delete'
}
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?")) {
$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,71 +0,0 @@
<#
.SYNOPSIS
Removes Company from Snipe-it asset system
.DESCRIPTION
Removes Company or multiple Companies from Snipe-it asset system
.PARAMETER ID
Unique ID For Company to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitCompany -ID 44
.EXAMPLE
Get-SnipeitCompany | | Where-object {$_.name -like '*some*'} | Remove-SnipeitCompany
#>
function Remove-SnipeitCompany () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($company_id in $id) {
$Parameters = @{
Api = "/api/v1/companies/$company_id"
Method = 'Delete'
}
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?")) {
$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,72 +0,0 @@
<#
.SYNOPSIS
Removes component from Snipe-it asset system
.DESCRIPTION
Removes component or multiple components from Snipe-it asset system
.PARAMETER IDs
Unique ID For component to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitComponent -ID 44
.EXAMPLE
Get-SnipeitComponent -search 123456789 | Remove-SnipeitComponent
#>
function Remove-SnipeitComponent () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($component_id in $id) {
$Parameters = @{
Api = "/api/v1/components/$component_id"
Method = 'Delete'
}
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?")) {
$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,73 +0,0 @@
<#
.SYNOPSIS
Removes consumable from Snipe-it asset system
.DESCRIPTION
Removes consumable or multiple consumables from Snipe-it asset system
.PARAMETER ID
Unique ID For consumable to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitConsumable -ID 44
.EXAMPLE
Get-SnipeitConsumable -search "paper" | Remove-SnipeitConsumable
#>
function Remove-SnipeitConsumable () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($consumable_id in $id) {
$Parameters = @{
Api = "/api/v1/consumables/$consumable_id"
Method = 'Delete'
}
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?")) {
$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,70 +0,0 @@
<#
.SYNOPSIS
Removes custom field from Snipe-it asset system
.DESCRIPTION
Removes custom field or multiple fields from Snipe-it asset system
.PARAMETER ID
Unique ID For field to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitCustomField -ID 44 -Verbose
.EXAMPLE
Get-SnipeitCustomField | Where-object {$_.name -like '*address*'} | Remove-SnipeitCustomField
#>
function Remove-SnipeitCustomField () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($field_id in $id) {
$Parameters = @{
Api = "/api/v1/fields/$field_id"
Method = 'Delete'
}
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?")) {
$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,71 +0,0 @@
<#
.SYNOPSIS
Removes department from Snipe-it asset system
.DESCRIPTION
Removes department or multiple departments from Snipe-it asset system
.PARAMETER ID
Unique ID For department to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitDepartment -ID 44
.EXAMPLE
Get-SnipeitDepartment | Where-object {$_.name -like '*head*'} | Remove-SnipeitDepartment
#>
function Remove-SnipeitDepartment () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($department_id in $id) {
$Parameters = @{
Api = "/api/v1/departments/$department_id"
Method = 'Delete'
}
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?")) {
$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,72 +0,0 @@
<#
.SYNOPSIS
Removes licence from Snipe-it asset system
.DESCRIPTION
Removes licence or multiple licenses from Snipe-it asset system
.PARAMETER ID
Unique ID For licence to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitLicence -ID 44
.EXAMPLE
Get-SnipeitLicence -product_key 123456789 | Remove-SnipeitLicense
#>
function Remove-SnipeitLicense () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($license_id in $id) {
$Parameters = @{
Api = "/api/v1/licenses/$license_id"
Method = 'Delete'
}
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?")) {
$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,72 +0,0 @@
<#
.SYNOPSIS
Removes Location from Snipe-it asset system
.DESCRIPTION
Removes localtion or multiple locations from Snipe-it asset system
.PARAMETER ID
Unique ID For location to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitLocation -ID 44
.EXAMPLE
Get-SnipeitLocation -city Arkham | Remove-SnipeitLocation
#>
function Remove-SnipeitLocation () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($location_id in $id) {
$Parameters = @{
Api = "/api/v1/locations/$asset_id"
Method = 'Delete'
}
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?")) {
$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,73 +0,0 @@
<#
.SYNOPSIS
Removes manufacturer from Snipe-it asset system
.DESCRIPTION
Removes manufacturer or multiple manufacturers from Snipe-it asset system
.PARAMETER ID
Unique ID For manufacturer to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitManufacturer -ID 44
.EXAMPLE
Get-SnipeitManufacturer | Where-object {$_.name -like '*something*'} | Remove-SnipeitManufacturer
#>
function Remove-SnipeitManufacturer () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($manufacturer_id in $id) {
$Parameters = @{
Api = "/api/v1/manufacturers/$manufacturer_id"
Method = 'Delete'
}
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?")) {
$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,72 +0,0 @@
<#
.SYNOPSIS
Removes Asset model from Snipe-it asset system
.DESCRIPTION
Removes asset model or multiple assets models from Snipe-it asset system
.PARAMETER ID
Unique ID For Model to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitModel -ID 44
.EXAMPLE
Get-SnipeitModel -search needle | Remove-SnipeitModel
#>
function Remove-SnipeitModel () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($model_id in $id) {
$Parameters = @{
Api = "/api/v1/models/$model_id"
Method = 'Delete'
}
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?")) {
$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,72 +0,0 @@
<#
.SYNOPSIS
Removes supplier from Snipe-it asset system
.DESCRIPTION
Removes supplier or multiple manufacturers from Snipe-it asset system
.PARAMETER ID
Unique ID For supplier to be removed
.PARAMETER url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
Remove-SnipeitSupplier -ID 44
.EXAMPLE
Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier
#>
function Remove-SnipeitSupplier () {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
}
process {
foreach($suppliers_id in $id) {
$Parameters = @{
Api = "/api/v1/suppliers/$supplier_id"
Method = 'Delete'
}
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?")) {
$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

@ -2,70 +2,56 @@
.SYNOPSIS .SYNOPSIS
Removes User from Snipe-it asset system Removes User from Snipe-it asset system
.DESCRIPTION .DESCRIPTION
Removes Uuser or users from Snipe-it asset system Long description
.PARAMETER ID .PARAMETER ID
Unique ID For User to be removed Unique ID For User to be removed
.PARAMETER url .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 .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 .EXAMPLE
Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#> #>
function Remove-SnipeitUser () { function Remove-SnipeitUser ()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
)] )]
Param( Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [parameter(mandatory = $true)]
[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
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{
"ID" = $id
} }
process { $Body = $Values | ConvertTo-Json
foreach($user_id in $id) {
$Parameters = @{
Api = "/api/v1/users/$user_id"
Method = 'Delete'
}
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $Parameters = @{
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Uri = "$url/api/v1/users/$ID"
Set-SnipeitPSLegacyApiKey -apiKey $apikey Method = 'Delete'
} Body = $Body
Token = $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?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
} }
end { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
# reset legacy sessions {
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { $result = Invoke-SnipeitMethod @Parameters
Reset-SnipeitPSLegacyApi
}
} }
$result
} }

View file

@ -10,10 +10,10 @@
Use Get-SnipeitAccessoryOwner to find out nooded value Use Get-SnipeitAccessoryOwner to find out nooded value
.PARAMETER url .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 .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 .EXAMPLE
To get the accessories_users table for specific accessory id number To get the accessories_users table for specific accessory id number
@ -25,7 +25,8 @@
Get-SnipeitAccessoryOwner -assigned_pivot_id xxx Get-SnipeitAccessoryOwner -assigned_pivot_id xxx
#> #>
function Reset-SnipeitAccessoryOwner() { function Reset-SnipeitAccessoryOwner()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -35,38 +36,24 @@ function Reset-SnipeitAccessoryOwner() {
[parameter(mandatory = $true)] [parameter(mandatory = $true)]
[int]$assigned_pivot_id, [int]$assigned_pivot_id,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
$Parameters = @{ $Parameters = @{
Api = "/api/v1/accessories/$assigned_pivot_id/checkin" Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
Method = 'Post' Method = 'Post'
Body = @{} Body = '{}'
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
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?")) {
$result = Invoke-SnipeitMethod @Parameters $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 return $result
} }

View file

@ -13,15 +13,17 @@
.PARAMETER location_id .PARAMETER location_id
Location id to change asset location to Location id to change asset location to
.PARAMETER note .PARAMETER notes
Notes about checkin Notes about checkin
.PARAMETER url .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 .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 .EXAMPLE
Remove-SnipeitUser -ID 44 Remove-SnipeitUser -ID 44 -url $url -apiKey $secret -Verbose
#> #>
function Reset-SnipeitAssetOwner() { function Reset-SnipeitAssetOwner() {
[CmdletBinding( [CmdletBinding(
@ -37,48 +39,36 @@ function Reset-SnipeitAssetOwner() {
[int]$location_id, [int]$location_id,
[string]$note, [string]$notes,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = @{ $Values = @{
"note" = $note "notes" = $notes
} }
if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) } if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) }
if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) } if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Api = "/api/v1/hardware/$id/checkin" Uri = "$url/api/v1/hardware/$id/checkin"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $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 return $result
} }

View file

@ -14,9 +14,6 @@ Notes about the accessory
.PARAMETER qty .PARAMETER qty
Quantity of the accessory you have Quantity of the accessory you have
.PARAMETER min_amt
Minimum amount of the accessory, before alert is triggered
.PARAMETER category_id .PARAMETER category_id
ID number of the category the accessory belongs to ID number of the category the accessory belongs to
@ -26,8 +23,14 @@ ID Number of the company the accessory is assigned to
.PARAMETER manufacturer_id .PARAMETER manufacturer_id
ID number of the manufacturer for this accessory. ID number of the manufacturer for this accessory.
.PARAMETER model_number .PARAMETER order_number
Model number for this accessory Order number for this accessory.
.PARAMETER purchase_cost
Cost of item being purchased.
.PARAMETER purchase_date
Date accessory was purchased
.PARAMETER order_number .PARAMETER order_number
Order number for this accessory. Order number for this accessory.
@ -44,20 +47,15 @@ ID number of the supplier for this accessory
.PARAMETER location_id .PARAMETER location_id
ID number of the location the accessory is assigned to ID number of the location the accessory is assigned to
.PARAMETER image .PARAMETER min_qty
Image file name and path for item Min quantity of the accessory before alert is triggered
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitAccessory -id 1 -qty 3 Set-SnipeitAccessory -id 1 -qty 3
@ -80,11 +78,12 @@ function Set-SnipeitAccessory() {
[ValidateRange(1, [int]::MaxValue)] [ValidateRange(1, [int]::MaxValue)]
[int]$category_id, [int]$category_id,
[Nullable[System.Int32]]$company_id, [ValidateRange(1, [int]::MaxValue)]
[int]$company_id,
[Nullable[System.Int32]]$manufacturer_id, [ValidateRange(1, [int]::MaxValue)]
[int]$manufacturer_id,
[string]$model_number,
[string]$order_number, [string]$order_number,
@ -92,24 +91,15 @@ function Set-SnipeitAccessory() {
[datetime]$purchase_date, [datetime]$purchase_date,
[Nullable[System.Int32]]$min_amt, [bool]$min_qty,
[Nullable[System.Int32]]$supplier_id, [ValidateRange(1, [int]::MaxValue)]
[int]$supplier_id,
[Nullable[System.Int32]]$location_id, [parameter(mandatory = $true)]
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
@ -118,43 +108,29 @@ function Set-SnipeitAccessory() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['purchase_date']) { if ($values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
Write-Verbose "Body: $Body"
} }
process { process {
foreach($accessory_id in $id) { foreach($accessory_id in $id){
$Parameters = @{ $Parameters = @{
Api = "/api/v1/accessories/$accessory_id" Uri = "$url/api/v1/accessories/$accessory_id"
Method = $RequestType Method = 'Patch'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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 Notes about checkout
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user" Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user"
#> #>
function Set-SnipeitAccessoryOwner() { function Set-SnipeitAccessoryOwner()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -37,46 +38,33 @@ function Set-SnipeitAccessoryOwner() {
[string] $note, [string] $note,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin{ begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
foreach($accessory_id in $id) { foreach($accessory_id in $id){
$Parameters = @{ $Parameters = @{
Api = "/api/v1/accessories/$accessory_id/checkout" Uri = "$url/api/v1/accessories/$accessory_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
return $result 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 .PARAMETER id
ID of the Asset or array of IDs ID of the Asset or array of IDs
.PARAMETER asset_tag
New tag for asset.
.PARAMETER Name .PARAMETER Name
Asset name Asset name
@ -44,9 +41,6 @@
.PARAMETER purchase_date .PARAMETER purchase_date
Date of asset purchase Date of asset purchase
.PARAMETER supplier_id
Supplier id of the Asset
.PARAMETER requestable .PARAMETER requestable
Whether or not the asset can be requested by users with the permission to request assets Whether or not the asset can be requested by users with the permission to request assets
@ -59,20 +53,14 @@
.PARAMETER notes .PARAMETER notes
Notes about asset Notes about asset
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType .PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. Http request type to send Snipe IT system. Defaults to Put youc use Patch if needed
.PARAMETER url .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 .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 .PARAMETER customfields
Hastable of custom fields and extra fields that need passing through to Snipeit Hastable of custom fields and extra fields that need passing through to Snipeit
@ -81,13 +69,14 @@
Set-SnipeitAsset -id 1 -status_id 1 -model_id 1 -name "Machine1" Set-SnipeitAsset -id 1 -status_id 1 -model_id 1 -name "Machine1"
.EXAMPLE .EXAMPLE
Set-SnipeitAsset -id 1 -name "Machine1" -customfields = @{ "_snipeit_os_5" = "Windows 10 Pro" ; "_snipeit_os_version" = "1909" } Set-SnipeitAsset -id 1 -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
.EXAMPLE .EXAMPLE
Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated' Get-SnipeitAsset -serial 12345678 | Set-SnipeitAsset -notes 'Just updated'
#> #>
function Set-SnipeitAsset() { function Set-SnipeitAsset()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -97,60 +86,47 @@ function Set-SnipeitAsset() {
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id, [int[]]$id,
[parameter(Mandatory=$false)]
[string]
$asset_tag,
[string]$name, [string]$name,
[ValidateRange(1, [int]::MaxValue)]
[int]$status_id, [int]$status_id,
[ValidateRange(1, [int]::MaxValue)]
[int]$model_id, [int]$model_id,
[DateTime]$last_checkout, [DateTime]$last_checkout,
[Nullable[System.Int32]]$assigned_to, [int]$assigned_to,
[Nullable[System.Int32]]$company_id, [int]$company_id,
[string]$serial, [string]$serial,
[string]$order_number, [string]$order_number,
[Nullable[System.Int32]]$warranty_months, [int]$warranty_months,
[double]$purchase_cost, [double]$purchase_cost,
[datetime]$purchase_date, [datetime]$purchase_date,
[parameter(mandatory = $false)]
[int]$supplier_id,
[bool]$requestable, [bool]$requestable,
[bool]$archived, [bool]$archived,
[Nullable[System.Int32]]$rtd_location_id, [int]$rtd_location_id,
[string]$notes, [string]$notes,
[ValidateSet("Put","Patch")] [ValidateSet("Put","Patch")]
[string]$RequestType = "Patch", [string]$RequestType = "Patch",
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey, [string]$apiKey,
[Alias('CustomValues')]
[hashtable] $customfields [hashtable] $customfields
) )
begin{ begin{
@ -158,46 +134,33 @@ function Set-SnipeitAsset() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['purchase_date']) { if ($values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($customfields) { if ($customfields)
{
$Values += $customfields $Values += $customfields
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
foreach($asset_id in $id) { foreach($asset_id in $id){
$Parameters = @{ $Parameters = @{
Api = "/api/v1/hardware/$asset_id" Uri = "$url/api/v1/hardware/$asset_id"
Method = $RequestType Method = $RequestType
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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,9 +10,6 @@
.PARAMETER assigned_id .PARAMETER assigned_id
Id of target user , location or asset Id of target user , location or asset
.PARAMETER checkout_to_type
Checkout asset to one of following types user, location, asset
.PARAMETER note .PARAMETER note
Notes about checkout Notes about checkout
@ -28,15 +25,16 @@
Optional date to override the checkout time of now Optional date to override the checkout time of now
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing check out to user" Set-SnipeitAssetOwner -id 1 -assigned_id 1 -checkout_to_type user -note "testing check out to user"
#> #>
function Set-SnipeitAssetOwner() { function Set-SnipeitAssetOwner()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -60,10 +58,10 @@ function Set-SnipeitAssetOwner() {
[datetime]$checkout_at, [datetime]$checkout_at,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
@ -73,54 +71,42 @@ function Set-SnipeitAssetOwner() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['expected_checkin']) { if ($Values['expected_checkin']) {
$Values['expected_checkin'] = $Values['expected_checkin'].ToString("yyyy-MM-dd") $Values['expected_checkin'] = $values['expected_checkin'].ToString("yyyy-MM-dd")
} }
if ($Values['checkout_at']) { if ($Values['checkout_at']) {
$Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd") $Values['checkout_at'] = $values['checkout_at'].ToString("yyyy-MM-dd")
} }
switch ($checkout_to_type) { switch ($checkout_to_type)
{
'location' { $Values += @{ "assigned_location" = $assigned_id } } 'location' { $Values += @{ "assigned_location" = $assigned_id } }
'user' { $Values += @{ "assigned_user" = $assigned_id } } 'user' { $Values += @{ "assigned_user" = $assigned_id } }
'asset' { $Values += @{ "assigned_asset" = $assigned_id } } 'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
} }
#This can be removed now #This can be removed now
if ($Values.ContainsKey('assigned_id')) {$Values.Remove('assigned_id')} if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')}
$Body = $Values | ConvertTo-Json;
} }
process{ process{
foreach($asset_id in $id) { foreach($asset_id in $id){
$Parameters = @{ $Parameters = @{
Api = "/api/v1/hardware/$asset_id/checkout" Uri = "$url/api/v1/hardware/$asset_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
return $result 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

@ -1,119 +0,0 @@
<#
.SYNOPSIS
Create a new Snipe-IT Category
.PARAMETER name
Name of new category to be created
.PARAMETER type
Type of new category to be created (asset, accessory, consumable, component, license)
.PARAMETER use_default_eula
If switch is present, use the primary default EULA
.PARAMETER eula_text
This allows you to customize your EULAs for specific types of assets
.PARAMETER require_acceptance
If switch is present, require users to confirm acceptance of assets in this category
.PARAMETER checkin_email
Should the user be emailed the EULA and/or an acceptance confirmation email when this item is checked in?
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE
Set-SnipeitCategory -id 4 -name "Laptops"
#>
function Set-SnipeitCategory() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[int[]]$id,
[string]$name,
[ValidateSet("asset", "accessory", "consumable", "component", "license")]
[string]$category_type,
[string]$eula_text,
[bool]$use_default_eula,
[bool]$require_acceptance,
[bool]$checkin_email,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process {
foreach($category_id in $id) {
$Parameters = @{
Api = "/api/v1/categories/$category_id"
Method = $RequestType
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
}
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,98 +0,0 @@
<#
.SYNOPSIS
Updates company name
.DESCRIPTION
Updates companyt name on Snipe-It system
.PARAMETER id
ID number of company
.PARAMETER name
Company name
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE
An example
.NOTES
General notes
#>
function Set-SnipeitCompany() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $true)]
[string]$name,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process{
foreach($company_id in $id) {
$Parameters = @{
Api = "/api/v1/companies/$company_id"
Method = $RequestType
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
}
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,139 +0,0 @@
<#
.SYNOPSIS
Updates component
.DESCRIPTION
Updates component on Snipe-It system
.PARAMETER id
ID number of name
.PARAMETER name
Component name
.PARAMETER category_id
ID number of category
.PARAMETER qty
Quantity of the components you have
.PARAMETER min_amt
Minimum Quantity of the components before alert is triggered
.PARAMETER location_id
ID number of the location the accessory is assigned to
.PARAMETER order_number
Order number for the accessory
.PARAMETER purchase_date
Date accessory was purchased
.PARAMETER purchase_cost
Cost of item being purchased.
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit.
.EXAMPLE
Set-SnipeitComponent -id 42 -qty 12
Sets count of component with ID 42 to 12
#>
function Set-SnipeitComponent() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $true)]
[int]$qty,
[Nullable[System.Int32]]$min_amt,
[string]$name,
[Nullable[System.Int32]]$company_id,
[Nullable[System.Int32]]$location_id,
[string]$order_number,
[datetime]$purchase_date,
[float]$purchase_cost,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
}
}
process {
foreach($component_id in $id) {
$Parameters = @{
Api = "/api/v1/components/$component_id"
Method = $RequestType
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
}
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

@ -0,0 +1,101 @@
<#
.SYNOPSIS
Updates component
.DESCRIPTION
Updates component on Snipe-It system
.PARAMETER id
ID number of name
.PARAMETER name
Component name
.PARAMETER category_id
ID number of category
.PARAMETER qty
Quantity of the components you have
.PARAMETER location_id
ID number of the location the accessory is assigned to
.PARAMETER order_number
Order number for the accessory
.PARAMETER purchase_date
Date accessory was purchased
.PARAMETER purchase_cost
Cost of item being purchased.
.PARAMETER url
URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE
An example
.NOTES
General notes
#>
function Set-SnipeitComponent()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true)]
[int]$id,
[parameter(mandatory = $true)]
[int]$qty,
[string]$name,
[int]$company_id,
[int]$location_id,
[string]$order_number,
[datetime]$purchase_date,
[float]$purchase_cost,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
}
$Body = $values | ConvertTo-Json;
$Parameters = @{
Uri = "$url/api/v1/components/$id"
Method = 'Patch'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}

View file

@ -1,179 +0,0 @@
<#
.SYNOPSIS
Add a new Consumable to Snipe-it asset system
.DESCRIPTION
Long description
.PARAMETER id
Optional id number of the Consumable
.PARAMETER name
Optional Name of the Consumable
.PARAMETER qty
Optional Quantity of comsumable
.PARAMETER category_id
Required Category ID of the Consumable, this can be got using Get-SnipeitCategory
.PARAMETER min_amt
Optional minimum quantity of comsumable
.PARAMETER company_id
Optional Company id
.PARAMETER order_number
Optional Order number
.PARAMETER manufacturer_id
Manufaturer id number of the consumable
.PARAMETER location_id
Location id number of the consumable
.PARAMETER requestable
Is consumable requestable?
.PARAMETER purchase_date
Optional Purchase cost of the consumable
.PARAMETER purchase_cost
Optional Purchase cost of the consumable
.PARAMETER model_number
Model number of the consumable in months
.PARAMETER item_no
Item number for the consumable
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-Snipeitconsumable -name "Ink pack" -qty 20 -category_id 3 -min_amt 5
Create consumable with stock count 20 , alert when stock is 5 or lower
#>
function Set-SnipeitConsumable() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[int[]]$id,
[parameter(mandatory = $false)]
[string]$name,
[parameter(mandatory = $false)]
[ValidateRange(1, [int]::MaxValue)]
[int]$qty,
[parameter(mandatory = $false)]
[ValidateRange(1, [int]::MaxValue)]
[int]$category_id,
[parameter(mandatory = $false)]
[Nullable[System.Int32]]$min_amt,
[parameter(mandatory = $false)]
[Nullable[System.Int32]]$company_id,
[parameter(mandatory = $false)]
[string]$order_number,
[parameter(mandatory = $false)]
[Nullable[System.Int32]]$manufacturer_id,
[parameter(mandatory = $false)]
[Nullable[System.Int32]]$location_id,
[parameter(mandatory = $false)]
[bool]$requestable,
[parameter(mandatory = $false)]
[datetime]$purchase_date,
[parameter(mandatory = $false)]
[string]$purchase_cost,
[parameter(mandatory = $false)]
[string]$model_number,
[parameter(mandatory = $false)]
[string]$item_no,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
}
}
process {
foreach($consumable_id in $id ) {
$Parameters = @{
Api = "/api/v1/consumables/$consumable_id"
Method = $RequestType
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
}
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,124 +0,0 @@
<#
.SYNOPSIS
Add a new Custom Field to Snipe-it asset system
.DESCRIPTION
Add a new Custom Field to Snipe-it asset system
.PARAMETER name
The field's name, which is also the form label
.PARAMETER element
Form field type that should be displayed.
.PARAMETER field_values
In the case of list boxes, etc, this should be a list of the options available
.PARAMETER show_in_email
Whether or not to show the custom field in email notifications
.PARAMETER format
How the field should be validated
.PARAMETER custom_format
In the case of format 'CUSTOM REGEX', this should be validation regex this field
.PARAMETER field_encrypted
Whether the field should be encrypted. (This can cause issues if you change it after the field was created.)
.PARAMETER help_text
Any additional text you wish to display under the new form field to make it clearer what the gauges should be.
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
#>
function Set-SnipeitCustomField() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[string]$name,
[string]$help_text,
[parameter(Mandatory=$true)]
[ValidateSet('text','textarea','listbox','checkbox','radio')]
[string]$element ,
[ValidateSet('ANY','CUSTOM REGEX','ALPHA','ALPHA-DASH','NUMERIC','ALPHA-NUMERIC','EMAIL','DATE','URL','IP','IPV4','IPV6','MAC','BOOLEAN')]
[string]$format,
[string]$field_values,
[bool]$field_encrypted,
[bool]$show_in_email,
[string]$custom_format,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Put",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
if ($format -eq 'CUSTOM REGEX' -and (-not $custom_format)) {
throw "Please specify regex validation with -custom_format when using -format 'CUSTOM REGEX'"
}
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process{
foreach($field_id in $id) {
$Parameters = @{
Api = "/api/v1/fields/$field_id"
Method = $RequestType
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
}
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,115 +0,0 @@
<#
.SYNOPSIS
Updates a department
.DESCRIPTION
Updates the department on Snipe-It system
.PARAMETER id
Id number of Department
.PARAMETER name
Department Name
.PARAMETER company_id
ID number of company
.PARAMETER location_id
ID number of location
.PARAMETER manager_id
ID number of manager
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
Set-SnipeitDepartment -id 4 -manager_id 3
#>
function Set-SnipeitDepartment() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[string]$name,
[Nullable[System.Int32]]$company_id,
[Nullable[System.Int32]]$location_id,
[Nullable[System.Int32]]$manager_id,
[string]$notes,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process {
foreach ($department_id in $id) {
$Parameters = @{
Api = "/api/v1/departments/$department_id"
Method = $RequestType
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
}
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 .SYNOPSIS
Sets authetication information. Deprecated, use Connect-SnipeitPS instead. Sets authetication information
.DESCRIPTION .DESCRIPTION
Deprecated combatibilty function that Set apikey and url user to connect Snipe-It system. Set apikey and url user to connect Snipe-It system
Please use Connect-SnipeitPS instead.
.PARAMETER url .PARAMETER url
URL of Snipeit system. URL of Snipeit system, can be set using Set-SnipeitInfo command
.PARAMETER apiKey .PARAMETER apiKey
User's API Key for Snipeit. User's API Key for Snipeit, can be set using Set-SnipeitInfo command
.EXAMPLE .EXAMPLE
Set-SnipeitInfo -url $url -apiKey -Verbose Set-SnipeitInfo -url $url -apiKey -Verbose
@ -19,18 +17,50 @@ function Set-SnipeitInfo {
[CmdletBinding()] [CmdletBinding()]
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
param ( param (
[parameter(Mandatory=$true)]
[Uri]$url, [Uri]$url,
[parameter(Mandatory=$true)]
[String]$apiKey [String]$apiKey
) )
BEGIN { 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 { 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

@ -59,14 +59,11 @@
.PARAMETER termination_date .PARAMETER termination_date
Termination date for license. Termination date for license.
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitLicence -name "License" -seats 3 -company_id 1 Set-SnipeitLicence -name "License" -seats 3 -company_id 1
@ -92,11 +89,12 @@ function Set-SnipeitLicense() {
[ValidateRange(1, [int]::MaxValue)] [ValidateRange(1, [int]::MaxValue)]
[int]$category_id, [int]$category_id,
[ValidateRange(1, [int]::MaxValue)]
[Nullable[System.Int32]]$company_id, [int]$company_id,
[datetime]$expiration_date, [datetime]$expiration_date,
[ValidateLength(1, 120)]
[mailaddress]$license_email, [mailaddress]$license_email,
[ValidateLength(1, 100)] [ValidateLength(1, 100)]
@ -120,68 +118,50 @@ function Set-SnipeitLicense() {
[string]$serial, [string]$serial,
[Nullable[System.Int32]]$supplier_id, [ValidateRange(1, [int]::MaxValue)]
[int]$supplier_id,
[datetime]$termination_date, [datetime]$termination_date,
[ValidateSet("Put","Patch")] [parameter(mandatory = $true)]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin{ begin{
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['expiration_date']) { if ($values['expiration_date']) {
$Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd") $values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd")
} }
if ($Values['purchase_date']) { if ($values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($Values['termination_date']) { if ($values['termination_date']) {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") $values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
foreach($license_id in $id) { foreach($license_id in $id){
$Parameters = @{ $Parameters = @{
Api = "/api/v1/licenses/$license_id" Uri = "$url/api/v1/licenses/$license_id"
Method = $RequestType Method = 'PUT'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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

@ -16,29 +16,23 @@
.PARAMETER note .PARAMETER note
Notes about checkout Notes about checkout
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -assigned_id 3 -Verbose
Checkout licence to user id 3 Checkout licence to user id 3
.EXAMPLE .EXAMPLE
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id 3 Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id 3 -Verbose
Checkout licence to asset id 3 Checkout licence to asset id 3
.EXAMPLE
Set-SnipeitLicenceSeat -ID 1 -seat_id 1 -asset_id $null -assigned_id $null
Checkin licence seat id 1 of licence id 1
#> #>
function Set-SnipeitLicenseSeat() { function Set-SnipeitLicenseSeat()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Medium" ConfirmImpact = "Medium"
@ -52,58 +46,40 @@ function Set-SnipeitLicenseSeat() {
[int]$seat_id, [int]$seat_id,
[Alias('assigned_id')] [Alias('assigned_id')]
[int]$assigned_to,
[Nullable[System.Int32]]$assigned_to, [int]$asset_id,
[Nullable[System.Int32]]$asset_id,
[string]$note, [string]$note,
[ValidateSet("Put","Patch")] [parameter(mandatory = $true)]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin{ begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
foreach($license_id in $id) { foreach($license_id in $id) {
$Parameters = @{ $Parameters = @{
Api = "/api/v1/licenses/$license_id/seats/$seat_id" Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
Method = $RequestType Method = 'Patch'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
return $result 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

@ -44,20 +44,11 @@
.PARAMETER parent_id .PARAMETER parent_id
Parent location as id Parent location as id
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100 Set-SnipeitLocation -id 123 -name "Some storage" -parent_id 100
@ -91,24 +82,16 @@ function Set-SnipeitLocation() {
[string]$currency, [string]$currency,
[Nullable[System.Int32]]$manager_id, [int]$manager_id,
[string]$ldap_ou, [string]$ldap_ou,
[Nullable[System.Int32]]$parent_id, [int]$parent_id,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
@ -116,39 +99,25 @@ function Set-SnipeitLocation() {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
foreach ($location_id in $id) { foreach ($location_id in $id) {
$Parameters = @{ $Parameters = @{
Api = "/api/v1/locations/$location_id" Uri = "$url/api/v1/locations/$location_id"
Method = $RequestType Method = 'PUT'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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,93 +0,0 @@
<#
.SYNOPSIS
Add a new Manufacturer to Snipe-it asset system
.DESCRIPTION
Long description
.PARAMETER Name
Name of the Manufacturer
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-SnipeitManufacturer -name "HP"
#>
function Set-SnipeitManufacturer() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$Name,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin{
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process{
foreach ($manufacturer_id in $id) {
$Parameters = @{
Api = "/api/v1/manufacturers/$manufacturer_id"
Method = $RequestType
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
}
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

@ -23,20 +23,11 @@
.PARAMETER fieldset_id .PARAMETER fieldset_id
Fieldset ID that the asset uses (Custom fields) Fieldset ID that the asset uses (Custom fields)
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1 New-SnipeitModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
@ -61,23 +52,16 @@ function Set-SnipeitModel() {
[int]$manufacturer_id, [int]$manufacturer_id,
[Nullable[System.Int32]]$eol, [ValidateRange(1, 240)]
[int]$eol,
[Alias("fieldset_id")] [Alias("fieldset_id")]
[Nullable[System.Int32]]$custom_fieldset_id, [int]$custom_fieldset_id,
[ValidateScript({Test-Path $_})] [parameter(mandatory = $true)]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
@ -86,37 +70,22 @@ function Set-SnipeitModel() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
foreach ($model_id in $id) { foreach ($model_id in $id) {
$Parameters = @{ $Parameters = @{
Api = "/api/v1/models/$model_id" Uri = "$url/api/v1/models/$model_id"
Method = $RequestType Method = 'put'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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,103 +0,0 @@
<#
.SYNOPSIS
Sets Snipe-it Status Labels
.PARAMETER id
A id of specific Status Label
.PARAMETER color
Hex code showing what color the status label should be on the pie chart in the dashboard
.PARAMETER show_in_nav
1 or 0 - determine whether the status label should show in the left-side nav of the web GUI
.PARAMETER default_label
1 or 0 - determine whether it should be bubbled up to the top of the list of available statuses
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
Get-SnipeitStatus -search "Ready to Deploy"
.EXAMPLE
Set-SnipeitStatus -id 3 -name 'Waiting for arrival' -type pending
#>
function Set-SnipeitStatus() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[string]$name,
[parameter(Mandatory=$true)]
[ValidateSet('deployable','undeployable','pending','archived')]
[string]$type,
[string]$notes,
[string]$color,
[bool]$show_in_nav,
[bool]$default_label,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process {
foreach($status_id in $id) {
$Parameters = @{
Api = "/api/v1/statuslabels/$status_id"
Method = $RequestType
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
}
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,150 +0,0 @@
<#
.SYNOPSIS
Modify the supplier
.DESCRIPTION
Modifieds the supplier on Snipe-It system
.PARAMETER name
Suppiers Name
.PARAMETER address
Address line 1 of supplier
.PARAMETER address2
Address line 1 of supplier
.PARAMETER city
City
.PARAMETER state
State
.PARAMETER country
Country
.PARAMETER zip
Zip code
.PARAMETER phone
Phone number
.PARAMETER fax
Fax number
.PARAMETER email
Email address
.PARAMETER contact
Contact person
.PARAMETER notes
Email address
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
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.
.PARAMETER apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
.EXAMPLE
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
#>
function Set-SnipeitSupplier() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$name,
[string]$address,
[string]$address2,
[string]$city,
[string]$state,
[string]$country,
[string]$zip,
[string]$phone,
[string]$fax,
[string]$email,
[string]$contact,
[string]$notes,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url,
[parameter(mandatory = $false)]
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
}
process {
foreach ($supplier_id in $id) {
$Parameters = @{
Api = "/api/v1/suppliers/$supplier_id"
Method = $RequestType
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
}
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

@ -17,12 +17,9 @@
.PARAMETER username .PARAMETER username
Username for user Username for user
.PARAMETER activated .PARAMETER active
Can user log in to snipe-it? Can user log in to snipe-it?
.PARAMETER password
Password for user
.PARAMETER notes .PARAMETER notes
User Notes User Notes
@ -47,29 +44,17 @@
.PARAMETER manager_id .PARAMETER manager_id
ID number of manager ID number of manager
.PARAMETER groups
ID numbers of groups
.PARAMETER employee_num .PARAMETER employee_num
Employeenumber Employeenumber
.PARAMETER ldap_import .PARAMETER ldap_import
Mark user as import from ldap Mark user as import from ldap
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.PARAMETER url .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 .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 .EXAMPLE
Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1 Update-SnipeitUser -id 3 -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
@ -89,52 +74,41 @@ function Set-SnipeitUser() {
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)] [parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id, [int[]]$id,
[ValidateLength(1,256)]
[string]$first_name, [string]$first_name,
[string]$last_name, [string]$last_name,
[ValidateLength(1,256)] [string]$userName,
[string]$username,
[string]$jobtitle, [string]$jobtitle,
[string]$email, [string]$email,
[string]$phone, [string]$phone,
[string]$password, [int]$company_id,
[Nullable[System.Int32]]$company_id, [int]$location_id,
[Nullable[System.Int32]]$location_id, [int]$department_id,
[Nullable[System.Int32]]$department_id, [int]$manager_id,
[Nullable[System.Int32]]$manager_id,
[int[]]$groups,
[string]$employee_num, [string]$employee_num,
[bool]$activated, [bool]$activated,
[string]$notes, [string]$notes,
[bool]$ldap_import, [parameter(mandatory = $true)]
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[parameter(mandatory = $false)]
[string]$url, [string]$url,
[parameter(mandatory = $false)] [parameter(mandatory = $true)]
[string]$apiKey [string]$apiKey
) )
begin{ begin{
@ -142,42 +116,23 @@ function Set-SnipeitUser() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($password) { $Body = $Values | ConvertTo-Json;
$Values['password_confirmation'] = $password
}
} }
process{ process{
foreach($user_id in $id) { foreach($user_id in $id) {
$Parameters = @{ $Parameters = @{
Api = "/api/v1/users/$user_id" Uri = "$url/api/v1/users/$user_id"
Method = 'PATCH' Method = 'PATCH'
Body = $Values Body = $Body
Token = $apiKey
} }
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
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?")) {
$result = Invoke-SnipeitMethod @Parameters $result = Invoke-SnipeitMethod @Parameters
} }
$result $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,12 +10,14 @@ Input string
.EXAMPLE .EXAMPLE
Get-Content [your-script.ps1] | Update-SnipeitAlias | Out-File [new-script-name.ps1] Get-Content [your-script.ps1] | Update-SnipeitAlias | Out-File [new-script-name.ps1]
Replaces old command from file "your-script.ps1" and creates new script "new-script-name.ps1" Replaces old command from file "your-script.ps1" and creates new script "new-script-name.ps1"
After testing new file you can replace old file with new. After testing new file you can replace old file with new.
#> #>
function Update-SnipeitAlias() {
function Update-SnipeitAlias()
{
[CmdletBinding( [CmdletBinding(
SupportsShouldProcess = $true, SupportsShouldProcess = $true,
ConfirmImpact = "Low" ConfirmImpact = "Low"
@ -33,8 +35,8 @@ function Update-SnipeitAlias() {
} }
process { process {
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
ForEach ($st in $String) { ForEach ($st in $String){
$result = $st $result = $st
ForEach ($key in $SnipeitAliases.Keys ) { ForEach ($key in $SnipeitAliases.Keys ) {
#Write-Verbose "Replacing $key with $($SnipeitAliases[$key])" #Write-Verbose "Replacing $key with $($SnipeitAliases[$key])"

View file

@ -12,7 +12,7 @@
RootModule = 'SnipeitPS' RootModule = 'SnipeitPS'
# Version number of this module. # Version number of this module.
ModuleVersion = '1.10' ModuleVersion = '1.5'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()
@ -33,7 +33,7 @@ Copyright = '(c) 2017 Stephen Maunder. All rights reserved.'
Description = 'Powershell API for Snipeit Asset Management' Description = 'Powershell API for Snipeit Asset Management'
# Minimum version of the Windows PowerShell engine required by this module # Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1' PowerShellVersion = '3.0'
# Name of the Windows PowerShell host required by this module # Name of the Windows PowerShell host required by this module
# PowerShellHostName = '' # PowerShellHostName = ''
@ -70,80 +70,53 @@ 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. # 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 = @( FunctionsToExport = @(
'Connect-SnipeitPS',
'Get-SnipeitAccessory',
'Get-SnipeitAccessoryOwner',
'Get-SnipeitActivity',
'Get-SnipeitAsset', 'Get-SnipeitAsset',
'Get-SnipeitAssetMaintenance', 'Get-SnipeitAssetMaintenance',
'Get-SnipeitCategory', 'Get-SnipeitCategory',
'Get-SnipeitCompany', 'Get-SnipeitCompany',
'Get-SnipeitComponent', 'Get-SnipeitComponent',
'Get-SnipeitConsumable',
'Get-SnipeitCustomField', 'Get-SnipeitCustomField',
'Get-SnipeitDepartment', 'Get-SnipeitDepartment',
'Get-SnipeitFieldset', 'Get-SnipeitFieldset',
'Get-SnipeitLicense',
'Get-SnipeitLicenseSeat',
'Get-SnipeitLocation', 'Get-SnipeitLocation',
'Get-SnipeitManufacturer', 'Get-SnipeitManufacturer',
'Get-SnipeitModel', 'Get-SnipeitModel',
'Get-SnipeitStatus', 'Get-SnipeitStatus',
'Get-SnipeitSupplier', 'Get-SnipeitSupplier',
'Get-SnipeitUser', 'Get-SnipeitUser',
'New-SnipeitAccessory',
'New-SnipeitAsset', 'New-SnipeitAsset',
'New-SnipeitAssetMaintenance', 'New-SnipeitAssetMaintenance',
'New-SnipeItAudit',
'New-SnipeitCategory', 'New-SnipeitCategory',
'New-SnipeitCompany',
'New-SnipeitComponent', 'New-SnipeitComponent',
'New-SnipeitConsumable',
'New-SnipeitCustomField', 'New-SnipeitCustomField',
'New-SnipeitDepartment', 'New-SnipeitDepartment',
'New-SnipeitLicense', 'New-SnipeitLicense',
'Set-SnipeitLicense',
'Get-SnipeitLicense',
'Get-SnipeitLicenseSeat',
'Set-SnipeitLicenseSeat',
'New-SnipeitLocation', 'New-SnipeitLocation',
'New-SnipeitManufacturer', 'New-SnipeitManufacturer',
'New-SnipeitModel', 'New-SnipeitModel',
'New-SnipeitSupplier',
'New-SnipeitUser', 'New-SnipeitUser',
'Remove-SnipeitAccessory',
'Remove-SnipeitAsset',
'Remove-SnipeitAssetMaintenance',
'Remove-SnipeitCategory',
'Remove-SnipeitCompany',
'Remove-SnipeitComponent',
'Remove-SnipeitConsumable',
'Remove-SnipeitCustomField',
'Remove-SnipeitDepartment',
'Remove-SnipeitLicense',
'Remove-SnipeitLocation',
'Remove-SnipeitManufacturer',
'Remove-SnipeitModel',
'Remove-SnipeitSupplier',
'Remove-SnipeitUser',
'Reset-SnipeitAccessoryOwner',
'Reset-SnipeitAssetOwner',
'Set-SnipeitAccessory',
'Set-SnipeitAccessoryOwner',
'Set-SnipeitAsset', 'Set-SnipeitAsset',
'Set-SnipeitAssetOwner', 'Set-SnipeitAssetOwner',
'Set-SnipeitCategory'
'Set-SnipeitCompany'
'Set-SnipeitComponent', 'Set-SnipeitComponent',
'Set-SnipeitConsumable',
'Set-SnipeitCustomField',
'Set-SnipeitDepartment',
'Set-SnipeitInfo',
'Set-SnipeitLicense',
'Set-SnipeitLicenseSeat',
'Set-SnipeitLocation',
'Set-SnipeitManufacturer',
'Set-SnipeitModel', 'Set-SnipeitModel',
'Set-SnipeitStatus', 'Set-SnipeitInfo',
'Set-SnipeitSupplier',
'Set-SnipeitUser', 'Set-SnipeitUser',
'Update-SnipeitAlias' 'Set-SnipeitLocation',
'Add-SnipeitAccessory',
'Set-SnipeitAccessory',
'Get-SnipeitAccessory',
'Remove-SnipeitAsset',
'Remove-SnipeitUser',
'Update-SnipeitAlias',
'Set-SnipeitAccessoryOwner',
'Get-SnipeitAccessoryOwner',
'Reset-SnipeitAccessoryOwner',
'Get-SnipeitActivity'
) )
# Cmdlets 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 cmdlets to export. # Cmdlets 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 cmdlets to export.

View file

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

@ -7,17 +7,14 @@
# #
############################################################ ############################################################
# powershell core and 5.1 # This tells AppVeyor that we need WMF 5 and PowerShell 5.0
image: os: WMF 5
- Visual Studio 2017
- Visual Studio 2019
environment: environment:
PSGalleryAPIKey: PSGalleryAPIKey:
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
PShell: '5'
version: 1.10.{build} version: 1.5.{build}
# Don't rebuild when I tag a release on GitHub # Don't rebuild when I tag a release on GitHub
skip_tags: true skip_tags: true
@ -56,40 +53,15 @@ before_build:
build_script: build_script:
- ps: Invoke-Build -Task Build - ps: Invoke-Build -Task Build
# after_build:
# - cmd: mdspell %releasePath%\**/*.md --ignore-numbers --ignore-acronyms --report
test_script: test_script:
- ps: Invoke-Build -Task Test - ps: Invoke-Build -Task Test
before_deploy: before_deploy:
- ps: Invoke-Build -Task Deploy - ps: Invoke-Build -Task Deploy
#Build with powershell core
for:
-
matrix:
only:
- image: Visual Studio 2019
environment:
PShell: '7'
install:
- pwsh: |
Install-Module InvokeBuild -Scope CurrentUser -Force
Install-Module BuildHelpers -Scope CurrentUser -Force
Install-Module platyPS -Scope CurrentUser -Force
Install-Module Pester -Scope CurrentUser -Force
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
$env:releasePath = "$($pwd.Path)\Release"
before_build:
- pwsh: Invoke-Build -Task ShowDebug
build_script:
- pwsh: Invoke-Build -Task Build
test_script:
- pwsh: Invoke-Build -Task Test
before_deploy:
- pwsh: Invoke-Build -Task Deploy
deploy: deploy:
provider: GitHub provider: GitHub
release: v$(appveyor_build_version) release: v$(appveyor_build_version)

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

@ -12,21 +12,16 @@ Gets a list of Snipe-it Accessories
## SYNTAX ## SYNTAX
### Search (Default) ### Search
``` ```
Get-SnipeitAccessory [-search <String>] [-company_id <Int32>] [-category_id <Int32>] [-manufacturer_id <Int32>] 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] [-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 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>]
``` ```
## DESCRIPTION ## DESCRIPTION
@ -44,12 +39,6 @@ Get-SnipeitAccessory -search Keyboard
Get-SnipeitAccessory -id 1 Get-SnipeitAccessory -id 1
``` ```
### EXAMPLE 3
```
Get-SnipeitAccessory -user_id 1
Get accessories checked out to user ID 1
```
## PARAMETERS ## PARAMETERS
### -all ### -all
@ -57,7 +46,7 @@ A return all results, works with -offset and other parameters
```yaml ```yaml
Type: SwitchParameter Type: SwitchParameter
Parameter Sets: Search, Accessories checked out to user id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
@ -68,15 +57,14 @@ Accept wildcard characters: False
``` ```
### -apiKey ### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit, can be set using Set-SnipeitInfo command
Users API Key for Snipeit.
```yaml ```yaml
Type: String Type: String
Parameter Sets: (All) Parameter Sets: (All)
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
@ -236,36 +224,20 @@ Accept wildcard characters: False
``` ```
### -url ### -url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system, can be set using Set-SnipeitInfo command
URL of Snipeit system.
```yaml ```yaml
Type: String Type: String
Parameter Sets: (All) Parameter Sets: (All)
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -user_id
{{ Fill user_id Description }}
```yaml
Type: Int32
Parameter Sets: Accessories checked out to user id
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### 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). 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).

View file

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

View file

@ -12,51 +12,27 @@ Gets a list of Snipe-it Assets or specific asset
## SYNTAX ## SYNTAX
### Search (Default) ### Search
``` ```
Get-SnipeitAsset [-search <String>] [-order_number <String>] [-model_id <Int32>] [-category_id <Int32>] 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>] [-manufacturer_id <Int32>] [-company_id <Int32>] [-location_id <Int32>] [-depreciation_id <Int32>]
[-requestable <Boolean>] [-status <String>] [-status_id <Int32>] [-sort <String>] [-order <String>] [-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 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 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 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>]
```
### Assets overdue for auditing
```
Get-SnipeitAsset [-audit_overdue] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>] [-all]
[-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>]
```
### Assets with component id
```
Get-SnipeitAsset [-component_id <Int32>] [-sort <String>] [-order <String>] [-limit <Int32>] [-offset <Int32>]
[-all] [-url <String>] [-apiKey <String>] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@ -66,56 +42,22 @@ Get-SnipeitAsset [-component_id <Int32>] [-sort <String>] [-order <String>] [-li
### EXAMPLE 1 ### EXAMPLE 1
``` ```
Get-SnipeitAsset -all Get-SnipeitAsset -url "https://assets.example.com"-token "token..."
Returens all assets
``` ```
### EXAMPLE 2 ### EXAMPLE 2
``` ```
Get-SnipeitAsset -search "myMachine" Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
Search for specific asset
``` ```
### EXAMPLE 3 ### EXAMPLE 3
``` ```
Get-SnipeitAsset -id 3 Get-SnipeitAsset -search "myMachine"-url "https://assets.example.com"-token "token..."
Get asset with id number 3
``` ```
### EXAMPLE 4 ### EXAMPLE 4
``` ```
Get-SnipeitAsset -asset_tag snipe0003 Get-SnipeitAsset -asset_tag "myAssetTag"-url "https://assets.example.com"-token "token..."
Get asset with asset tag snipe00033
```
### EXAMPLE 5
```
Get-SnipeitAsset -serial 1234
Get asset with searial number 1234
```
### EXAMPLE 6
```
Get-SnipeitAsser -audit_due
Get Assets due auditing soon
```
### EXAMPLE 7
```
Get-SnipeitAsser -audit_overdue
Get Assets overdue for auditing
```
### EXAMPLE 8
```
Get-AnipeitAsset -user_id 4
Get Assets checked out to user id 4
```
### EXAMPLE 9
```
Get-SnipeitAsset -component_id 5
Get Assets with component id 5
``` ```
## PARAMETERS ## PARAMETERS
@ -125,7 +67,7 @@ A return all results, works with -offset and other parameters
```yaml ```yaml
Type: SwitchParameter Type: SwitchParameter
Parameter Sets: Search, Assets due auditing soon, Assets overdue for auditing, Assets checked out to user id, Assets with component id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
@ -136,15 +78,14 @@ Accept wildcard characters: False
``` ```
### -apiKey ### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit, can be set using Set-SnipeitInfo command
Users API Key for Snipeit.
```yaml ```yaml
Type: String Type: String
Parameter Sets: (All) Parameter Sets: (All)
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
@ -166,36 +107,6 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -audit_due
Retrieve a list of assets that are due for auditing soon.
```yaml
Type: SwitchParameter
Parameter Sets: Assets due auditing soon
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -audit_overdue
Retrieve a list of assets that are overdue for auditing.
```yaml
Type: SwitchParameter
Parameter Sets: Assets overdue for auditing
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -category_id ### -category_id
Optionally restrict asset results to this category ID Optionally restrict asset results to this category ID
@ -226,21 +137,6 @@ Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -component_id
{{ Fill component_id Description }}
```yaml
Type: Int32
Parameter Sets: Assets with component id
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -depreciation_id ### -depreciation_id
{{ Fill depreciation_id Description }} {{ Fill depreciation_id Description }}
@ -278,7 +174,7 @@ Defines batch size for -all
```yaml ```yaml
Type: Int32 Type: Int32
Parameter Sets: Search, Assets due auditing soon, Assets overdue for auditing, Assets checked out to user id, Assets with component id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
@ -338,7 +234,7 @@ Offset to use
```yaml ```yaml
Type: Int32 Type: Int32
Parameter Sets: Search, Assets due auditing soon, Assets overdue for auditing, Assets checked out to user id, Assets with component id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
@ -353,12 +249,12 @@ Specify the order (asc or desc) you wish to order by on your sort column
```yaml ```yaml
Type: String Type: String
Parameter Sets: Search, Assets due auditing soon, Assets overdue for auditing, Assets checked out to user id, Assets with component id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
Position: Named Position: Named
Default value: None Default value: Desc
Accept pipeline input: False Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
@ -428,12 +324,12 @@ Specify the column name you wish to sort by
```yaml ```yaml
Type: String Type: String
Parameter Sets: Search, Assets due auditing soon, Assets overdue for auditing, Assets checked out to user id, Assets with component id Parameter Sets: Search
Aliases: Aliases:
Required: False Required: False
Position: Named Position: Named
Default value: None Default value: Created_at
Accept pipeline input: False Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
@ -469,36 +365,20 @@ Accept wildcard characters: False
``` ```
### -url ### -url
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system, can be set using Set-SnipeitInfo command
URL of Snipeit system.
```yaml ```yaml
Type: String Type: String
Parameter Sets: (All) Parameter Sets: (All)
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False
``` ```
### -user_id
{{ Fill user_id Description }}
```yaml
Type: Int32
Parameter Sets: Assets checked out to user id
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters ### 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). 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).

View file

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

View file

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

View file

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

View file

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

View file

@ -1,275 +0,0 @@
---
external help file: SnipeitPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Get-SnipeitConsumable
## SYNOPSIS
Gets a list of Snipe-it consumables
## SYNTAX
### Search (Default)
```
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>]
```
### Get with ID
```
Get-SnipeitConsumable [-id <Int32[]>] [-url <String>] [-apiKey <String>] [<CommonParameters>]
```
## DESCRIPTION
{{ Fill in the Description }}
## EXAMPLES
### EXAMPLE 1
```
Get-SnipeitConsumable -all
Returns all consumables
```
### EXAMPLE 2
```
Get-SnipeitConsumable -search paper
Returns search results containeing string display
```
### EXAMPLE 3
```
Get-Snipeitconsumable -id
Returns specific consumable
```
## PARAMETERS
### -all
A return all results
```yaml
Type: SwitchParameter
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -apiKey
Deprecated parameter, please use Connect-SnipeitPS instead.
Users API Key for Snipeit.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -category_id
Id number of category
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -company_id
Id number of company
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -expand
Whether to include detailed information on categories, etc (true) or just the text name (false)
```yaml
Type: SwitchParameter
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -id
A id of specific consumable
```yaml
Type: Int32[]
Parameter Sets: Get with ID
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -limit
Specify the number of results you wish to return.
Defaults to 50.
Defines batch size for -all
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 50
Accept pipeline input: False
Accept wildcard characters: False
```
### -location_id
{{ Fill location_id Description }}
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -manufacturer_id
Id number of manufacturer
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -offset
Offset to use
```yaml
Type: Int32
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -order
Specify the order (asc or desc) you wish to order by on your sort column
```yaml
Type: String
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: Desc
Accept pipeline input: False
Accept wildcard characters: False
```
### -search
A text string to search the consumables
```yaml
Type: String
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -sort
Sort results by column
```yaml
Type: String
Parameter Sets: Search
Aliases:
Required: False
Position: Named
Default value: Created_at
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
Deprecated parameter, please use Connect-SnipeitPS instead.
URL of Snipeit system.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
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

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

View file

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

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