Files
ps.ipam/functions/public/Assign-Tag.ps1
2022-12-14 13:22:13 +03:00

49 lines
1.0 KiB
PowerShell

function Assign-Tag {
<#
.SYNOPSIS
Assign tag to address.
.PARAMETER Tag
Tag object to assign.
#>
[CmdletBinding()]
param (
[parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0
)]
[ValidateNotNullOrEmpty()]
[PS.IPAM.Address]
$AddressObject,
[parameter(
Mandatory=$true,
Position=1
)]
[ValidateNotNullOrEmpty()]
[PS.IPAM.Tag]
$Tag
)
process {
$_params = @{
Controller = [PS.IPAM.controllers]::addresses
Method = "PATCH"
}
$_id = $AddressObject.id
$_tagid = $Tag.id
$_identifiers = @($_id)
$_params.Add("Identifiers",$_identifiers)
$_body = @{ }
$_body.Add("tag", $_tagid)
$_params.Add("Params",$_body)
Invoke-Request @_params
}
}
Export-ModuleMember -Function Assign-Tag