mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Merge pull request #121 from PetriAsi/fix/datetime-inputs
check datetime and int input types
This commit is contained in:
commit
160ba60069
11 changed files with 40 additions and 35 deletions
|
|
@ -106,7 +106,7 @@ function New-SnipeItAsset()
|
||||||
[string]$purchase_cost,
|
[string]$purchase_cost,
|
||||||
|
|
||||||
[parameter(mandatory = $false)]
|
[parameter(mandatory = $false)]
|
||||||
[string]$purchase_date,
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
[parameter(mandatory = $false)]
|
[parameter(mandatory = $false)]
|
||||||
[int]$supplier_id,
|
[int]$supplier_id,
|
||||||
|
|
@ -127,6 +127,9 @@ function New-SnipeItAsset()
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
if ($customfields)
|
if ($customfields)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ function Remove-SnipeItAsset ()
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[int]$ID,
|
[int]$id,
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$URL,
|
[string]$URL,
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
|
|
@ -35,7 +35,7 @@ function Remove-SnipeItAsset ()
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = @{
|
$Values = @{
|
||||||
"ID" = $Name
|
"ID" = $id
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json
|
$Body = $Values | ConvertTo-Json
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function Remove-SnipeItAssetMaintenance {
|
||||||
# Asset maintenance ID
|
# Asset maintenance ID
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[int]
|
[int]
|
||||||
$ID,
|
$id,
|
||||||
|
|
||||||
# SnipeIt URL
|
# SnipeIt URL
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
|
|
@ -39,7 +39,7 @@ function Remove-SnipeItAssetMaintenance {
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = @{
|
$Values = @{
|
||||||
"ID" = $ID
|
"ID" = $id
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json
|
$Body = $Values | ConvertTo-Json
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ function Remove-SnipeItUser ()
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$ID,
|
[int]$id,
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$URL,
|
[string]$URL,
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
|
|
@ -36,7 +36,7 @@ function Remove-SnipeItUser ()
|
||||||
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||||
|
|
||||||
$Values = @{
|
$Values = @{
|
||||||
"ID" = $ID
|
"ID" = $id
|
||||||
}
|
}
|
||||||
|
|
||||||
$Body = $Values | ConvertTo-Json
|
$Body = $Values | ConvertTo-Json
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ function Set-SnipeItAsset()
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Status_id,
|
[int]$status_id,
|
||||||
|
|
||||||
[string]$Model_id,
|
[int]$model_id,
|
||||||
|
|
||||||
[DateTime]$last_checkout,
|
[DateTime]$last_checkout,
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ function Set-SnipeItAsset()
|
||||||
|
|
||||||
[double]$purchase_cost,
|
[double]$purchase_cost,
|
||||||
|
|
||||||
[DateTime]$purchase_date,
|
[datetime]$purchase_date,
|
||||||
|
|
||||||
[bool]$requestable,
|
[bool]$requestable,
|
||||||
|
|
||||||
|
|
@ -118,7 +118,9 @@ function Set-SnipeItAsset()
|
||||||
|
|
||||||
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
||||||
|
|
||||||
if ($model_id) { $Values.Add('model_id',$model_id)}
|
if ($values['purchase_date']) {
|
||||||
|
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
|
||||||
if ($customfields)
|
if ($customfields)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ function Set-SnipeItComponent()
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$id,
|
[int]$id,
|
||||||
|
|
||||||
[parameter(mandatory = $true)]
|
[parameter(mandatory = $true)]
|
||||||
[string]$qty,
|
[int]$qty,
|
||||||
|
|
||||||
[string]$name,
|
[string]$name,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ Add a new Asset to Snipe-it asset system
|
||||||
```
|
```
|
||||||
New-SnipeItAsset [-status_id] <Int32> [-model_id] <Int32> [[-name] <String>] [[-asset_tag] <String>]
|
New-SnipeItAsset [-status_id] <Int32> [-model_id] <Int32> [[-name] <String>] [[-asset_tag] <String>]
|
||||||
[[-serial] <String>] [[-company_id] <Int32>] [[-order_number] <String>] [[-notes] <String>]
|
[[-serial] <String>] [[-company_id] <Int32>] [[-order_number] <String>] [[-notes] <String>]
|
||||||
[[-warranty_months] <Int32>] [[-purchase_cost] <String>] [[-purchase_date] <String>] [[-supplier_id] <Int32>]
|
[[-warranty_months] <Int32>] [[-purchase_cost] <String>] [[-purchase_date] <DateTime>]
|
||||||
[[-rtd_location_id] <Int32>] [-url] <String> [-apiKey] <String> [[-customfields] <Hashtable>] [-WhatIf]
|
[[-supplier_id] <Int32>] [[-rtd_location_id] <Int32>] [-url] <String> [-apiKey] <String>
|
||||||
[-Confirm] [<CommonParameters>]
|
[[-customfields] <Hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
@ -188,7 +188,7 @@ Accept wildcard characters: False
|
||||||
Optional Purchase cost of the Asset
|
Optional Purchase cost of the Asset
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: DateTime
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Removes Asset from Snipe-it asset system
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Remove-SnipeItAsset [-ID] <Int32> [-URL] <String> [-APIKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
Remove-SnipeItAsset [-id] <Int32> [-URL] <String> [-APIKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
@ -43,7 +43,7 @@ Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -ID
|
### -id
|
||||||
Unique ID For Asset to be removed
|
Unique ID For Asset to be removed
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Removes User from Snipe-it asset system
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Remove-SnipeItUser [-ID] <String> [-URL] <String> [-APIKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
Remove-SnipeItUser [-id] <Int32> [-URL] <String> [-APIKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
@ -43,17 +43,17 @@ Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -ID
|
### -id
|
||||||
Unique ID For User to be removed
|
Unique ID For User to be removed
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 1
|
Position: 1
|
||||||
Default value: None
|
Default value: 0
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Update a specific Asset in the Snipe-it asset system
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Set-SnipeItAsset [-id] <Int32> [[-Name] <String>] [[-Status_id] <String>] [[-Model_id] <String>]
|
Set-SnipeItAsset [-id] <Int32> [[-Name] <String>] [[-status_id] <Int32>] [[-model_id] <Int32>]
|
||||||
[[-last_checkout] <DateTime>] [[-assigned_to] <Int32>] [[-company_id] <Int32>] [[-serial] <String>]
|
[[-last_checkout] <DateTime>] [[-assigned_to] <Int32>] [[-company_id] <Int32>] [[-serial] <String>]
|
||||||
[[-order_number] <String>] [[-warranty_months] <Int32>] [[-purchase_cost] <Double>]
|
[[-order_number] <String>] [[-warranty_months] <Int32>] [[-purchase_cost] <Double>]
|
||||||
[[-purchase_date] <DateTime>] [[-requestable] <Boolean>] [[-archived] <Boolean>] [[-rtd_location_id] <Int32>]
|
[[-purchase_date] <DateTime>] [[-requestable] <Boolean>] [[-archived] <Boolean>] [[-rtd_location_id] <Int32>]
|
||||||
|
|
@ -143,17 +143,17 @@ Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -Model_id
|
### -model_id
|
||||||
Model ID of the asset, this can be got using Get-Model
|
Model ID of the asset, this can be got using Get-Model
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: 4
|
Position: 4
|
||||||
Default value: None
|
Default value: 0
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
@ -263,17 +263,17 @@ Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -Status_id
|
### -status_id
|
||||||
Status ID of the asset, this can be got using Get-Status
|
Status ID of the asset, this can be got using Get-Status
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: 3
|
Position: 3
|
||||||
Default value: None
|
Default value: 0
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Updates component
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Set-SnipeItComponent [-id] <String> [-qty] <String> [[-name] <String>] [[-company_id] <Int32>]
|
Set-SnipeItComponent [-id] <Int32> [-qty] <Int32> [[-name] <String>] [[-company_id] <Int32>]
|
||||||
[[-location_id] <Int32>] [[-purchase_date] <DateTime>] [[-purchase_cost] <Single>] [-url] <String>
|
[[-location_id] <Int32>] [[-purchase_date] <DateTime>] [[-purchase_cost] <Single>] [-url] <String>
|
||||||
[-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
[-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
@ -64,13 +64,13 @@ Accept wildcard characters: False
|
||||||
ID number of name
|
ID number of name
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 1
|
Position: 1
|
||||||
Default value: None
|
Default value: 0
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
@ -139,13 +139,13 @@ Accept wildcard characters: False
|
||||||
Quantity of the components you have
|
Quantity of the components you have
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 2
|
Position: 2
|
||||||
Default value: None
|
Default value: 0
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue