mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Merge pull request #26 from snazy2000/develop
BREAKING CHANGE : Renamed Get-Location to Get-Locations
This commit is contained in:
commit
1b5b8428d4
2 changed files with 55 additions and 39 deletions
51
SnipeitPS/Public/Get-Locations.ps1
Normal file
51
SnipeitPS/Public/Get-Locations.ps1
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
# Gets a list of Snipe-it Locations
|
||||||
|
|
||||||
|
.PARAMETER url
|
||||||
|
URL of Snipeit system, can be set using Set-Info command
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Users API Key for Snipeit, can be set using Set-Info command
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-Location -url "https://assets.example.com" -token "token..."
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-Location -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Location1" }
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
function Get-Locations()
|
||||||
|
{
|
||||||
|
Param(
|
||||||
|
[string]$search,
|
||||||
|
|
||||||
|
[ValidateSet("asc", "desc")]
|
||||||
|
[string]$order = "desc",
|
||||||
|
|
||||||
|
[int]$limit = 50,
|
||||||
|
|
||||||
|
[int]$offset,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
$SearchParameter = . Get-ParameterValue
|
||||||
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/locations"
|
||||||
|
Method = 'Get'
|
||||||
|
Token = $apiKey
|
||||||
|
GetParameters = $SearchParameter
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,38 +1,3 @@
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Add a new Asset to Snipe-it asset system
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Long description
|
|
||||||
|
|
||||||
.PARAMETER Tag
|
|
||||||
Asset Tag for the Asset
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
Name of the Asset
|
|
||||||
|
|
||||||
.PARAMETER Status_id
|
|
||||||
Status ID of the asset, this can be got using Get-Status
|
|
||||||
|
|
||||||
.PARAMETER Model_id
|
|
||||||
Model ID of the asset, this can be got using Get-Model
|
|
||||||
|
|
||||||
.PARAMETER url
|
|
||||||
URL of Snipeit system, can be set using Set-Info command
|
|
||||||
|
|
||||||
.PARAMETER apiKey
|
|
||||||
Users API Key for Snipeit, can be set using Set-Info command
|
|
||||||
|
|
||||||
.PARAMETER customfields
|
|
||||||
Hastable of custom fields and extra fields that need passing through to Snipeit
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
New-Asset -status_id 1 -model_id 1 -name "Machine1"
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
New-Asset -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
|
||||||
#>
|
|
||||||
|
|
||||||
function New-AssetMaintenance() {
|
function New-AssetMaintenance() {
|
||||||
[CmdletBinding(
|
[CmdletBinding(
|
||||||
SupportsShouldProcess = $true,
|
SupportsShouldProcess = $true,
|
||||||
|
|
@ -53,10 +18,10 @@ function New-AssetMaintenance() {
|
||||||
[string]$title,
|
[string]$title,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[datetime]$startDate,
|
[datetime]$start_date,
|
||||||
|
|
||||||
[parameter(mandatory = $false)]
|
[parameter(mandatory = $false)]
|
||||||
[datetime]$completionDate,
|
[datetime]$completion_date,
|
||||||
|
|
||||||
[bool]$is_warranty = $false,
|
[bool]$is_warranty = $false,
|
||||||
|
|
||||||
|
|
@ -77,8 +42,8 @@ function New-AssetMaintenance() {
|
||||||
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
|
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($values['completionDate']) {
|
if ($values['completion_date']) {
|
||||||
$values['completionDate'] = $values['completionDate'].ToString("yyyy-MM-dd")
|
$values['completion_date'] = $values['completion_date'].ToString("yyyy-MM-dd")
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue