diff --git a/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlan.ps1 b/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlan.ps1 new file mode 100644 index 0000000..e49bda9 --- /dev/null +++ b/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlan.ps1 @@ -0,0 +1,69 @@ +<# +.SYNOPSIS + Get PhpIpam Vlan by vlan id +.DESCRIPTION + Get PhpIpam Vlan by vlan id +.EXAMPLE + PS C:\> New-PhpIpamVlan -Param @{"name"="vlan2"} + + id : 8 + name : vlan2 + description : + masterVlan : 0 + permissions : + strictMode : 1 + subnetOrdering : + order : + editDate : + showVLAN : 0 + showVRF : 0 + showSupernetOnly : 0 + DNS : + + # get vlan by vlan id + PS C:\> get-PhpIpamVlan 8 + + # specify -id to using explicitly ById ParameterSet + PS C:\> get-PhpIpamVlan -id 8 + + +.INPUTS + Inputs (if any) +.OUTPUTS + Output (if any) +.NOTES + General notes +#> +function Get-PhpIpamVlan { + [cmdletbinding()] + Param( + + [parameter( + Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + position = 0, + ParameterSetName = "ByID" + )] + [ValidateNotNullOrEmpty()] + [int]$ID + ) + + begin { + + } + process { + if ($PSCmdlet.ParameterSetName -eq 'ByID') { + $r=Invoke-PhpIpamExecute -method get -controller vlan -identifiers @($ID) + } + Resolve-PhpIpamExecuteResult -result $r + } + + end { + + } +} + +New-Alias -Name Get-PhpIpamVlanByVlanID -Value Get-PhpIpamVlan +new-alias -Name Get-PhpIpamVlanByID -Value Get-PhpIpamVlan +Export-ModuleMember -function Get-PhpIpamVlan -alias "Get-PhpIpamVlanByVlanID", "Get-PhpIpamVlanByID" diff --git a/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlans.ps1 b/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlans.ps1 new file mode 100644 index 0000000..ef6fc19 --- /dev/null +++ b/PSPHPIPAM/Functions/Public/Vlans/Get-PhpIpamVlans.ps1 @@ -0,0 +1,11 @@ +function Get-PhpIpamVlans{ + [cmdletbinding()] + param( + + ) + $r=Invoke-PhpIpamExecute -method get -controller vlans + Resolve-PhpIpamExecuteResult -result $r +} + +New-Alias -Name Get-PhpIpamAllVlans -Value Get-PhpIpamVlans +Export-ModuleMember -Function Get-PhpIpamVlans -Alias Get-PhpIpamAllVlans diff --git a/PSPHPIPAM/Functions/Public/Vlans/New-PhpIpamVlan.ps1 b/PSPHPIPAM/Functions/Public/Vlans/New-PhpIpamVlan.ps1 new file mode 100644 index 0000000..6df3b68 --- /dev/null +++ b/PSPHPIPAM/Functions/Public/Vlans/New-PhpIpamVlan.ps1 @@ -0,0 +1,43 @@ +<# +.SYNOPSIS + Creates new vlan +.DESCRIPTION + Creates new vlan +.EXAMPLE + PS C:\> New-PhpIpamVlan -Params @{number=2323;name="test"} + Create an vlan 2323 with name test +.INPUTS + Hashtable contains vlan infos +.OUTPUTS + Output (if any) +.NOTES + General notes +#> +function New-PhpIpamVlan { + + [cmdletBinding()] + Param( + [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] + [validateScript( { $_ -is [system.collections.hashtable] })] + $Params = @{ } + ) + begin { + + } + process { + $r = Invoke-PhpIpamExecute -method post -controller vlans -params $Params + + if ($r -and $r.success) { + if ($r.id) { + Get-PhpIpamVlanByID -id $r.id + } + } else { + Write-Error $r + } + } + end { + + } +} + +Export-ModuleMember -Function New-PhpIpamVlan diff --git a/PSPHPIPAM/Functions/Public/Vlans/Remove-PhpIpamVlan.ps1 b/PSPHPIPAM/Functions/Public/Vlans/Remove-PhpIpamVlan.ps1 new file mode 100644 index 0000000..9f862ce --- /dev/null +++ b/PSPHPIPAM/Functions/Public/Vlans/Remove-PhpIpamVlan.ps1 @@ -0,0 +1,45 @@ +<# +.SYNOPSIS + Remove PhpIpam Vlan +.DESCRIPTION + Remove PhpIpam Vlan +.EXAMPLE + PS C:\> Remove-PhpIpamVlan -ID 20 + +.INPUTS + Inputs (if any) +.OUTPUTS + Output (if any) +.NOTES + General notes +#> +function Remove-PhpIpamVlan{ + Param( + [parameter( + Mandatory=$true, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0, + ParameterSetName="ByID" + )] + [int]$ID + ) + BEGIN{ + + } + PROCESS{ + if($PSCmdlet.ParameterSetName -eq 'ByID'){ + $r=Invoke-PhpIpamExecute -method delete -controller vlan -params @{'id'=$id} + if($r -and $r.success){ + return $true + }else{ + return $false + } + } + } + END{ + + } +} + +Export-ModuleMember -Function Remove-PhpIpamVlan