Compare commits
13 Commits
ed9d648074
...
documentat
| Author | SHA1 | Date | |
|---|---|---|---|
| fb39efd493 | |||
| e45d2665fa | |||
| 2af591dbbf | |||
| 85e13dc150 | |||
| d1128997cc | |||
| bc645fc0d8 | |||
| ced1dde708 | |||
| bad183aff4 | |||
| e456d7affe | |||
|
|
4c128f5864 | ||
|
|
0913fc2069 | ||
| ea9b760933 | |||
| 833bb183eb |
@@ -5,7 +5,8 @@ using System;
|
|||||||
public class Nameserver {
|
public class Nameserver {
|
||||||
public int Id { get; }
|
public int Id { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public string[] NameSevers { get; }
|
public string[] NameServers { get; }
|
||||||
|
public string Description { get; }
|
||||||
public string Permissions { get; }
|
public string Permissions { get; }
|
||||||
public DateTime? EditDate { get; }
|
public DateTime? EditDate { get; }
|
||||||
|
|
||||||
@@ -13,12 +14,14 @@ public class Nameserver {
|
|||||||
int id,
|
int id,
|
||||||
string name,
|
string name,
|
||||||
string nameServers,
|
string nameServers,
|
||||||
|
string description,
|
||||||
string permissions,
|
string permissions,
|
||||||
DateTime? editDate
|
DateTime? editDate
|
||||||
) {
|
) {
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.NameSevers = nameServers.Split(';');
|
this.NameServers = nameServers.Split(new char[] {';'});
|
||||||
|
this.Description = description;
|
||||||
this.Permissions = permissions;
|
this.Permissions = permissions;
|
||||||
this.EditDate = editDate;
|
this.EditDate = editDate;
|
||||||
}
|
}
|
||||||
|
|||||||
21
functions/private/ConvertTo-Hashtable.ps1
Normal file
21
functions/private/ConvertTo-Hashtable.ps1
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
function ConvertTo-Hashtable {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[PSCustomObject]$InputObject
|
||||||
|
)
|
||||||
|
process {
|
||||||
|
$_hashtable = @{}
|
||||||
|
$InputObject | Get-Member -MemberType *Property | Where-Object {
|
||||||
|
$_hashtable.($_.name) = $CustomFields.($_.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output $_hashtable
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,22 +27,20 @@ function Invoke-Request {
|
|||||||
if ($_tokenStatus -eq "Expired") { Update-Session }
|
if ($_tokenStatus -eq "Expired") { Update-Session }
|
||||||
|
|
||||||
$_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller"
|
$_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller"
|
||||||
if ($SubController -ne $null) { $SubController;$_uri += "/$SubController" }
|
if ($null -ne $SubController) { $_uri += "/$SubController" }
|
||||||
if ($Identifiers -ne $null) { $_uri += "/$($Identifiers -join '/')/" }
|
if ($null -ne $Identifiers) { $_uri += "/$($Identifiers -join '/')/" }
|
||||||
|
|
||||||
$_headers = @{
|
$_headers = @{ }
|
||||||
"Accept" = "application/json"
|
|
||||||
"Content-Type" = "application/json"
|
|
||||||
}
|
|
||||||
switch ($script:psipamSession.AuthType) {
|
switch ($script:psipamSession.AuthType) {
|
||||||
"Credentials" { $_headers.Add("token", $script:psipamSession.Token) }
|
"Credentials" { $_headers.Add("token", $script:psipamSession.Token) }
|
||||||
"Token" { $_headers.Add("phpipam-token", $script:psipamSession.Token) }
|
"Token" { $_headers.Add("phpipam-token", $script:psipamSession.Token) }
|
||||||
}
|
}
|
||||||
|
|
||||||
$_arguments = @{
|
$_arguments = @{
|
||||||
Method = $Method
|
Method = $Method
|
||||||
Uri = $_uri
|
Uri = $_uri
|
||||||
Headers = $_headers
|
Headers = $_headers
|
||||||
|
ContentType = "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Method -eq "POST" -or $Method -eq "PATCH") {
|
if ($Method -eq "POST" -or $Method -eq "PATCH") {
|
||||||
|
|||||||
20
functions/public/Close-Session.ps1
Normal file
20
functions/public/Close-Session.ps1
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
function Close-Session {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Removes (revokes) token.
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
param()
|
||||||
|
process {
|
||||||
|
$_params = @{
|
||||||
|
Controller = [PS.IPAM.controllers]::user
|
||||||
|
Method = "DELETE"
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Request @_params
|
||||||
|
|
||||||
|
$script:psipamSession = $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Export-ModuleMember Close-Session
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
function Get-Address {
|
function Get-Address {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Returns address object.
|
||||||
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
[OutputType([PS.IPAM.address])]
|
[OutputType([PS.IPAM.address])]
|
||||||
param (
|
param (
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
function Get-Nameserver {
|
function Get-Nameserver {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
param (
|
param (
|
||||||
[parameter(
|
[parameter(
|
||||||
Mandatory=$false,
|
Mandatory=$true,
|
||||||
ValueFromPipeline=$true,
|
ValueFromPipeline=$true,
|
||||||
ValueFromPipelineByPropertyName=$true,
|
ValueFromPipelineByPropertyName=$true,
|
||||||
Position=0,
|
Position=0,
|
||||||
@@ -17,6 +17,7 @@ function Get-Nameserver {
|
|||||||
Controller = [PS.IPAM.controllers]::tools
|
Controller = [PS.IPAM.controllers]::tools
|
||||||
SubController = [PS.IPAM.subcontrollers]::nameservers
|
SubController = [PS.IPAM.subcontrollers]::nameservers
|
||||||
Method = "GET"
|
Method = "GET"
|
||||||
|
Type = [PS.IPAM.types]::nameserver
|
||||||
}
|
}
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
"ByID" { $_nameserverId = $Id; break }
|
"ByID" { $_nameserverId = $Id; break }
|
||||||
|
|||||||
@@ -2,47 +2,131 @@ function Get-Subnet {
|
|||||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Subnetwork])]
|
[OutputType([PS.IPAM.Subnetwork])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByCIDR")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
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()]
|
||||||
[string]
|
[string]
|
||||||
$CIDR,
|
$CIDR,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySectionId")]
|
[parameter(
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="ByVlanNumber")]
|
Mandatory=$true,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="ByVlanId")]
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySectionId"
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
|
ParameterSetName="ByVlanNumber"
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1,
|
||||||
|
ParameterSetName="ByVlanId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$SectionId,
|
$SectionId,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySectionName")]
|
[parameter(
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=3,ParameterSetName="ByVlanNumber")]
|
Mandatory=$true,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="ByVlanId")]
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySectionName"
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=3,
|
||||||
|
ParameterSetName="ByVlanNumber"
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
|
ParameterSetName="ByVlanId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$SectionName,
|
$SectionName,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVrfId")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByVrfId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VrfId,
|
$VrfId,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVlanId")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByVlanId"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VlanId,
|
$VlanId,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVlanNumber")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByVlanNumber"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VlanNumber,
|
$VlanNumber,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="ByVlanNumber")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1,
|
||||||
|
ParameterSetName="ByVlanNumber"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VlanDomainId,
|
$VlanDomainId,
|
||||||
[parameter(Mandatory=$false,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$Slaves,
|
$Slaves,
|
||||||
[parameter(Mandatory=$false,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$Recurse
|
$Recurse
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,20 +1,31 @@
|
|||||||
function Get-SubnetUsage {
|
function Get-SubnetUsage {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByCIDR")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
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()]
|
||||||
[string]
|
[string]
|
||||||
$CIDR,
|
$CIDR,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
[ValidateScript({ $_ -match "^\d+$" })]
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[int]
|
||||||
$Id
|
$Id
|
||||||
)
|
)
|
||||||
process {
|
process {
|
||||||
$_params = @{
|
$_params = @{
|
||||||
Controller = "subnets"
|
Controller = [ps.ipam.controllers]::subnets
|
||||||
Method = "GET"
|
Method = "GET"
|
||||||
}
|
}
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
|||||||
@@ -11,15 +11,33 @@ function Get-Tag {
|
|||||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Tag])]
|
[OutputType([PS.IPAM.Tag])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByAddressObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Address]
|
[PS.IPAM.Address]
|
||||||
$AddressObject,
|
$AddressObject,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySubnetObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Subnetwork]
|
[PS.IPAM.Subnetwork]
|
||||||
$SubnetObject
|
$SubnetObject
|
||||||
|
|||||||
@@ -14,23 +14,53 @@ function Get-Vlan {
|
|||||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Vlan])]
|
[OutputType([PS.IPAM.Vlan])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByNumber")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByNumber"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Number,
|
$Number,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByL2Domain")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByL2Domain"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$L2DomainId,
|
$L2DomainId,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="BySubnetObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Subnetwork]
|
[PS.IPAM.Subnetwork]
|
||||||
$SubnetObject,
|
$SubnetObject,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByDomainObject")]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByDomainObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Domain]
|
[PS.IPAM.Domain]
|
||||||
$DomainObject
|
$DomainObject
|
||||||
|
|||||||
@@ -1,8 +1,23 @@
|
|||||||
function Get-Vrf {
|
function Get-Vrf {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Returns VRF object.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
Returns VRF by id. Or leave it empty to get all VRFs.
|
||||||
|
#>
|
||||||
|
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||||
[OutputType([PS.IPAM.Vrf])]
|
[OutputType([PS.IPAM.Vrf])]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id
|
$Id
|
||||||
|
|||||||
@@ -1,11 +1,58 @@
|
|||||||
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])]
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[parameter(
|
[parameter(
|
||||||
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]
|
||||||
@@ -14,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()]
|
||||||
@@ -24,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,
|
||||||
@@ -32,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]
|
||||||
@@ -41,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]
|
||||||
@@ -50,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()]
|
||||||
@@ -60,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]
|
||||||
@@ -69,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]
|
||||||
@@ -78,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,
|
||||||
@@ -86,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]
|
||||||
@@ -95,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]
|
||||||
@@ -104,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,
|
||||||
@@ -112,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]
|
||||||
@@ -121,13 +156,16 @@ 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]
|
||||||
$Port,
|
$Port,
|
||||||
|
[parameter(
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=14
|
||||||
|
)]
|
||||||
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
||||||
$CustomFields
|
$CustomFields
|
||||||
)
|
)
|
||||||
@@ -156,10 +194,7 @@ function New-Address {
|
|||||||
|
|
||||||
if ($CustomFields) {
|
if ($CustomFields) {
|
||||||
if ($CustomFields -is [PSCustomObject]) {
|
if ($CustomFields -is [PSCustomObject]) {
|
||||||
$_customFields = @{};
|
$_customFields = ConvertTo-Hashtable -InputObject $CustomFields
|
||||||
$CustomFields | Get-Member -MemberType *Property | Where-Object {
|
|
||||||
$_customFields.($_.name) = $CustomFields.($_.name)
|
|
||||||
}
|
|
||||||
} else { $_customFields = $CustomFields }
|
} else { $_customFields = $CustomFields }
|
||||||
|
|
||||||
$_body = $_body + $_customFields
|
$_body = $_body + $_customFields
|
||||||
@@ -167,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,78 +1,225 @@
|
|||||||
function New-Subnet {
|
function New-Subnet {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Creates new subnetwork object.
|
||||||
|
|
||||||
|
.PARAMETER CIDR
|
||||||
|
CIDR of subnet in dotted format (e.g 10.10.10.0/24).
|
||||||
|
|
||||||
|
.PARAMETER SectionId
|
||||||
|
Section identifier.
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Subnet description.
|
||||||
|
|
||||||
|
.PARAMETER VlanId
|
||||||
|
Assigns subnet to VLAN.
|
||||||
|
|
||||||
|
.PARAMETER VrfId
|
||||||
|
Assigns subnet to VRF.
|
||||||
|
|
||||||
|
.PARAMETER MasterSubnetId
|
||||||
|
Master subnet id for nested subnet.
|
||||||
|
|
||||||
|
.PARAMETER NameserverId
|
||||||
|
Id of nameserver to attach to subnet.
|
||||||
|
|
||||||
|
.PARAMETER ShowName
|
||||||
|
Controls weather subnet is displayed as IP address or Name in subnets menu.
|
||||||
|
|
||||||
|
.PARAMETER DNSRecursive
|
||||||
|
Controls if PTR records should be created for subnet.
|
||||||
|
|
||||||
|
.PARAMETER DNSRecords
|
||||||
|
Controls weather hostname DNS records are displayed.
|
||||||
|
|
||||||
|
.PARAMETER AllowRequests
|
||||||
|
Controls if IP requests are allowed for subnet.
|
||||||
|
|
||||||
|
.PARAMETER ScanAgentId
|
||||||
|
Controls which scanagent to use for subnet (default id 1).
|
||||||
|
|
||||||
|
.PARAMETER DiscoverSubnet
|
||||||
|
Controls if new hosts should be discovered for new host scans.
|
||||||
|
|
||||||
|
.PARAMETER IsFull
|
||||||
|
Marks subnet as used.
|
||||||
|
|
||||||
|
.PARAMETER TagId
|
||||||
|
Assignes state (tag) to subnet (default: 1 Used).
|
||||||
|
|
||||||
|
.PARAMETER Threshold
|
||||||
|
Subnet threshold.
|
||||||
|
|
||||||
|
.PARAMETER LocationId
|
||||||
|
Location index.
|
||||||
|
#>
|
||||||
|
[OutputType([PS.IPAM.Subnetwork])]
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="CIDR of subnet in dotted format (e.g 10.10.10.0/24)",Position=0)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0
|
||||||
|
)]
|
||||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$CIDR,
|
$CIDR,
|
||||||
[parameter(Mandatory=$true,HelpMessage="Section identifier",Position=1)]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=1
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$SectionId,
|
$SectionId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Subnet description",Position=2)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=2
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Description,
|
$Description,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="Assigns subnet to VLAN",Position=3)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=3
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VlanId,
|
$VlanId,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="Assigns subnet to VRF",Position=4)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=4
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$VrfId,
|
$VrfId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Master subnet id for nested subnet",Position=5)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=5
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$MasterSubnetId,
|
$MasterSubnetId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Id of nameserver to attach to subnet",Position=6)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=6
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$NameserverId,
|
$NameserverId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls weather subnet is displayed as IP address or Name in subnets menu",Position=7)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=7
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$ShowName,
|
$ShowName,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls if PTR records should be created for subnet",Position=8)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=8
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$DNSRecursive,
|
$DNSRecursive,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls weather hostname DNS records are displayed",Position=9)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=9
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$DNSRecords,
|
$DNSRecords,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls if IP requests are allowed for subnet",Position=10)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=10
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$AllowRequests,
|
$AllowRequests,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls which scanagent to use for subnet (default id 1)",Position=11)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=11
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$ScanAgentId,
|
$ScanAgentId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls if new hosts should be discovered for new host scans",Position=12)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=12
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$DiscoverSubnet,
|
$DiscoverSubnet,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Marks subnet as used",Position=12)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=12
|
||||||
|
)]
|
||||||
[switch]
|
[switch]
|
||||||
$IsFull,
|
$IsFull,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Assignes state (tag) to subnet (default: 1 Used)",Position=12)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=12
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$TagId,
|
$TagId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Subnet threshold",Position=13)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=13
|
||||||
|
)]
|
||||||
[ValidateScript({ $_ -le 100 -and $_ -ge 1 })]
|
[ValidateScript({ $_ -le 100 -and $_ -ge 1 })]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Threshold,
|
$Threshold,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Location index",Position=14)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=14
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$LocationId,
|
$LocationId,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=15
|
||||||
|
)]
|
||||||
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
$CustomFields
|
$CustomFields
|
||||||
)
|
)
|
||||||
process {
|
process {
|
||||||
$_params = @{
|
$_params = @{
|
||||||
Controller = "subnets"
|
Controller = [PS.IPAM.controllers]::subnets
|
||||||
Method = "POST"
|
Method = "POST"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +246,7 @@ function New-Subnet {
|
|||||||
|
|
||||||
if ($CustomFields) {
|
if ($CustomFields) {
|
||||||
if ($CustomFields -is [PSCustomObject]) {
|
if ($CustomFields -is [PSCustomObject]) {
|
||||||
$_customFields = @{};
|
$_customFields = ConvertTo-Hashtable -InputObject $CustomFields
|
||||||
$CustomFields | Get-Member -MemberType *Property | Where-Object {
|
|
||||||
$_customFields.($_.name) = $CustomFields.($_.name)
|
|
||||||
}
|
|
||||||
} else { $_customFields = $CustomFields }
|
} else { $_customFields = $CustomFields }
|
||||||
|
|
||||||
$_body = $_body + $_customFields
|
$_body = $_body + $_customFields
|
||||||
@@ -111,6 +255,7 @@ function New-Subnet {
|
|||||||
$_params.Add("Params",$_body)
|
$_params.Add("Params",$_body)
|
||||||
|
|
||||||
$_result = Invoke-Request @_params
|
$_result = Invoke-Request @_params
|
||||||
|
|
||||||
if ($_result) {
|
if ($_result) {
|
||||||
return Get-Subnet -CIDR $_result
|
return Get-Subnet -CIDR $_result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
function Remove-Address {
|
function Remove-Address {
|
||||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByID"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByAddressObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Address]
|
[PS.IPAM.Address]
|
||||||
$AddressObject
|
$AddressObject
|
||||||
|
|||||||
@@ -1,57 +1,140 @@
|
|||||||
function Set-Address {
|
function Set-Address {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Edit address object.
|
||||||
|
|
||||||
|
.PARAMETER Id
|
||||||
|
Id of subnet address belongs to.
|
||||||
|
|
||||||
|
.PARAMETER AddressObject
|
||||||
|
Address object to edit.
|
||||||
|
|
||||||
|
.PARAMETER Gateway
|
||||||
|
Defines if address is presented as gateway
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Address description.
|
||||||
|
#>
|
||||||
|
[OutputType([PS.IPAM.address])]
|
||||||
[CmdletBinding(DefaultParameterSetName="ById")]
|
[CmdletBinding(DefaultParameterSetName="ById")]
|
||||||
param (
|
param (
|
||||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="Id of subnet address belongs to",Position=0,ParameterSetName="ById")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ById"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$Id,
|
$Id,
|
||||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
[parameter(
|
||||||
|
Mandatory=$true,
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ByAddressObject"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PS.IPAM.Address]
|
[PS.IPAM.Address]
|
||||||
$AddressObject,
|
$AddressObject,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Defines if address is presented as gateway",Position=1)]
|
[parameter(
|
||||||
|
Position=1
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
ParameterSetName="ById"
|
||||||
|
)]
|
||||||
[bool]
|
[bool]
|
||||||
$Gateway,
|
$Gateway,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Address description",Position=2)]
|
[parameter(
|
||||||
|
Position=2
|
||||||
|
)]
|
||||||
|
[parameter(
|
||||||
|
ValueFromPipeline=$true,
|
||||||
|
ValueFromPipelineByPropertyName=$true,
|
||||||
|
ParameterSetName="ById"
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Description,
|
$Description,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Address hostname",Position=3)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Address hostname",
|
||||||
|
Position=3
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Hostname,
|
$Hostname,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Mac address",Position=4)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Mac address",
|
||||||
|
Position=4
|
||||||
|
)]
|
||||||
[ValidateScript({ $_.Replace(":","") -match "^$('([A-F0-9]{2})' * 6)$" })]
|
[ValidateScript({ $_.Replace(":","") -match "^$('([A-F0-9]{2})' * 6)$" })]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$MAC,
|
$MAC,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Address owner",Position=5)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Address owner",
|
||||||
|
Position=5
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Owner,
|
$Owner,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Id of subnet address belongs to",Position=6)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Id of subnet address belongs to",
|
||||||
|
Position=6
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$TagId,
|
$TagId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Controls if PTR should not be created",Position=7)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Controls if PTR should not be created",
|
||||||
|
Position=7
|
||||||
|
)]
|
||||||
[bool]
|
[bool]
|
||||||
$PTRIgnore,
|
$PTRIgnore,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Id of PowerDNS PTR record",Position=8)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Id of PowerDNS PTR record",
|
||||||
|
Position=8
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$PTRId,
|
$PTRId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Note",Position=9)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Note",
|
||||||
|
Position=9
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Note,
|
$Note,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Exclude this address from status update scans (ping)",Position=10)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Exclude this address from status update scans (ping)",
|
||||||
|
Position=10
|
||||||
|
)]
|
||||||
[bool]
|
[bool]
|
||||||
$ExcludePing,
|
$ExcludePing,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Id of device address belongs to",Position=11)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Id of device address belongs to",
|
||||||
|
Position=11
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[int]
|
[int]
|
||||||
$DeviceId,
|
$DeviceId,
|
||||||
[parameter(Mandatory=$false,HelpMessage="Port",Position=12)]
|
[parameter(
|
||||||
|
Mandatory=$false,
|
||||||
|
HelpMessage="Port",
|
||||||
|
Position=12
|
||||||
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]
|
[string]
|
||||||
$Port,
|
$Port,
|
||||||
@@ -103,7 +186,7 @@ function Set-Address {
|
|||||||
Invoke-Request @_params
|
Invoke-Request @_params
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Get-Address -Id $_id
|
Get-Address -id $_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
ps.ipam.psd1
BIN
ps.ipam.psd1
Binary file not shown.
@@ -170,4 +170,29 @@
|
|||||||
</MemberSet>
|
</MemberSet>
|
||||||
</Members>
|
</Members>
|
||||||
</Type>
|
</Type>
|
||||||
|
<Type>
|
||||||
|
<Name>ps.ipam.nameserver</Name>
|
||||||
|
<Members>
|
||||||
|
<MemberSet>
|
||||||
|
<Name>PSStandardMembers</Name>
|
||||||
|
<Members>
|
||||||
|
<PropertySet>
|
||||||
|
<Name>DefaultDisplayPropertySet</Name>
|
||||||
|
<ReferencedProperties>
|
||||||
|
<Name>Id</Name>
|
||||||
|
<Name>Name</Name>
|
||||||
|
<Name>NameServers</Name>
|
||||||
|
<Name>Description</Name>
|
||||||
|
</ReferencedProperties>
|
||||||
|
</PropertySet>
|
||||||
|
<PropertySet>
|
||||||
|
<Name>DefaultKeyPropertySet</Name>
|
||||||
|
<ReferencedProperties>
|
||||||
|
<Name>Id</Name>
|
||||||
|
</ReferencedProperties>
|
||||||
|
</PropertySet>
|
||||||
|
</Members>
|
||||||
|
</MemberSet>
|
||||||
|
</Members>
|
||||||
|
</Type>
|
||||||
</Types>
|
</Types>
|
||||||
Reference in New Issue
Block a user