mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
60 lines
1.1 KiB
PowerShell
60 lines
1.1 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Creates a new Company
|
|
|
|
.DESCRIPTION
|
|
Creates new company on Snipe-It system
|
|
|
|
.PARAMETER name
|
|
Comapany 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
|
|
New-SnipeItCompany -name "Acme Company"
|
|
|
|
#>
|
|
|
|
function New-SnipeItCompany()
|
|
{
|
|
[CmdletBinding(
|
|
SupportsShouldProcess = $true,
|
|
ConfirmImpact = "Low"
|
|
)]
|
|
|
|
Param(
|
|
[parameter(mandatory = $true)]
|
|
[string]$name,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[string]$url,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[string]$apiKey
|
|
)
|
|
|
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
|
|
|
$Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters
|
|
|
|
$Body = $Values | ConvertTo-Json;
|
|
|
|
$Parameters = @{
|
|
Uri = "$url/api/v1/companies"
|
|
Method = 'POST'
|
|
Body = $Body
|
|
Token = $apiKey
|
|
}
|
|
|
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
|
{
|
|
$result = Invoke-SnipeitMethod @Parameters
|
|
}
|
|
|
|
$result
|
|
}
|
|
|