Last active
September 29, 2017 15:04
-
-
Save tonysangha/2c26dc99bcb855e312f181690823dd40 to your computer and use it in GitHub Desktop.
One liners commands for PowerNSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Retrieve any rules that are configured with either block (deny) or reject in the NSX Distributed Firewall | |
Get-NsxFirewallSection | Get-NsxFirewallRule | ? {$_.action -eq "deny" -or $_.action -eq "reject"} | ft -autosize | |
# Retrieve services matching port number | |
get-nsxservice | ? {$_.element.value -eq "80"} | select name | |
# Compare NSX Services from two different NSX environments and list the differences based on name | |
# Not really a one liner I know | |
$old_services = Get-NsxService -Connection $old_env | |
$new_services = Get-NsxService -Connection $new_env | |
Compare-Object $old_services $new_services -Property name -PassThru | |
# Retrieve interface IP Addresses from all Logical Routers and display in shell | |
foreach($item in ($int = Get-NsxLogicalRouter | Get-NsxLogicalRouterInterface)){write-host $item.logicalRouterId, "|", $item.name, "|", $item.addressGroups.addressGroup.primaryAddress, "|", $item.addressGroups.addressGroup.subnetMask} | |
# Reverse the order of a PowerShell array. Useful for importing Firewall rules in the correct order | |
[array]::Reverse($array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment