New-Address documentation
This commit is contained in:
@@ -6,7 +6,8 @@ function Get-Subnet {
|
|||||||
Mandatory=$true,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
Position=0,ParameterSetName="ByCIDR"
|
Position=0,
|
||||||
|
ParameterSetName="ByCIDR"
|
||||||
)]
|
)]
|
||||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
@@ -16,7 +17,8 @@ function Get-Subnet {
|
|||||||
Mandatory=$true,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
Position=0,ParameterSetName="ByID"
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
@@ -25,7 +27,8 @@ function Get-Subnet {
|
|||||||
Mandatory=$true,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
Position=0,ParameterSetName="BySectionId"
|
Position=0,
|
||||||
|
ParameterSetName="BySectionId"
|
||||||
)]
|
)]
|
||||||
[parameter(
|
[parameter(
|
||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
@@ -110,12 +113,18 @@ function Get-Subnet {
|
|||||||
$VlanDomainId,
|
$VlanDomainId,
|
||||||
[parameter(
|
[parameter(
|
||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1,
|
||||||
ParameterSetName="ByID"
|
ParameterSetName="ByID"
|
||||||
)]
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$Slaves,
|
$Slaves,
|
||||||
[parameter(
|
[parameter(
|
||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
ParameterSetName="ByID"
|
ParameterSetName="ByID"
|
||||||
)]
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
|
|||||||
@@ -1,4 +1,51 @@
|
|||||||
function New-Address {
|
function New-Address {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Creates address object.
|
||||||
|
|
||||||
|
.PARAMETER SubnetId
|
||||||
|
Id of subnet address belongs to.
|
||||||
|
|
||||||
|
.PARAMETER Ip
|
||||||
|
IP address.
|
||||||
|
|
||||||
|
.PARAMETER Gateway
|
||||||
|
Defines if address is presented as gateway.
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Address description.
|
||||||
|
|
||||||
|
.PARAMETER Hostname
|
||||||
|
Address hostname.
|
||||||
|
|
||||||
|
.PARAMETER MAC
|
||||||
|
Mac address.
|
||||||
|
|
||||||
|
.PARAMETER Owner
|
||||||
|
Address owner.
|
||||||
|
|
||||||
|
.PARAMETER TagId
|
||||||
|
Id of subnet address belongs to.
|
||||||
|
|
||||||
|
.PARAMETER PTRIgnore
|
||||||
|
Controls if PTR should not be created.
|
||||||
|
|
||||||
|
.PARAMETER PTRId
|
||||||
|
Id of PowerDNS PTR record.
|
||||||
|
|
||||||
|
.PARAMETER Note
|
||||||
|
Note.
|
||||||
|
|
||||||
|
.PARAMETER ExcludePing
|
||||||
|
Exclude this address from status update scans (ping).
|
||||||
|
|
||||||
|
.PARAMETER DeviceId
|
||||||
|
Id of device address belongs to.
|
||||||
|
|
||||||
|
.PARAMETER Port
|
||||||
|
Port.
|
||||||
|
#>
|
||||||
[OutputType([PS.IPAM.address])]
|
[OutputType([PS.IPAM.address])]
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
@@ -6,7 +53,6 @@ function New-Address {
|
|||||||
Mandatory=$true,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Id of subnet address belongs to",
|
|
||||||
Position=0)]
|
Position=0)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
@@ -15,7 +61,6 @@ function New-Address {
|
|||||||
Mandatory=$true,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="IP address",
|
|
||||||
Position=1)]
|
Position=1)]
|
||||||
[ValidateScript({[ipaddress] $_ })]
|
[ValidateScript({[ipaddress] $_ })]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
@@ -25,7 +70,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Defines if address is presented as gateway",
|
|
||||||
Position=2)]
|
Position=2)]
|
||||||
[switch]
|
[switch]
|
||||||
$Gateway,
|
$Gateway,
|
||||||
@@ -33,7 +77,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Address description",
|
|
||||||
Position=3)]
|
Position=3)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -42,7 +85,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Address hostname",
|
|
||||||
Position=4)]
|
Position=4)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -51,7 +93,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Mac address",
|
|
||||||
Position=5)]
|
Position=5)]
|
||||||
[ValidateScript({ $_.Replace(":","") -match "^$('([A-F0-9]{2})' * 6)$" })]
|
[ValidateScript({ $_.Replace(":","") -match "^$('([A-F0-9]{2})' * 6)$" })]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
@@ -61,7 +102,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Address owner",
|
|
||||||
Position=6)]
|
Position=6)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -70,7 +110,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Id of subnet address belongs to",
|
|
||||||
Position=7)]
|
Position=7)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
@@ -79,7 +118,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Controls if PTR should not be created",
|
|
||||||
Position=8)]
|
Position=8)]
|
||||||
[switch]
|
[switch]
|
||||||
$PTRIgnore,
|
$PTRIgnore,
|
||||||
@@ -87,7 +125,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Id of PowerDNS PTR record",
|
|
||||||
Position=7)]
|
Position=7)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
@@ -96,7 +133,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Note",
|
|
||||||
Position=10)]
|
Position=10)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -105,7 +141,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Exclude this address from status update scans (ping)",
|
|
||||||
Position=11)]
|
Position=11)]
|
||||||
[switch]
|
[switch]
|
||||||
$ExcludePing,
|
$ExcludePing,
|
||||||
@@ -113,7 +148,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Id of device address belongs to",
|
|
||||||
Position=12)]
|
Position=12)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
@@ -122,7 +156,6 @@ function New-Address {
|
|||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
HelpMessage="Port",
|
|
||||||
Position=13)]
|
Position=13)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
@@ -130,7 +163,8 @@ function New-Address {
|
|||||||
[parameter(
|
[parameter(
|
||||||
Mandatory=$false,
|
Mandatory=$false,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=14
|
||||||
)]
|
)]
|
||||||
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
||||||
$CustomFields
|
$CustomFields
|
||||||
@@ -168,10 +202,9 @@ function New-Address {
|
|||||||
|
|
||||||
$_params.Add("Params",$_body)
|
$_params.Add("Params",$_body)
|
||||||
|
|
||||||
try {
|
$_result = Invoke-Request @_params
|
||||||
Invoke-Request @_params
|
|
||||||
}
|
if ($_result) {
|
||||||
finally {
|
|
||||||
Get-Address -SubnetId $SubnetId -Ip $Ip
|
Get-Address -SubnetId $SubnetId -Ip $Ip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user