mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 09:52:30 +00:00
Merge branch 'PetriAsi-new-asset-like-api' into develop
This commit is contained in:
commit
3804a6df17
2 changed files with 98 additions and 67 deletions
|
|
@ -5,17 +5,42 @@
|
|||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER Tag
|
||||
Asset Tag for the Asset
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Asset
|
||||
.PARAMETER status_id
|
||||
Required Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
.PARAMETER Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
.PARAMETER model_id
|
||||
Required Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
.PARAMETER Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
.PARAMETER name
|
||||
Optional Name of the Asset
|
||||
|
||||
.PARAMETER asset_tag
|
||||
Asset Tag for the Asset, not required when snipe asset_tag autogeneration is on.
|
||||
|
||||
.PARAMETER serial
|
||||
Optional Serial number of the Asset
|
||||
|
||||
.PARAMETER company_id
|
||||
Optional Company id
|
||||
|
||||
.PARAMETER order_number
|
||||
Optional Order number
|
||||
|
||||
.PARAMETER notes
|
||||
Optional Notes
|
||||
|
||||
.PARAMETER warranty_monhts
|
||||
Optional Warranty lenght of the Asset in months
|
||||
|
||||
.PARAMETER purchase_cost
|
||||
Optional Purchase cost of the Asset
|
||||
|
||||
.PARAMETER purchase_date
|
||||
Optional Purchase cost of the Asset
|
||||
|
||||
.PARAMETER rtd_location_id
|
||||
Optional Default location id for the asset
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
|
@ -41,16 +66,45 @@ function New-Asset()
|
|||
)]
|
||||
|
||||
Param(
|
||||
[string]$tag,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$status_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Name,
|
||||
[int]$model_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$Status_id,
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$Model_id,
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$asset_tag,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$serial,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$company_id,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$order_number,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$notes,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$warranty_months,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$purchase_cost,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$purchase_date,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$supplier_id,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[int]$rtd_location_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
|
@ -61,16 +115,8 @@ function New-Asset()
|
|||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('tag'))
|
||||
{
|
||||
$Values += @{"asset_tag" = $tag}
|
||||
}
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
|
||||
if ($customfields)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,16 +5,22 @@
|
|||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER firstName
|
||||
.PARAMETER first_name
|
||||
Parameter description
|
||||
|
||||
.PARAMETER lastName
|
||||
.PARAMETER last_name
|
||||
Parameter description
|
||||
|
||||
.PARAMETER userName
|
||||
.PARAMETER username
|
||||
Parameter description
|
||||
|
||||
.PARAMETER jobTitle
|
||||
.PARAMETER active
|
||||
Parameter description
|
||||
|
||||
.PARAMETER notes
|
||||
Parameter description
|
||||
|
||||
.PARAMETER jobtitle
|
||||
Parameter description
|
||||
|
||||
.PARAMETER email
|
||||
|
|
@ -38,8 +44,8 @@
|
|||
.PARAMETER employee_num
|
||||
Parameter description
|
||||
|
||||
.PARAMETER ldap_user
|
||||
Parameter description
|
||||
.PARAMETER ldap_import
|
||||
Mark user as import from ldap
|
||||
|
||||
.PARAMETER url
|
||||
Parameter description
|
||||
|
|
@ -62,17 +68,21 @@ function New-User() {
|
|||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$firstName,
|
||||
[string]$first_name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$lastName,
|
||||
[string]$last_name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$userName,
|
||||
[string]$username,
|
||||
|
||||
[string]$password,
|
||||
|
||||
[string]$jobTitle,
|
||||
[bool]$activated = $false,
|
||||
|
||||
[string]$notes,
|
||||
|
||||
[string]$jobtitle,
|
||||
|
||||
[string]$email,
|
||||
|
||||
|
|
@ -88,47 +98,22 @@ function New-User() {
|
|||
|
||||
[string]$employee_num,
|
||||
|
||||
[bool]$ldap_user = $false,
|
||||
[bool]$ldap_import = $false,
|
||||
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
first_name = $firstName
|
||||
last_name = $lastName
|
||||
username = $userName
|
||||
|
||||
email = $email
|
||||
phone = $phone
|
||||
company_id = $company_id
|
||||
location_id = $location_id
|
||||
department_id = $department_id
|
||||
manager_id = $manager_id
|
||||
jobtitle = $jobTitle
|
||||
employee_num = $employee_num
|
||||
notes = "Imported using SnipeitPS Script"
|
||||
activated = 1
|
||||
|
||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||
|
||||
if ($password ) {
|
||||
$Values['password_confirmation'] = $password
|
||||
}
|
||||
|
||||
if ($ldap_user -eq $false) {
|
||||
$ldap = @{
|
||||
password = $password
|
||||
password_confirmation = $password
|
||||
ldap_import = 0
|
||||
}
|
||||
$Values += $ldap
|
||||
}
|
||||
else {
|
||||
$ldap = @{
|
||||
ldap_import = 1
|
||||
}
|
||||
$Values += $ldap
|
||||
}
|
||||
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue