mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Merge pull request #159 from PetriAsi/feature/set-things
Set thing and couple other fixes
This commit is contained in:
commit
7d6aa54279
14 changed files with 594 additions and 111 deletions
|
|
@ -8,11 +8,8 @@ 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 url
|
.PARAMETER eula_text
|
||||||
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
This allows you to customize your EULAs for specific types of assets
|
||||||
|
|
||||||
.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
|
||||||
|
|
@ -23,6 +20,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 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
|
.EXAMPLE
|
||||||
New-SnipeitCategory -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..."
|
New-SnipeitCategory -name "Laptops" -category_type asset -url "Snipe-IT URL here..." -apiKey "API key here..."
|
||||||
#>
|
#>
|
||||||
|
|
@ -42,51 +45,47 @@ function New-SnipeitCategory()
|
||||||
[ValidateSet("asset", "accessory", "consumable", "component", "license")]
|
[ValidateSet("asset", "accessory", "consumable", "component", "license")]
|
||||||
[string]$category_type,
|
[string]$category_type,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[string]$eula_text,
|
||||||
[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,
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
|
||||||
)
|
)
|
||||||
|
begin {
|
||||||
|
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
if($eula_text -and $use_default_eula){
|
||||||
|
throw 'Dont use -use_defalt_eula if -eula_text is set'
|
||||||
|
}
|
||||||
|
|
||||||
$Values = @{
|
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
"name" = $name
|
|
||||||
"category_type" = $category_type
|
$Body = $Values | ConvertTo-Json;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_default_eula) {
|
process {
|
||||||
$Values += @{"use_default_eula" = $true}
|
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/categories"
|
||||||
|
Method = 'POST'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
|
{
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($require_acceptance) {
|
|
||||||
$Values += @{"require_acceptance" = $true}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,29 @@
|
||||||
.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
|
||||||
Name of the Custom Field
|
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 url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
||||||
|
|
@ -27,17 +48,25 @@ function New-SnipeitCustomField()
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$name,
|
||||||
|
|
||||||
[string]$HelpText,
|
[string]$help_text,
|
||||||
|
|
||||||
[string]$Element = "text",
|
[parameter(mandatory = $true)]
|
||||||
|
[ValidateSet('text','textarea','listbox','checkbox','radio')]
|
||||||
|
[string]$element ,
|
||||||
|
|
||||||
[string]$Format = "ANY",
|
[parameter(mandatory = $true)]
|
||||||
|
[ValidateSet('ANY','CUSTOM REGEX','ALPHA','ALPHA-DASH','NUMERIC','ALPHA-NUMERIC','EMAIL','DATE','URL','IP','IPV4','IPV6','MAC','BOOLEAN')]
|
||||||
|
[string]$format,
|
||||||
|
|
||||||
[bool]$field_encrypted,
|
[string]$field_values,
|
||||||
|
|
||||||
[string]$CustomFormat,
|
[bool]$field_encrypted=$false,
|
||||||
|
|
||||||
|
[bool]$show_in_email=$false,
|
||||||
|
|
||||||
|
[string]$custom_format,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$url,
|
[string]$url,
|
||||||
|
|
@ -46,24 +75,31 @@ function New-SnipeitCustomField()
|
||||||
[string]$apiKey
|
[string]$apiKey
|
||||||
)
|
)
|
||||||
|
|
||||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
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
|
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
|
|
||||||
#Convert Values to JSON format
|
$Body = $Values | ConvertTo-Json;
|
||||||
$Body = $Values | ConvertTo-Json;
|
|
||||||
|
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/fields"
|
Uri = "$url/api/v1/fields"
|
||||||
Method = 'post'
|
Method = 'post'
|
||||||
Body = $Body
|
Body = $Body
|
||||||
Token = $apiKey
|
Token = $apiKey
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
process{
|
||||||
{
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
$result = Invoke-SnipeitMethod @Parameters
|
{
|
||||||
}
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
$result
|
$result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,13 @@ function Remove-SnipeitAssetMaintenance {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Remove asset maintenance from Snipe-it asset system
|
Remove asset maintenance from Snipe-it asset system
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Removes asset maintenance event or events from Snipe-it asset system by ID
|
Removes asset maintenance event or events from Snipe-it asset system by ID
|
||||||
|
|
||||||
.PARAMETER ID
|
.PARAMETER ID
|
||||||
Unique ID of the asset maintenance to be removed
|
Unique ID of the asset maintenance to be removed
|
||||||
|
|
||||||
.PARAMETER url
|
.PARAMETER url
|
||||||
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
|
URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
Get-SnipeitCategory -search something | Remove-SnipeitCategory
|
Get-SnipeitCategory -search something | Remove-SnipeitCategory
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function Remove-SnipeitModel ()
|
function Remove-SnipeitCategory ()
|
||||||
{
|
{
|
||||||
[CmdletBinding(
|
[CmdletBinding(
|
||||||
SupportsShouldProcess = $true,
|
SupportsShouldProcess = $true,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ function Remove-SnipeitDepartment ()
|
||||||
begin {
|
begin {
|
||||||
}
|
}
|
||||||
process {
|
process {
|
||||||
foreach($depatment_id in $id){
|
foreach($department_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Uri = "$url/api/v1/departments/$department_id"
|
Uri = "$url/api/v1/departments/$department_id"
|
||||||
Method = 'Delete'
|
Method = 'Delete'
|
||||||
|
|
|
||||||
90
SnipeitPS/Public/Set-SnipeitCategory.ps1
Normal file
90
SnipeitPS/Public/Set-SnipeitCategory.ps1
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
<#
|
||||||
|
.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 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
|
||||||
|
|
||||||
|
.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?
|
||||||
|
|
||||||
|
.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,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach($category_id in $id){
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/categories/$category_id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
|
{
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
SnipeitPS/Public/Set-SnipeitCompany.ps1
Normal file
70
SnipeitPS/Public/Set-SnipeitCompany.ps1
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Updates company name
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Updates companyt name on Snipe-It system
|
||||||
|
|
||||||
|
.PARAMETER id
|
||||||
|
ID number of company
|
||||||
|
|
||||||
|
.PARAMETER name
|
||||||
|
Company name
|
||||||
|
|
||||||
|
.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-SnipeitCompany()
|
||||||
|
{
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = "Medium"
|
||||||
|
)]
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
|
[int[]]$id,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$name,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
begin{
|
||||||
|
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
|
|
||||||
|
$Body = $values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach($company_id in $id){
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/companies/$company_id"
|
||||||
|
Method = 'Patch'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
|
{
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -49,8 +49,8 @@ function Set-SnipeitComponent()
|
||||||
)]
|
)]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
|
||||||
[int]$id,
|
[int[]]$id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$qty,
|
[int]$qty,
|
||||||
|
|
@ -74,28 +74,33 @@ function Set-SnipeitComponent()
|
||||||
[parameter(mandatory = $true)]
|
[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
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
if ($values['purchase_date']) {
|
$Body = $values | ConvertTo-Json;
|
||||||
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $values | ConvertTo-Json;
|
process {
|
||||||
|
foreach($component_id in $id){
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/components/$component_id"
|
||||||
|
Method = 'Patch'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
$Parameters = @{
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
Uri = "$url/api/v1/components/$id"
|
{
|
||||||
Method = 'Patch'
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
Body = $Body
|
}
|
||||||
Token = $apiKey
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
|
||||||
{
|
|
||||||
$result = Invoke-SnipeitMethod @Parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
$result
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
108
SnipeitPS/Public/Set-SnipeitCustomField.ps1
Normal file
108
SnipeitPS/Public/Set-SnipeitCustomField.ps1
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
<#
|
||||||
|
.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 url
|
||||||
|
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-SnipeitCustomField -Name "AntivirusInstalled" -Format "BOOLEAN" -HelpText "Is AntiVirus installed on Asset"
|
||||||
|
#>
|
||||||
|
|
||||||
|
function Set-SnipeitCustomField()
|
||||||
|
{
|
||||||
|
[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,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[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
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process{
|
||||||
|
foreach($field_id in $id) {
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/fields/$field_id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||||
|
{
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
85
SnipeitPS/Public/Set-SnipeitDepartment.ps1
Normal file
85
SnipeitPS/Public/Set-SnipeitDepartment.ps1
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<#
|
||||||
|
.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 url
|
||||||
|
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.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,
|
||||||
|
|
||||||
|
[int]$company_id,
|
||||||
|
|
||||||
|
[int]$location_id,
|
||||||
|
|
||||||
|
[int]$manager_id,
|
||||||
|
|
||||||
|
[string]$notes,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
|
|
||||||
|
$Body = $Values | ConvertTo-Json;
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($department_id in $id) {
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/departments/$department_id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -129,6 +129,7 @@ function Set-SnipeitLicense() {
|
||||||
[parameter(mandatory = $true)]
|
[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
|
||||||
|
|
||||||
|
|
@ -148,6 +149,7 @@ function Set-SnipeitLicense() {
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json;
|
$Body = $Values | ConvertTo-Json;
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach($license_id in $id){
|
foreach($license_id in $id){
|
||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
|
|
|
||||||
83
SnipeitPS/Public/Set-SnipeitStatus.ps1
Normal file
83
SnipeitPS/Public/Set-SnipeitStatus.ps1
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
<#
|
||||||
|
.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 url
|
||||||
|
URL of Snipeit system, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.PARAMETER apiKey
|
||||||
|
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
|
||||||
|
|
||||||
|
.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,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
|
||||||
|
[parameter(mandatory = $true)]
|
||||||
|
[string]$apiKey
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||||
|
$Body = $Values | ConvertTo-Json
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach($status_id in $id) {
|
||||||
|
$Parameters = @{
|
||||||
|
Uri = "$url/api/v1/statuslabels/$status_id"
|
||||||
|
Method = 'Put'
|
||||||
|
Body = $Body
|
||||||
|
Token = $apiKey
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||||
|
$result = Invoke-SnipeitMethod @Parameters
|
||||||
|
}
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -80,13 +80,10 @@ function Set-SnipeitUser() {
|
||||||
|
|
||||||
[string]$userName,
|
[string]$userName,
|
||||||
|
|
||||||
|
|
||||||
[string]$jobtitle,
|
[string]$jobtitle,
|
||||||
|
|
||||||
|
|
||||||
[string]$email,
|
[string]$email,
|
||||||
|
|
||||||
|
|
||||||
[string]$phone,
|
[string]$phone,
|
||||||
|
|
||||||
[int]$company_id,
|
[int]$company_id,
|
||||||
|
|
@ -97,12 +94,10 @@ function Set-SnipeitUser() {
|
||||||
|
|
||||||
[int]$manager_id,
|
[int]$manager_id,
|
||||||
|
|
||||||
|
|
||||||
[string]$employee_num,
|
[string]$employee_num,
|
||||||
|
|
||||||
[bool]$activated,
|
[bool]$activated,
|
||||||
|
|
||||||
|
|
||||||
[string]$notes,
|
[string]$notes,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,9 @@ PowerShellVersion = '3.0'
|
||||||
|
|
||||||
# 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 = @(
|
||||||
|
'Get-SnipeitAccessory',
|
||||||
|
'Get-SnipeitAccessoryOwner',
|
||||||
|
'Get-SnipeitActivity',
|
||||||
'Get-SnipeitAsset',
|
'Get-SnipeitAsset',
|
||||||
'Get-SnipeitAssetMaintenance',
|
'Get-SnipeitAssetMaintenance',
|
||||||
'Get-SnipeitCategory',
|
'Get-SnipeitCategory',
|
||||||
|
|
@ -78,45 +81,30 @@ FunctionsToExport = @(
|
||||||
'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-SnipeitComponent',
|
'New-SnipeitComponent',
|
||||||
'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-SnipeitUser',
|
'New-SnipeitUser',
|
||||||
'Set-SnipeitAsset',
|
|
||||||
'Set-SnipeitAssetOwner',
|
|
||||||
'Set-SnipeitComponent',
|
|
||||||
'Set-SnipeitModel',
|
|
||||||
'Set-SnipeitInfo',
|
|
||||||
'Set-SnipeitUser',
|
|
||||||
'Set-SnipeitLocation',
|
|
||||||
'Add-SnipeitAccessory',
|
|
||||||
'Set-SnipeitAccessory',
|
|
||||||
'Get-SnipeitAccessory',
|
|
||||||
'Remove-SnipeitAsset',
|
|
||||||
'Remove-SnipeitUser',
|
|
||||||
'Update-SnipeitAlias',
|
|
||||||
'Set-SnipeitAccessoryOwner',
|
|
||||||
'Get-SnipeitAccessoryOwner',
|
|
||||||
'Reset-SnipeitAccessoryOwner',
|
|
||||||
'Get-SnipeitActivity',
|
|
||||||
'Remove-SnipeitAccessory',
|
'Remove-SnipeitAccessory',
|
||||||
|
'Remove-SnipeitAsset',
|
||||||
|
'Remove-SnipeitAssetMaintenance',
|
||||||
'Remove-SnipeitCategory',
|
'Remove-SnipeitCategory',
|
||||||
'Remove-SnipeitCompany',
|
'Remove-SnipeitCompany',
|
||||||
'Remove-SnipeitComponent',
|
'Remove-SnipeitComponent',
|
||||||
|
|
@ -125,8 +113,27 @@ FunctionsToExport = @(
|
||||||
'Remove-SnipeitLicense',
|
'Remove-SnipeitLicense',
|
||||||
'Remove-SnipeitLocation',
|
'Remove-SnipeitLocation',
|
||||||
'Remove-SnipeitManufacturer',
|
'Remove-SnipeitManufacturer',
|
||||||
'Remove-SnipeitModel'
|
'Remove-SnipeitModel',
|
||||||
|
'Remove-SnipeitUser',
|
||||||
|
'Reset-SnipeitAccessoryOwner',
|
||||||
|
'Reset-SnipeitAssetOwner',
|
||||||
|
'Set-SnipeitAccessory',
|
||||||
|
'Set-SnipeitAccessoryOwner',
|
||||||
|
'Set-SnipeitAsset',
|
||||||
|
'Set-SnipeitAssetOwner',
|
||||||
|
'Set-SnipeitCategory'
|
||||||
|
'Set-SnipeitCompany'
|
||||||
|
'Set-SnipeitComponent',
|
||||||
|
'Set-SnipeitCustomField',
|
||||||
|
'Set-SnipeitDepartment',
|
||||||
|
'Set-SnipeitInfo',
|
||||||
|
'Set-SnipeitLicense',
|
||||||
|
'Set-SnipeitLicenseSeat',
|
||||||
|
'Set-SnipeitLocation',
|
||||||
|
'Set-SnipeitModel',
|
||||||
|
'Set-SnipeitStatus',
|
||||||
|
'Set-SnipeitUser',
|
||||||
|
'Update-SnipeitAlias'
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue