Add Remove-NSXTDistFirewallSection
This commit is contained in:
@@ -1185,6 +1185,60 @@ Function Get-NSXTDistFirewallSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Remove-NSXTDistFirewallSection {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: William Lam
|
||||||
|
Date: 04/20/2019
|
||||||
|
Organization: VMware
|
||||||
|
Blog: http://www.virtuallyghetto.com
|
||||||
|
Twitter: @lamw
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
.SYNOPSIS
|
||||||
|
Removes an NSX-T Distributed Firewall Section
|
||||||
|
.DESCRIPTION
|
||||||
|
This cmdlet removes an NSX-T Distributed Firewall Section
|
||||||
|
.EXAMPLE
|
||||||
|
Remove-NSXTDistFirewallSection -Id <ID> -Troubleshoot
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True)]$Id,
|
||||||
|
[Switch]$Troubleshoot
|
||||||
|
)
|
||||||
|
|
||||||
|
If (-Not $global:nsxtProxyConnection) { Write-error "No NSX-T Proxy Connection found, please use Connect-NSXTProxy" } Else {
|
||||||
|
$method = "DELETE"
|
||||||
|
$deleteDistFirewallSectioneURL = $global:nsxtProxyConnection.Server + "/policy/api/v1/infra/domains/cgw/communication-maps/$Id"
|
||||||
|
|
||||||
|
if($Troubleshoot) {
|
||||||
|
Write-Host -ForegroundColor cyan "`n[DEBUG] - $method`n$deleteDistFirewallSectioneURL`n"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if($PSVersionTable.PSEdition -eq "Core") {
|
||||||
|
$requests = Invoke-WebRequest -Uri $deleteDistFirewallSectioneURL -Method $method -Headers $global:nsxtProxyConnection.headers -SkipCertificateCheck
|
||||||
|
} else {
|
||||||
|
$requests = Invoke-WebRequest -Uri $deleteDistFirewallSectioneURL -Method $method -Headers $global:nsxtProxyConnection.headers
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
|
||||||
|
Write-Host -ForegroundColor Red "`nThe NSX-T Proxy session is no longer valid, please re-run the Connect-NSXTProxy cmdlet to retrieve a new token`n"
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
Write-Error "Error in removing NSX-T Distributed Firewall Section"
|
||||||
|
Write-Error "`n($_.Exception.Message)`n"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($requests.StatusCode -eq 200) {
|
||||||
|
Write-Host "Successfully removed NSX-T Distributed Firewall Section $Id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function Get-NSXTDistFirewall {
|
Function Get-NSXTDistFirewall {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
|
|||||||
Reference in New Issue
Block a user