mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-15 02:35:47 +00:00
Merge 865a07d4ad into d14244d727
This commit is contained in:
commit
c973eeb735
8 changed files with 100 additions and 7 deletions
73
SnipeitPS/Public/New-SnipeitCustomFieldset.ps1
Normal file
73
SnipeitPS/Public/New-SnipeitCustomFieldset.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Custom Fieldset to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Add a new Custom Field Set to Snipe-it asset system
|
||||
|
||||
.PARAMETER name
|
||||
The fieldsets's name
|
||||
|
||||
.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-SnipeitCustomFieldSet -Name "Notebook Fields"
|
||||
#>
|
||||
|
||||
function New-SnipeitCustomFieldSet() {
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$name,
|
||||
|
||||
[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/fieldsets"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +47,9 @@
|
|||
.PARAMETER purchase_date
|
||||
Date of license purchase
|
||||
|
||||
.PARAMETER purchase_order
|
||||
Purchase order number of license purchase
|
||||
|
||||
.PARAMETER reassignable
|
||||
Is license reassignable?
|
||||
|
||||
|
|
@ -89,7 +92,6 @@ function New-SnipeitLicense() {
|
|||
|
||||
[datetime]$expiration_date,
|
||||
|
||||
[ValidateLength(1, 120)]
|
||||
[mailaddress]$license_email,
|
||||
|
||||
[ValidateLength(1, 100)]
|
||||
|
|
@ -108,6 +110,8 @@ function New-SnipeitLicense() {
|
|||
|
||||
[datetime]$purchase_date,
|
||||
|
||||
[string]$purchase_order,
|
||||
|
||||
[bool]$reassignable,
|
||||
|
||||
[string]$serial,
|
||||
|
|
@ -140,6 +144,10 @@ function New-SnipeitLicense() {
|
|||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($Values['license_email']) {
|
||||
$Values['license_email'] = $Values['license_email'].address
|
||||
}
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/licenses"
|
||||
Method = 'POST'
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function New-SnipeitSupplier() {
|
|||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/suppilers"
|
||||
Api = "/api/v1/suppliers"
|
||||
Method = 'POST'
|
||||
Body = $Values
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@
|
|||
.PARAMETER username
|
||||
Username for user
|
||||
|
||||
.PARAMETER active
|
||||
.PARAMETER activated
|
||||
Can user log in to snipe-it?
|
||||
|
||||
.PARAMETER password
|
||||
Password for user
|
||||
Password for user. The password should at least be 8 characters long.
|
||||
|
||||
.PARAMETER notes
|
||||
User Notes
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
|
||||
|
||||
.EXAMPLE
|
||||
New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
|
||||
New-Snipeituser -first_name It -last_name Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
|
||||
Creates new a new user who can't login to system
|
||||
|
||||
.NOTES
|
||||
|
|
@ -86,6 +86,8 @@ function New-SnipeitUser() {
|
|||
[parameter(mandatory = $true)]
|
||||
[string]$username,
|
||||
|
||||
[ValidateScript({$_.Length -ge 8}, ErrorMessage = "Password should be at least 8 characters.")]
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$password,
|
||||
|
||||
[bool]$activated = $false,
|
||||
|
|
@ -122,6 +124,7 @@ function New-SnipeitUser() {
|
|||
[string]$apiKey
|
||||
)
|
||||
begin {
|
||||
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
.PARAMETER purchase_date
|
||||
Date of license purchase
|
||||
|
||||
.PARAMETER purchase_order
|
||||
Purchase order number of license purchase
|
||||
|
||||
.PARAMETER reassignable
|
||||
Is license reassignable?
|
||||
|
||||
|
|
@ -116,6 +119,8 @@ function Set-SnipeitLicense() {
|
|||
|
||||
[datetime]$purchase_date,
|
||||
|
||||
[string]$purchase_order,
|
||||
|
||||
[bool]$reassignable,
|
||||
|
||||
[string]$serial,
|
||||
|
|
@ -151,6 +156,9 @@ function Set-SnipeitLicense() {
|
|||
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
if ($Values['license_email']) {
|
||||
$Values['license_email'] = $Values['license_email'].address
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ FunctionsToExport = @(
|
|||
'New-SnipeitComponent',
|
||||
'New-SnipeitConsumable',
|
||||
'New-SnipeitCustomField',
|
||||
'New-SnipeitCustomFieldSet',
|
||||
'New-SnipeitDepartment',
|
||||
'New-SnipeitLicense',
|
||||
'New-SnipeitLocation',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ Specifying asset tag when creating asset
|
|||
|
||||
### EXAMPLE 3
|
||||
```
|
||||
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" -customfields @{ "_snipeit_os_5" = "Windows 10 Pro" }
|
||||
Using customfields when creating asset.
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Set-SnipeitAsset -id 1 -status_id 1 -model_id 1 -name "Machine1"
|
|||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Set-SnipeitAsset -id 1 -name "Machine1" -customfields = @{ "_snipeit_os_5" = "Windows 10 Pro" ; "_snipeit_os_version" = "1909" }
|
||||
Set-SnipeitAsset -id 1 -name "Machine1" -customfields @{ "_snipeit_os_5" = "Windows 10 Pro" ; "_snipeit_os_version" = "1909" }
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue