New/Set/Remove suppliers

This commit is contained in:
Petri Asikainen 2021-07-09 15:17:41 +03:00
parent 7871fc3711
commit 9b356a2b9e
7 changed files with 1059 additions and 0 deletions

View file

@ -0,0 +1,117 @@
<#
.SYNOPSIS
Creates a supplier
.DESCRIPTION
Creates a new supplier on Snipe-It system
.PARAMETER name
Department Name
.PARAMETER address
Address line 1 of supplier
.PARAMETER address2
Address line 1 of supplier
.PARAMETER city
City
.PARAMETER state
State
.PARAMETER country
Country
.PARAMETER zip
Zip code
.PARAMETER phone
Phone number
.PARAMETER fax
Fax number
.PARAMETER email
Email address
.PARAMETER contact
Contact person
.PARAMETER notes
Email address
.PARAMETER image
Image file name and path for item
.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-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
#>
function New-SnipeitSupplier() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$name,
[string]$address,
[string]$address2,
[string]$city,
[string]$state,
[string]$country,
[string]$zip,
[string]$phone,
[string]$fax,
[string]$email,
[string]$contact,
[string]$notes,
[ValidateScript({Test-Path $_})]
[string]$image,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Uri = "$url/api/v1/suppilers"
Method = 'POST'
Body = $Values
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}

View file

@ -0,0 +1,54 @@
<#
.SYNOPSIS
Removes supplier from Snipe-it asset system
.DESCRIPTION
Removes supplier or multiple manufacturers from Snipe-it asset system
.PARAMETER ID
Unique ID For supplier to be removed
.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
Remove-SnipeitSupplier -ID 44
.EXAMPLE
Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier
#>
function Remove-SnipeitSupplier ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
begin {
}
process {
foreach($suppliers_id in $id){
$Parameters = @{
Uri = "$url/api/v1/suppliers/$supplier_id"
Method = 'Delete'
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}

View file

@ -0,0 +1,134 @@
<#
.SYNOPSIS
Modify the supplier
.DESCRIPTION
Modifieds the supplier on Snipe-It system
.PARAMETER name
Suppiers Name
.PARAMETER address
Address line 1 of supplier
.PARAMETER address2
Address line 1 of supplier
.PARAMETER city
City
.PARAMETER state
State
.PARAMETER country
Country
.PARAMETER zip
Zip code
.PARAMETER phone
Phone number
.PARAMETER fax
Fax number
.PARAMETER email
Email address
.PARAMETER contact
Contact person
.PARAMETER notes
Email address
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
.PARAMETER RequestType
Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed.
.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-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
#>
function Set-SnipeitSupplier() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[string]$name,
[string]$address,
[string]$address2,
[string]$city,
[string]$state,
[string]$country,
[string]$zip,
[string]$phone,
[string]$fax,
[string]$email,
[string]$contact,
[string]$notes,
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete,
[ValidateSet("Put","Patch")]
[string]$RequestType = "Patch",
[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
}
process {
foreach ($supplier_id in $id) {
$Parameters = @{
Uri = "$url/api/v1/suppliers/$supplier_id"
Method = $RequestType
Body = $Values
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}

View file

@ -104,6 +104,7 @@ FunctionsToExport = @(
'New-SnipeitLocation',
'New-SnipeitManufacturer',
'New-SnipeitModel',
'New-SnipeitSupplier',
'New-SnipeitUser',
'Remove-SnipeitAccessory',
'Remove-SnipeitAsset',
@ -118,6 +119,7 @@ FunctionsToExport = @(
'Remove-SnipeitLocation',
'Remove-SnipeitManufacturer',
'Remove-SnipeitModel',
'Remove-SnipeitSupplier',
'Remove-SnipeitUser',
'Reset-SnipeitAccessoryOwner',
'Reset-SnipeitAssetOwner',
@ -137,6 +139,7 @@ FunctionsToExport = @(
'Set-SnipeitLocation',
'Set-SnipeitModel',
'Set-SnipeitStatus',
'Set-SnipeitSupplier',
'Set-SnipeitUser',
'Update-SnipeitAlias'
)

299
docs/New-SnipeitSupplier.md Normal file
View file

@ -0,0 +1,299 @@
---
external help file: SnipeitPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# New-SnipeitSupplier
## SYNOPSIS
Creates a supplier
## SYNTAX
```
New-SnipeitSupplier [-name] <String> [[-address] <String>] [[-address2] <String>] [[-city] <String>]
[[-state] <String>] [[-country] <String>] [[-zip] <String>] [[-phone] <String>] [[-fax] <String>]
[[-email] <String>] [[-contact] <String>] [[-notes] <String>] [[-image] <String>] [-url] <String>
[-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Creates a new supplier on Snipe-It system
## EXAMPLES
### EXAMPLE 1
```
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
```
## PARAMETERS
### -address
Address line 1 of supplier
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -address2
Address line 1 of supplier
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 15
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -city
City
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -contact
Contact person
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -country
Country
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -email
Email address
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -fax
Fax number
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -image
Image file name and path for item
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 13
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -name
Department Name
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -notes
Email address
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -phone
Phone number
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -state
State
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 14
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -zip
Zip code
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

View file

@ -0,0 +1,122 @@
---
external help file: SnipeitPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Remove-SnipeitSupplier
## SYNOPSIS
Removes supplier from Snipe-it asset system
## SYNTAX
```
Remove-SnipeitSupplier [-id] <Int32[]> [-URL] <String> [-APIKey] <String> [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
Removes supplier or multiple manufacturers from Snipe-it asset system
## EXAMPLES
### EXAMPLE 1
```
Remove-SnipeitSupplier -ID 44
```
### EXAMPLE 2
```
Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier
```
## PARAMETERS
### -APIKey
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -id
Unique ID For supplier to be removed
```yaml
Type: Int32[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -URL
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

330
docs/Set-SnipeitSupplier.md Normal file
View file

@ -0,0 +1,330 @@
---
external help file: SnipeitPS-help.xml
Module Name: SnipeitPS
online version:
schema: 2.0.0
---
# Set-SnipeitSupplier
## SYNOPSIS
Modify the supplier
## SYNTAX
```
Set-SnipeitSupplier [-name] <String> [[-address] <String>] [[-address2] <String>] [[-city] <String>]
[[-state] <String>] [[-country] <String>] [[-zip] <String>] [[-phone] <String>] [[-fax] <String>]
[[-email] <String>] [[-contact] <String>] [[-notes] <String>] [[-image] <String>] [-image_delete]
[[-RequestType] <String>] [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Modifieds the supplier on Snipe-It system
## EXAMPLES
### EXAMPLE 1
```
New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3
```
## PARAMETERS
### -address
Address line 1 of supplier
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -address2
Address line 1 of supplier
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -apiKey
Users API Key for Snipeit, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 16
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -city
City
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -contact
Contact person
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -country
Country
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -email
Email address
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -fax
Fax number
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -image
Image file name and path for item
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 13
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -image_delete
Remove current image
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -name
Suppiers Name
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -notes
Email address
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -phone
Phone number
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -RequestType
Http request type to send Snipe IT system.
Defaults to Patch you could use Put if needed.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 14
Default value: Patch
Accept pipeline input: False
Accept wildcard characters: False
```
### -state
State
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -url
URL of Snipeit system, can be set using Set-SnipeitInfo command
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 15
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -zip
Zip code
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS