diff --git a/classlib/class/domain.cs b/classlib/class/domain.cs index 36b8530..dc8a184 100644 --- a/classlib/class/domain.cs +++ b/classlib/class/domain.cs @@ -14,10 +14,10 @@ public class Domain { string description, string sections ) { - this.Id = id; - this.Name = name; + this.Id = id; + this.Name = name; this.Description = description; - this.Sections = sections; + this.Sections = sections; } public override string ToString() diff --git a/classlib/class/nameserver.cs b/classlib/class/nameserver.cs new file mode 100644 index 0000000..77962b5 --- /dev/null +++ b/classlib/class/nameserver.cs @@ -0,0 +1,25 @@ +namespace PS.IPAM; +using System; + +[Serializable] +public class Nameserver { + public int Id { get; } + public string Name { get; } + public string[] NameSevers { get; } + public string Permissions { get; } + public DateTime? EditDate { get; } + + public Nameserver( + int id, + string name, + string nameServers, + string permissions, + DateTime? editDate + ) { + this.Id = id; + this.Name = name; + this.NameSevers = nameServers.Split(';'); + this.Permissions = permissions; + this.EditDate = editDate; + } +} \ No newline at end of file diff --git a/classlib/class/section.cs b/classlib/class/section.cs index c8589a7..28022d1 100644 --- a/classlib/class/section.cs +++ b/classlib/class/section.cs @@ -34,20 +34,20 @@ public class Section { bool showSupernetOnly, int dnsId ) { - this.Id = id; - this.Name = name; - this.Description = description; - this.MasterSectionId = masterSectionId; - this.Permissions = permissions; - this.StrictMode = strictMode; - this.SubnetOrdering = subnetOrdering; - this.Order = order; - this.EditDate = editDate; - this.ShowSubnet = showSubnet; - this.ShowVlan = showVlan; - this.ShowVRF = showVRF; + this.Id = id; + this.Name = name; + this.Description = description; + this.MasterSectionId = masterSectionId; + this.Permissions = permissions; + this.StrictMode = strictMode; + this.SubnetOrdering = subnetOrdering; + this.Order = order; + this.EditDate = editDate; + this.ShowSubnet = showSubnet; + this.ShowVlan = showVlan; + this.ShowVRF = showVRF; this.ShowSupernetOnly = showSupernetOnly; - this.DNSId = dnsId; + this.DNSId = dnsId; } public override string ToString() diff --git a/classlib/class/session.cs b/classlib/class/session.cs index 774d011..5387361 100644 --- a/classlib/class/session.cs +++ b/classlib/class/session.cs @@ -17,11 +17,11 @@ public class Session { DateTime? expires, Object? credentials ) { - AuthType = authType; - Token = token; - AppID = appId; - URL = url; - Expires = expires; + AuthType = authType; + Token = token; + AppID = appId; + URL = url; + Expires = expires; Credentials = credentials; } diff --git a/classlib/class/subnet.cs b/classlib/class/subnet.cs index 45cdf2a..9785ff3 100644 --- a/classlib/class/subnet.cs +++ b/classlib/class/subnet.cs @@ -69,38 +69,38 @@ public class Subnetwork { Object calculation, Object? custom_fields ) { - this.Id = id; - this.Subnet = subnet; - this.Mask = mask; - this.SectionId = sectionId; - this.Description = description; - this.LinkedSubnet = linkedSubnet; + this.Id = id; + this.Subnet = subnet; + this.Mask = mask; + this.SectionId = sectionId; + this.Description = description; + this.LinkedSubnet = linkedSubnet; this.FirewallAddressObject = firewallAddressObject; - this.VrfId = vrfId; - this.MasterSubnetId = masterSubnetId; - this.AllowRequests = allowRequests; - this.VlanId = vlanId; - this.ShowName = showName; - this.DeviceId = deviceId; - this.Permissions = permissions; - this.PingSubnet = pingSubnet; - this.DiscoverSubnet = discoverSubnet; - this.ResolveDNS = resolveDNS; - this.DNSRecursive = dnsRecursive; - this.DNSRecords = dnsRecords; - this.NameserverId = nameserverId; - this.ScanAgent = scanAgent; - this.IsFolder = isFolder; - this.IsFull = isFull; - this.IsPool = isPool; - this.TagId = tagId; - this.Threshold = threshold; - this.LocationId = locationId; - this.EditDate = editDate; - this.LastScan = lastScan; - this.LastDiscovery = lastDiscovery; - this.Calculation = calculation; - this.ExtendedData = custom_fields; + this.VrfId = vrfId; + this.MasterSubnetId = masterSubnetId; + this.AllowRequests = allowRequests; + this.VlanId = vlanId; + this.ShowName = showName; + this.DeviceId = deviceId; + this.Permissions = permissions; + this.PingSubnet = pingSubnet; + this.DiscoverSubnet = discoverSubnet; + this.ResolveDNS = resolveDNS; + this.DNSRecursive = dnsRecursive; + this.DNSRecords = dnsRecords; + this.NameserverId = nameserverId; + this.ScanAgent = scanAgent; + this.IsFolder = isFolder; + this.IsFull = isFull; + this.IsPool = isPool; + this.TagId = tagId; + this.Threshold = threshold; + this.LocationId = locationId; + this.EditDate = editDate; + this.LastScan = lastScan; + this.LastDiscovery = lastDiscovery; + this.Calculation = calculation; + this.ExtendedData = custom_fields; } public string GetCIDR() { diff --git a/classlib/class/vlan.cs b/classlib/class/vlan.cs index 77ddb50..342726b 100644 --- a/classlib/class/vlan.cs +++ b/classlib/class/vlan.cs @@ -22,13 +22,13 @@ public class Vlan : DynamicObject { int customer_id, Object? custom_fields ) { - this.Id = vlanId; - this.DomainId = domainId; - this.Name = name; - this.Number = number; - this.Description = description; - this.EditDate = editDate; - this.CustomerId = customer_id; + this.Id = vlanId; + this.DomainId = domainId; + this.Name = name; + this.Number = number; + this.Description = description; + this.EditDate = editDate; + this.CustomerId = customer_id; this.ExtendedData = custom_fields; } diff --git a/classlib/class/vrf.cs b/classlib/class/vrf.cs index 92c2af9..2c426ac 100644 --- a/classlib/class/vrf.cs +++ b/classlib/class/vrf.cs @@ -20,13 +20,13 @@ public class Vrf { DateTime? editDate, Object? custom_fields ) { - this.Id = id; - this.Name = name; + this.Id = id; + this.Name = name; this.RouteDistinguisher = rd; - this.Description = description; - this.Sections = sections; - this.EditDate = editDate; - this.ExtendedData = custom_fields; + this.Description = description; + this.Sections = sections; + this.EditDate = editDate; + this.ExtendedData = custom_fields; } public override string ToString() { diff --git a/classlib/enum/types.cs b/classlib/enum/types.cs index 1dfaba1..6bc4a56 100644 --- a/classlib/enum/types.cs +++ b/classlib/enum/types.cs @@ -7,6 +7,7 @@ public enum types { Domain, Section, Subnetwork, + Nameserver, Tag, Vlan, Vrf diff --git a/functions/private/Invoke-Request.ps1 b/functions/private/Invoke-Request.ps1 index 2a81e66..3dc3d3c 100644 --- a/functions/private/Invoke-Request.ps1 +++ b/functions/private/Invoke-Request.ps1 @@ -26,11 +26,9 @@ function Invoke-Request { if ($_tokenStatus -eq "NoToken") { throw "No session available!" } if ($_tokenStatus -eq "Expired") { Update-Session } - $Controller = $Controller - $_uri = "$($script:psipamSession.URL)/api/$($script:psipamSession.AppID)/$Controller" - if ($SubController) { $_uri += "/$SubController" } - if ($Identifiers) { $_uri += "/$($Identifiers -join '/')/" } + if ($SubController -ne $null) { $SubController;$_uri += "/$SubController" } + if ($Identifiers -ne $null) { $_uri += "/$($Identifiers -join '/')/" } $_headers = @{ "Accept" = "application/json" @@ -60,42 +58,48 @@ function Invoke-Request { Write-Verbose -Message "Invoking web request to $($_uri), with method $($_arguments.Method), headers: $($_arguments.Headers)" - $_response = Invoke-RestMethod @_arguments - - if ($_response.code -match "20\d") { - if ($Type -is [PS.IPAM.types]) { - switch ($Type) { - "address" { - $_paramList = @("id","subnetId","ip","is_gateway","description","hostname","mac","owner","tag","deviceId","location","port","note","lastSeen","excludePing","PTRignore","PTR","firewallAddressObject","editDate","customer_id") - - $_response.data | ForEach-Object { - New-Object -TypeName ([PS.IPAM.Address]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) - }; break - } - "vlan" { - $_paramList = @("vlanId","domainId","name","number","description","editDate","customer_id","custom_fields") - - $_response.data | ForEach-Object { - New-Object -TypeName ([PS.IPAM.Vlan]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) - }; break - } - "subnetwork" { - $_response.data | ForEach-Object { - New-Object -TypeName ([PS.IPAM.Subnetwork]) -ArgumentList (@($_.psobject.properties.value[0..30]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) - }; break - } - "vrf" { - $_response.data | ForEach-Object { - New-Object -TypeName ([PS.IPAM.Vrf]) -ArgumentList (@($_.psobject.properties.value[0..5]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) - }; break - } - Default { $_response.data | ForEach-Object { New-Object -TypeName ("PS.IPAM.$Type") -ArgumentList $_.psobject.properties.value } } - } - - } else { - return $_response.data + try { + $_response = Invoke-RestMethod @_arguments + } + catch [System.Net.WebException] { + switch ($_.Exception.Message) { + "The remote server returned an error: (404) Not Found." { Write-Verbose -Message "Not found." } + "The remote server returned an error: (400) Bad Request." { Write-Warning -Message "Bad Request." } + Default { Write-Verbose -Message "Error occured while requesting api" } } + } + if (!$_response) { return $null } + + if ($Type -is [PS.IPAM.types]) { + switch ($Type) { + "address" { + $_paramList = @("id","subnetId","ip","is_gateway","description","hostname","mac","owner","tag","deviceId","location","port","note","lastSeen","excludePing","PTRignore","PTR","firewallAddressObject","editDate","customer_id") + + $_response.data | ForEach-Object { + New-Object -TypeName ([PS.IPAM.Address]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) + } + } + "vlan" { + $_paramList = @("vlanId","domainId","name","number","description","editDate","customer_id","custom_fields") + + $_response.data | ForEach-Object { + New-Object -TypeName ([PS.IPAM.Vlan]) -ArgumentList (@(($_ | Select-Object $_paramList).psobject.properties.value) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) + } + } + "subnetwork" { + $_response.data | ForEach-Object { + New-Object -TypeName ([PS.IPAM.Subnetwork]) -ArgumentList (@($_.psobject.properties.value[0..30]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) + } + } + "vrf" { + $_response.data | ForEach-Object { + New-Object -TypeName ([PS.IPAM.Vrf]) -ArgumentList (@($_.psobject.properties.value[0..5]) + ($_ | Select-Object -Property custom_* -ExcludeProperty 'custom_\*')) + } + } + Default { $_response.data | ForEach-Object { New-Object -TypeName ("PS.IPAM.$Type") -ArgumentList $_.psobject.properties.value } } + } + } else { - throw ("Error - $($_response.code)") + $_response.data } } \ No newline at end of file diff --git a/functions/public/Assign-Tag.ps1 b/functions/public/Assign-Tag.ps1 index 7b609ab..4b256b1 100644 --- a/functions/public/Assign-Tag.ps1 +++ b/functions/public/Assign-Tag.ps1 @@ -1,11 +1,27 @@ 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)] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0 + )] [ValidateNotNullOrEmpty()] [PS.IPAM.Address] $AddressObject, - [parameter(Mandatory=$true,Position=1)] + [parameter( + Mandatory=$true, + Position=1 + )] [ValidateNotNullOrEmpty()] [PS.IPAM.Tag] $Tag diff --git a/functions/public/Get-Address.ps1 b/functions/public/Get-Address.ps1 index ecaf22e..9874b20 100644 --- a/functions/public/Get-Address.ps1 +++ b/functions/public/Get-Address.ps1 @@ -2,28 +2,80 @@ function Get-Address { [CmdletBinding(DefaultParameterSetName="ByID")] [OutputType([PS.IPAM.address])] param ( - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByID" + )] [ValidateNotNullOrEmpty()] [int] $Id, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByIP")] - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="BySubnetId")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByIP" + )] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=1, + ParameterSetName="BySubnetId" + )] [ValidateNotNullOrEmpty()] [ipaddress] $IP, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByHostName")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByHostName" + )] [ValidateNotNullOrEmpty()] [string] $HostName, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByTag")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByHostBase" + )] + [ValidateNotNullOrEmpty()] + [string] + $HostBase, + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByTag" + )] [ValidateNotNullOrEmpty()] [int] $TagId, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetId")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="BySubnetId" + )] [ValidateNotNullOrEmpty()] [int] $SubnetId, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetCIDR")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="BySubnetCIDR" + )] [ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})] [ValidateNotNullOrEmpty()] [string] @@ -39,6 +91,7 @@ function Get-Address { "ByID" { $_identifiers = @($id); break } "ByIP" { $_identifiers = ("search",$IP); break } "ByHostName" { $_identifiers = ("search_hostname",$HostName); break } + "ByHostBase" { $_identifiers = ("search_hostbase",$HostBase); break } "ByTag" { $_identifiers = ("tags",$TagId,[PS.IPAM.controllers]::addresses); break } "BySubnetId" { if ($IP) { diff --git a/functions/public/Get-FirstFreeIP.ps1 b/functions/public/Get-FirstFreeIP.ps1 index daba78f..62f48c0 100644 --- a/functions/public/Get-FirstFreeIP.ps1 +++ b/functions/public/Get-FirstFreeIP.ps1 @@ -1,16 +1,34 @@ function Get-FirstFreeIP { [CmdletBinding(DefaultParameterSetName="ByID")] 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}"})] [ValidateNotNullOrEmpty()] [string] $CIDR, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByID" + )] [ValidateNotNullOrEmpty()] [int] $Id, - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="BySubnetObject" + )] [ValidateNotNullOrEmpty()] [PS.IPAM.Subnetwork] $SubnetObject diff --git a/functions/public/Get-L2Domain.ps1 b/functions/public/Get-L2Domain.ps1 index d97694b..3bad7fd 100644 --- a/functions/public/Get-L2Domain.ps1 +++ b/functions/public/Get-L2Domain.ps1 @@ -2,7 +2,13 @@ function Get-L2Domain { [CmdletBinding(DefaultParameterSetName="ByID")] [OutputType([PS.IPAM.Domain])] param ( - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByID" + )] [ValidateNotNullOrEmpty()] [int] $Id diff --git a/functions/public/Get-Nameserver.ps1 b/functions/public/Get-Nameserver.ps1 index 06fe325..34b4515 100644 --- a/functions/public/Get-Nameserver.ps1 +++ b/functions/public/Get-Nameserver.ps1 @@ -1,15 +1,18 @@ function Get-Nameserver { [CmdletBinding(DefaultParameterSetName="ByID")] param ( - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByID" + )] [ValidateNotNullOrEmpty()] [int] $Id ) process { - [string[]]$visiblePropertiesList = @('Id','Name','Address','Description') - $visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList) - $_params = @{ Controller = [PS.IPAM.controllers]::tools SubController = [PS.IPAM.subcontrollers]::nameservers @@ -21,8 +24,7 @@ function Get-Nameserver { $_identifiers = @($_nameserverId) $_params.Add("Identifiers",$_identifiers) - Invoke-Request @_params | Select-Object @{n="address";e={$_.namesrv1}},* | Select-Object -ExcludeProperty namesrv1 | ` - Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru + Invoke-Request @_params } } Export-ModuleMember -Function Get-Nameserver \ No newline at end of file diff --git a/functions/public/Get-Section.ps1 b/functions/public/Get-Section.ps1 index 16ae03c..1698a1f 100644 --- a/functions/public/Get-Section.ps1 +++ b/functions/public/Get-Section.ps1 @@ -2,11 +2,21 @@ function Get-Section { [CmdletBinding(DefaultParameterSetName="NoParams")] [OutputType([PS.IPAM.Section])] param ( - [parameter(Mandatory=$false,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + Position=0, + ParameterSetName="ByID" + )] [ValidateNotNullOrEmpty()] [int] $Id, - [parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByName")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + Position=0, + ParameterSetName="ByName" + )] [ValidateNotNullOrEmpty()] [string] $Name diff --git a/functions/public/Get-Tag.ps1 b/functions/public/Get-Tag.ps1 index 31fa28f..8fdd5b5 100644 --- a/functions/public/Get-Tag.ps1 +++ b/functions/public/Get-Tag.ps1 @@ -1,4 +1,13 @@ function Get-Tag { + <# + .SYNOPSIS + + Return address tag. + + .DESCRIPTION + + Return address tag by id, address object or subnetwork object. Or leave it empty at take all tags at once. + #> [CmdletBinding(DefaultParameterSetName="NoParams")] [OutputType([PS.IPAM.Tag])] param ( diff --git a/functions/public/Get-Vlan.ps1 b/functions/public/Get-Vlan.ps1 index a6aa22f..154a28e 100644 --- a/functions/public/Get-Vlan.ps1 +++ b/functions/public/Get-Vlan.ps1 @@ -1,8 +1,20 @@ function Get-Vlan { - [CmdletBinding(DefaultParameterSetName="ByID")] + <# + .SYNOPSIS + + Return vlan object. + + .DESCRIPTION + + Return vlan object by vlanId, vlan number, l2domainId (return all vlans in domain), subnet object or l2domain object + + .PARAMETER Number + Vlan tag + #> + [CmdletBinding(DefaultParameterSetName="NoParams")] [OutputType([PS.IPAM.Vlan])] param ( - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] + [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")] [ValidateNotNullOrEmpty()] [int] $Id, diff --git a/functions/public/New-Session.ps1 b/functions/public/New-Session.ps1 index 73fb82b..0c3d068 100644 --- a/functions/public/New-Session.ps1 +++ b/functions/public/New-Session.ps1 @@ -1,20 +1,72 @@ function New-Session { + <# + .SYNOPSIS + + Creates new session to phpIPAM instance. + + .DESCRIPTION + + Creates new session to phpIPAM instance by provided credentials or token. + + .PARAMETER URL + Base URL of phpIPAM instance. + Example - http://ipam.example.com + + .PARAMETER AppID + API id (specified in phpIPAM api settings) + + .PARAMETER Token + User token foor authorization + + .PARAMETER IgnoreSSL + Ignore SSL errors + + .OUTPUTS + None. New-Session does not generate any output. + #> [CmdletBinding(DefaultParameterSetName="Credentials")] param ( - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0 + )] [ValidateNotNullOrEmpty()] [validatescript({$_.startswith("http")})] [string]$URL, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1)] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=1 + )] [ValidateNotNullOrEmpty()] [string]$AppID, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="Credentials")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=2, + ParameterSetName="Credentials" + )] [ValidateNotNullOrEmpty()] [pscredential]$Credentials, - [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="Token")] + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=2, + ParameterSetName="Token" + )] [ValidateNotNullOrEmpty()] [string]$Token, - [parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=3)] + [parameter( + Mandatory=$false, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=3 + )] [switch]$IgnoreSSL = $false ) switch ($PSCmdlet.ParameterSetName) { diff --git a/functions/public/New-Subnet.ps1 b/functions/public/New-Subnet.ps1 index 3987f74..115d703 100644 --- a/functions/public/New-Subnet.ps1 +++ b/functions/public/New-Subnet.ps1 @@ -1,12 +1,7 @@ function New-Subnet { [CmdletBinding()] 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,HelpMessage="CIDR of subnet in dotted format (e.g 10.10.10.0/24)",Position=0)] [ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})] [ValidateNotNullOrEmpty()] [string] diff --git a/ps.ipam.psd1 b/ps.ipam.psd1 index d81187c..9441c1c 100644 Binary files a/ps.ipam.psd1 and b/ps.ipam.psd1 differ diff --git a/types/types.ps1xml b/types/types.ps1xml index a56619e..7acac0f 100644 --- a/types/types.ps1xml +++ b/types/types.ps1xml @@ -145,7 +145,7 @@ - ps.ipam.subnet + ps.ipam.subnetwork PSStandardMembers @@ -154,9 +154,10 @@ DefaultDisplayPropertySet Id - Name - DomainId - Number + Subnet + Mask + SectionId + Description