Initial commit
This commit is contained in:
33
functions/public/Get-PSIPAMSubnetUsage.ps1
Normal file
33
functions/public/Get-PSIPAMSubnetUsage.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
function Get-PSIPAMSubnetUsage {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
param (
|
||||
[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")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Id
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = "subnets"
|
||||
Method = "GET"
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByCIDR" {
|
||||
$_subnetId = (Get-PSIPAMSubnet -CIDR $CIDR).id
|
||||
if (!$_subnetId) { throw "Cannot find subnet!" }
|
||||
}
|
||||
"ByID" { $_subnetId = $Id }
|
||||
}
|
||||
$_identifiers = @($_subnetId,"usage")
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
return Invoke-PSIPAMRequest @_params
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function Get-PSIPAMSubnetUsage
|
||||
Reference in New Issue
Block a user