SnipeitPS/SnipeitPS/Public/New-SnipeItCompany.ps1
2021-05-23 23:22:23 +03:00

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
}