Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 7a7e309

Browse files
author
Dale Coghlan
committed
update 1125
1 parent 98164dd commit 7a7e309

File tree

8 files changed

+366
-72
lines changed

8 files changed

+366
-72
lines changed

.DS_Store

8 KB
Binary file not shown.

doc/index.html

-1.32 MB
Binary file not shown.

module/platform/core/PowerNSX/PowerNSX.psd1

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Nick Bradford
55
#
6-
# Generated on: 20/08/2018
6+
# Generated on: 17/2/19
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'PowerNSX.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '3.0.1116'
15+
ModuleVersion = '3.0.1125'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -36,13 +36,13 @@ It aims to focus on exposing New, Update, Remove and Get operations for all key
3636
It is unlikely that it will ever expose 100% of the NSX API, but feature requests are welcomed if you find a particular function you require to be lacking.
3737
PowerNSX is currently a work in progress and is not yet feature complete.'
3838

39-
# Minimum version of the Windows PowerShell engine required by this module
39+
# Minimum version of the PowerShell engine required by this module
4040
PowerShellVersion = '3.0'
4141

42-
# Name of the Windows PowerShell host required by this module
42+
# Name of the PowerShell host required by this module
4343
# PowerShellHostName = ''
4444

45-
# Minimum version of the Windows PowerShell host required by this module
45+
# Minimum version of the PowerShell host required by this module
4646
# PowerShellHostVersion = ''
4747

4848
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
@@ -161,10 +161,10 @@ FunctionsToExport = 'Add-XmlElement', 'Format-Xml', 'Invoke-NsxRestMethod',
161161
'Get-NsxService', 'New-NsxService', 'Remove-NsxService',
162162
'Get-NsxFirewallSection', 'New-NsxFirewallSection',
163163
'Remove-NsxFirewallSection', 'Get-NsxFirewallRule',
164-
'New-NsxFirewallRule', 'Remove-NsxFirewallRule',
165-
'Get-NsxLoadBalancer', 'Set-NsxLoadBalancer',
166-
'Get-NsxLoadBalancerMonitor', 'New-NsxLoadBalancerMonitor',
167-
'Remove-NsxLoadBalancerMonitor',
164+
'New-NsxFirewallRule', 'Set-NsxFirewallRule',
165+
'Remove-NsxFirewallRule', 'Get-NsxLoadBalancer',
166+
'Set-NsxLoadBalancer', 'Get-NsxLoadBalancerMonitor',
167+
'New-NsxLoadBalancerMonitor', 'Remove-NsxLoadBalancerMonitor',
168168
'Get-NsxLoadBalancerApplicationProfile',
169169
'New-NsxLoadBalancerApplicationProfile',
170170
'Remove-NsxLoadBalancerApplicationProfile',

module/platform/core/PowerNSX/PowerNSX.psm1

+113-15
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ Function _init {
7979
$script:PNsxPSTarget = "Desktop"
8080
}
8181

82-
if ( ( $script:PNsxPSTarget -eq "Core" ) -and ( $PSVersionTable.GitCommitId -notmatch '^v6.[\d].[\d]+$') ) {
83-
84-
if ( $PSVersionTable.GitCommitId -ne 'v6.0.0-alpha.18') {
85-
write-warning "This build of PowerShell core has known issues that affect PowerNSX. The only recommended build of PowerShell Core at this stage is alpha-18."
86-
if ( $PSVersionTable.PSVersion -ne '6.0.0-alpha') {
87-
throw "The PowerShell Core Beta has known issues that cause PowerNSX to fail. Refusing to load module."
88-
}
89-
}
90-
}
91-
9282
## Define class required for certificate validation override. Version dependant.
9383
## For whatever reason, this does not work when contained within a function?
9484
$TrustAllCertsPolicy = @"
@@ -2214,8 +2204,8 @@ Function ValidateSecurityGroupMember {
22142204
}
22152205

22162206
#check if we are valid type
2217-
if ( ($argument -is [string]) -and ($argument -match "^vm-\d+$|^resgroup-\d+$|^dvportgroup-\d+$|^directory_group-\d+$" )) {
2218-
#argument is moref string and refers to vm, resource pool or dvportgroup.
2207+
if ( ($argument -is [string]) -and ($argument -match "^vm-\d+$|^resgroup-\d+$|^dvportgroup-\d+$|^directory_group-\d+$|^domain-c\d+$" )) {
2208+
#argument is moref string and refers to vm, resource pool, dvportgroup, directory group or cluster.
22192209
$true
22202210
}
22212211
elseif ( ($argument -is [string]) -and ( $NsxMemberTypes -contains ($argument -replace "-\d+$"))) {
@@ -23026,7 +23016,7 @@ function Add-NsxSecurityGroupMember {
2302623016
if ($_Member -is [System.Xml.XmlElement] ) {
2302723017
$MemberMoref = $_Member.objectId
2302823018
}
23029-
elseif ( ($_Member -is [string]) -and ($_Member -match "^vm-\d+$|^resgroup-\d+$|^dvportgroup-\d+$|^directory_group-\d+$" )) {
23019+
elseif ( ($_Member -is [string]) -and ($_Member -match "^vm-\d+$|^resgroup-\d+$|^dvportgroup-\d+$|^directory_group-\d+$|^domain-c\d+$" )) {
2303023020
$MemberMoref = $_Member
2303123021
}
2303223022
elseif ( ($_Member -is [string] ) -and ( [guid]::tryparse(($_Member -replace ".\d{3}$",""), [ref][guid]::Empty)) ) {
@@ -26651,9 +26641,17 @@ function Add-NsxServiceGroupMember {
2665126641
Group for specific or all Service Groups
2665226642

2665326643
.EXAMPLE
26654-
PS C:\> Get-NsxServiceGroup Heartbeat | Add-NsxServiceGroupMember -Member $Service1
26644+
$Service1 = Get-NsxService http -LocalOnly
26645+
PS C:\> Get-NsxServiceGroup SG_PowerNSX | Add-NsxServiceGroupMember -Member $Service1
2665526646

26656-
PS C:\> get-nsxservicegroup Service-Group-4 | Add-NsxServiceGroupMember $Service1,$Service2
26647+
Add service http to Service Group SG_PowerNSX
26648+
26649+
.EXAMPLE
26650+
$Service1 = Get-NsxService http -LocalOnly
26651+
PS C:\> $Service2 = Get-NsxService https -LocalOnly
26652+
PS C:\> Get-NsxServiceGroup SG_PowerNSX2 | Add-NsxServiceGroupMember $Service1, $Service2
26653+
26654+
Add service http and https to Service Group SG_PowerNSX2
2665726655

2665826656
#>
2665926657

@@ -27857,6 +27855,106 @@ function New-NsxFirewallRule {
2785727855
end {}
2785827856
}
2785927857

27858+
function Set-NsxFirewallRule {
27859+
27860+
<#
27861+
.SYNOPSIS
27862+
Set configuration for a NSX Distributed Firewall Rule.
27863+
27864+
.DESCRIPTION
27865+
An NSX Distributed Firewall Rule defines a typical 5 tuple rule and is
27866+
enforced on each hypervisor at the point where the VMs NIC connects to the
27867+
portgroup or logical switch.
27868+
27869+
This cmdlet accepts a firewall rule object returned from Get-NsxFirewallRule
27870+
and set configuration (disabled, name, action...)
27871+
27872+
.EXAMPLE
27873+
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -disabled:$true
27874+
27875+
Disabled the RuleId 1007
27876+
27877+
.EXAMPLE
27878+
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -logged:$true
27879+
27880+
Enable logging on the RuleId 1007
27881+
27882+
.EXAMPLE
27883+
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -name "My Distributed Firewall Rule"
27884+
27885+
Set/Update the description of the RuleId 1007
27886+
27887+
.EXAMPLE
27888+
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -action deny
27889+
27890+
Change action to deny to RuleId 1007
27891+
#>
27892+
27893+
param (
27894+
27895+
[Parameter (Mandatory=$true,ValueFromPipeline=$true)]
27896+
# DFW rule as returned by Get-NsxFirewallRule / New-NsxFirewallRule
27897+
[ValidateScript({ ValidateFirewallRule $_ })]
27898+
[System.Xml.XmlElement]$FirewallRule,
27899+
[Parameter (Mandatory=$false)]
27900+
[boolean]$disabled,
27901+
[Parameter (Mandatory=$false)]
27902+
[boolean]$logged,
27903+
[Parameter (Mandatory=$false)]
27904+
[ValidateNotNullOrEmpty()]
27905+
[string]$name,
27906+
[Parameter (Mandatory=$false)]
27907+
[ValidateSet("Allow","Deny", "Reject")]
27908+
[string]$action,
27909+
[Parameter (Mandatory=$false)]
27910+
#PowerNSX Connection object.
27911+
[ValidateNotNullOrEmpty()]
27912+
[PSCustomObject]$Connection=$defaultNSXConnection
27913+
)
27914+
27915+
begin {}
27916+
27917+
process {
27918+
27919+
$sectionId = $FirewallRule.ParentNode.Id
27920+
$RuleId = $FirewallRule.id
27921+
$generationNumber = $FirewallRule.ParentNode.generationnumber
27922+
27923+
#Clone the xml so we dont modify source...
27924+
$_FirewallRule = $FirewallRule.CloneNode($true)
27925+
27926+
if ( $PsBoundParameters.ContainsKey('disabled') ) {
27927+
$_FirewallRule.disabled = $disabled.ToString().ToLower()
27928+
}
27929+
27930+
if ( $PsBoundParameters.ContainsKey('logged') ) {
27931+
$_FirewallRule.logged = $logged.ToString().ToLower()
27932+
}
27933+
27934+
if ( $PsBoundParameters.ContainsKey('name') ) {
27935+
$_FirewallRule.name = $name
27936+
}
27937+
27938+
if ( $PsBoundParameters.ContainsKey('action') ) {
27939+
$_FirewallRule.action = $action
27940+
}
27941+
27942+
$uri = "/api/4.0/firewall/globalroot-0/config/layer3sections/$sectionId/rules/$Ruleid"
27943+
#Need the IfMatch header to specify the current section generation id
27944+
$IfMatchHeader = @{"If-Match"=$generationNumber}
27945+
try {
27946+
$response = Invoke-NsxWebRequest -method put -Uri $uri -body $_FirewallRule.OuterXml -extraheader $IfMatchHeader -connection $connection
27947+
[xml]$ruleElem = $response.Content
27948+
Get-NsxFirewallRule -RuleId $ruleElem.rule.id
27949+
}
27950+
catch {
27951+
throw "Failed to modify the specified rule. $_"
27952+
}
27953+
}
27954+
27955+
end {}
27956+
}
27957+
2786027958
function Remove-NsxFirewallRule {
2786127959

2786227960
<#

module/platform/desktop/PowerNSX/PowerNSX.psd1

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Nick Bradford
55
#
6-
# Generated on: 20/08/2018
6+
# Generated on: 17/2/19
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'PowerNSX.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '3.0.1116'
15+
ModuleVersion = '3.0.1125'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -36,13 +36,13 @@ It aims to focus on exposing New, Update, Remove and Get operations for all key
3636
It is unlikely that it will ever expose 100% of the NSX API, but feature requests are welcomed if you find a particular function you require to be lacking.
3737
PowerNSX is currently a work in progress and is not yet feature complete.'
3838

39-
# Minimum version of the Windows PowerShell engine required by this module
39+
# Minimum version of the PowerShell engine required by this module
4040
PowerShellVersion = '3.0'
4141

42-
# Name of the Windows PowerShell host required by this module
42+
# Name of the PowerShell host required by this module
4343
# PowerShellHostName = ''
4444

45-
# Minimum version of the Windows PowerShell host required by this module
45+
# Minimum version of the PowerShell host required by this module
4646
# PowerShellHostVersion = ''
4747

4848
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
@@ -161,10 +161,10 @@ FunctionsToExport = 'Add-XmlElement', 'Format-Xml', 'Invoke-NsxRestMethod',
161161
'Get-NsxService', 'New-NsxService', 'Remove-NsxService',
162162
'Get-NsxFirewallSection', 'New-NsxFirewallSection',
163163
'Remove-NsxFirewallSection', 'Get-NsxFirewallRule',
164-
'New-NsxFirewallRule', 'Remove-NsxFirewallRule',
165-
'Get-NsxLoadBalancer', 'Set-NsxLoadBalancer',
166-
'Get-NsxLoadBalancerMonitor', 'New-NsxLoadBalancerMonitor',
167-
'Remove-NsxLoadBalancerMonitor',
164+
'New-NsxFirewallRule', 'Set-NsxFirewallRule',
165+
'Remove-NsxFirewallRule', 'Get-NsxLoadBalancer',
166+
'Set-NsxLoadBalancer', 'Get-NsxLoadBalancerMonitor',
167+
'New-NsxLoadBalancerMonitor', 'Remove-NsxLoadBalancerMonitor',
168168
'Get-NsxLoadBalancerApplicationProfile',
169169
'New-NsxLoadBalancerApplicationProfile',
170170
'Remove-NsxLoadBalancerApplicationProfile',

0 commit comments

Comments
 (0)