mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-15 02:35:47 +00:00
85 lines
2.1 KiB
PowerShell
85 lines
2.1 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Add a new Manufacturer to Snipe-it asset system
|
|
|
|
.DESCRIPTION
|
|
Long description
|
|
|
|
.PARAMETER Name
|
|
Name of the Manufacturer
|
|
|
|
.PARAMETER image
|
|
Manufacturer Image filename and path
|
|
|
|
.PARAMETER image_delete
|
|
Remove current image
|
|
|
|
.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-SnipeitManufacturer -name "HP"
|
|
#>
|
|
|
|
function New-SnipeitManufacturer() {
|
|
[CmdletBinding(
|
|
SupportsShouldProcess = $true,
|
|
ConfirmImpact = "Low"
|
|
)]
|
|
|
|
Param(
|
|
[parameter(mandatory = $true)]
|
|
[string]$Name,
|
|
|
|
[ValidateScript({Test-Path $_})]
|
|
[string]$image,
|
|
|
|
[switch]$image_delete=$false,
|
|
|
|
[parameter(mandatory = $false)]
|
|
[string]$url,
|
|
|
|
[parameter(mandatory = $false)]
|
|
[string]$apiKey
|
|
)
|
|
|
|
begin {
|
|
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
|
|
|
$Values = @{
|
|
"name" = $Name
|
|
}
|
|
|
|
$Parameters = @{
|
|
Api = "/api/v1/manufacturers"
|
|
Method = 'post'
|
|
Body = $Values
|
|
}
|
|
|
|
if ($PSBoundParameters.ContainsKey('apiKey')) {
|
|
Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead."
|
|
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
|
}
|
|
|
|
if ($PSBoundParameters.ContainsKey('url')) {
|
|
Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead."
|
|
Set-SnipeitPSLegacyUrl -url $url
|
|
}
|
|
}
|
|
process {
|
|
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
|
$result = Invoke-SnipeitMethod @Parameters
|
|
}
|
|
|
|
$result
|
|
}
|
|
end {
|
|
# reset legacy sessions
|
|
if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) {
|
|
Reset-SnipeitPSLegacyApi
|
|
}
|
|
}
|
|
}
|