From c506bf400aad8359e27cfa87cfd5ebff5f82c0f3 Mon Sep 17 00:00:00 2001 From: Sander <28297121+servisan@users.noreply.github.com> Date: Mon, 30 Sep 2019 21:12:56 +0200 Subject: [PATCH 1/7] Rearranged notes section Tabs and spaces cleaned up --- Scripts/NVME Info.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Scripts/NVME Info.ps1 b/Scripts/NVME Info.ps1 index 415b298..dd38a10 100644 --- a/Scripts/NVME Info.ps1 +++ b/Scripts/NVME Info.ps1 @@ -1,11 +1,11 @@ <# .NOTES =========================================================================== - Created by: Alan Renouf - Organization: VMware - Blog: http://virtu-al.net - Twitter: @alanrenouf - =========================================================================== + Created by: Alan Renouf + Organization: VMware + Blog: http://virtu-al.net + Twitter: @alanrenouf + =========================================================================== #> Foreach ($vmhost in Get-VMHost) { @@ -24,4 +24,4 @@ Foreach ($vmhost in Get-VMHost) { $esxcli.nvme.device.feature.$feature.get.Invoke($currentfeature) } } -} \ No newline at end of file +} From 1b7ea8034219008f6eff8072276b6ba2e020abb1 Mon Sep 17 00:00:00 2001 From: Doug Taliaferro Date: Fri, 11 Oct 2019 09:30:38 -0400 Subject: [PATCH 2/7] Create Set-ClusterDpm.ps1 Configures Distributed Power Managment (DPM) --- Scripts/Set-ClusterDpm.ps1 | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Scripts/Set-ClusterDpm.ps1 diff --git a/Scripts/Set-ClusterDpm.ps1 b/Scripts/Set-ClusterDpm.ps1 new file mode 100644 index 0000000..82292c2 --- /dev/null +++ b/Scripts/Set-ClusterDpm.ps1 @@ -0,0 +1,63 @@ +<# +.NOTES + Script name: Set-ClusterDpm.ps1 + Created on: 10/10/2019 + Author: Doug Taliaferro, @virtually_doug + Description: Configures Distributed Power Management (DPM) on a cluster. + Dependencies: None known + + ===Tested Against Environment==== + vSphere Version: 6.7 + PowerCLI Version: 11.3.0 + PowerShell Version: 5.1 + OS Version: Windows 7, 10 + Keyword: Cluster, DPM +.SYNOPSIS + Configures Distributed Power Management (DPM). + +.DESCRIPTION + Enables/disables Distributed Power Management (DPM) for one or more clusters and optionally sets the automation level. + +.PARAMETER Clusters + Specifies the name of the cluster(s) you want to configure. + +.PARAMETER DpmEnabled + Indicates whether Distributed Power Management (DPM) should be enabled/disabled. + +.PARAMETER DpmAutomationLevel + Specifies the Distributed Power Management (DPM) automation level. The valid values are 'automated' and 'manual'. + +.EXAMPLE + Set-ClusterDpm -Cluster 'Cluster01' -DpmEnabled:$true + +.EXAMPLE + Get-Cluster | Set-ClusterDpm -DpmEnabled:$true -DpmAutomationLevel 'automated' +#> +[CmdletBinding()] +param ( + [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] + [Alias('Name')] + [string[]]$Clusters, + + [Parameter(Mandatory=$true)] + [bool]$DpmEnabled, + + [Parameter(Mandatory = $false)] + [ValidateSet('automated','manual')] + [string]$DpmAutomationLevel +) +Begin { + # Create a configuration spec + $spec = New-Object VMware.Vim.ClusterConfigSpecEx + $spec.dpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo + $spec.dpmConfig.enabled = $DpmEnabled + if ($DpmAutomationLevel) { + $spec.dpmConfig.defaultDpmBehavior = $DpmAutomationLevel + } +} +Process { + ForEach ($cluster in $Clusters) { + # Configure the cluster + (Get-Cluster $cluster).ExtensionData.ReconfigureComputeResource_Task($spec, $true) + } +} From ae16ef6e52059558691775930341dfcd07c7f49a Mon Sep 17 00:00:00 2001 From: Troy Lindsay Date: Fri, 25 Oct 2019 15:23:06 -0500 Subject: [PATCH 3/7] #320: Add DomainName param to New-NSXTSegment Allows end user to specify the DNS domain name for the network segment --- Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 index b8c9c9a..e74fc61 100644 --- a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 +++ b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 @@ -159,6 +159,7 @@ Function New-NSXTSegment { [Parameter(Mandatory=$True)]$Name, [Parameter(Mandatory=$True)]$Gateway, [Parameter(Mandatory=$False)]$DHCPRange, + [Parameter(Mandatory=$False)]$DomainName, [Switch]$DHCP, [Switch]$Troubleshoot ) @@ -179,6 +180,11 @@ Function New-NSXTSegment { display_name = $Name; subnets = @($subnets) } + + if($DomainName) { + $payload.domain_name = $DomainName + } + $body = $payload | ConvertTo-Json -depth 4 $method = "PUT" From 39a8539d978e64d72056138622cd8568c2853150 Mon Sep 17 00:00:00 2001 From: Troy Lindsay Date: Fri, 25 Oct 2019 16:26:26 -0500 Subject: [PATCH 4/7] #320: Add example for New-NSXTSegment -DomainName --- Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 index e74fc61..8e372a0 100644 --- a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 +++ b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 @@ -152,6 +152,8 @@ Function New-NSXTSegment { This cmdlet creates a new NSX-T Segment (Logical Networks) .EXAMPLE New-NSXTSegment -Name "sddc-cgw-network-4" -Gateway "192.168.4.1/24" -DHCP -DHCPRange "192.168.4.2-192.168.4.254" + .EXAMPLE + New-NSXTSegment -Name "sddc-cgw-network-4" -Gateway "192.168.4.1/24" -DHCP -DHCPRange "192.168.4.2-192.168.4.254" -DomainName 'vmc.local' .EXAMPLE New-NSXTSegment -Name "sddc-cgw-network-5" -Gateway "192.168.5.1/24" #> From 49c0b44beb3683b7394b22e280152b31c843837c Mon Sep 17 00:00:00 2001 From: Troy Lindsay Date: Fri, 25 Oct 2019 22:08:36 -0500 Subject: [PATCH 5/7] #322: New-NSXTFirewall fix action --- Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 index b8c9c9a..e250676 100644 --- a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 +++ b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 @@ -469,7 +469,7 @@ Function New-NSXTFirewall { [Parameter(Mandatory=$False)]$SourceGroup, [Parameter(Mandatory=$False)]$DestinationGroup, [Parameter(Mandatory=$True)]$Service, - [Parameter(Mandatory=$True)][ValidateSet("ALLOW","DENY")]$Action, + [Parameter(Mandatory=$True)][ValidateSet("ALLOW","DROP")]$Action, [Parameter(Mandatory=$false)]$InfraScope, [Parameter(Mandatory=$false)]$SourceInfraGroup, [Parameter(Mandatory=$false)]$DestinationInfraGroup, From 478d913779a404fb52faebfdf45654d2b722ee16 Mon Sep 17 00:00:00 2001 From: Troy Lindsay Date: Thu, 14 Nov 2019 10:44:55 -0600 Subject: [PATCH 6/7] #326: Add New-NSXTGroup matching support --- Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 index 6a55445..b48351b 100644 --- a/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 +++ b/Modules/VMware.VMC.NSXT/VMware.VMC.NSXT.psm1 @@ -754,18 +754,46 @@ Function New-NSXTGroup { This cmdlet creates a new NSX-T Firewall Rule on MGW or CGW .EXAMPLE New-NSXTGroup -GatewayType MGW -Name Foo -IPAddress @("172.31.0.0/24") + .EXAMPLE + New-NSXTGroup -GatewayType CGW -Name Foo -Tag Bar + .EXAMPLE + New-NSXTGroup -GatewayType CGW -Name Foo -VmName Bar -Operator CONTAINS + .EXAMPLE + New-NSXTGroup -GatewayType CGW -Name Foo -VmName Bar -Operator STARTSWITH #> + [CmdletBinding(DefaultParameterSetName = 'IPAddress')] Param ( [Parameter(Mandatory=$True)]$Name, [Parameter(Mandatory=$true)][ValidateSet("MGW","CGW")][String]$GatewayType, - [Parameter(Mandatory=$True)][String[]]$IPAddress, + [Parameter(Mandatory=$true, ParameterSetName='IPAddress')][String[]]$IPAddress, + [Parameter(Mandatory=$true, ParameterSetName='Tag')][String]$Tag, + [Parameter(Mandatory=$true, ParameterSetName='VmName')][String]$VmName, + [Parameter(Mandatory=$true, ParameterSetName='VmName')][ValidateSet('CONTAINS','STARTSWITH')][String]$Operator, [Switch]$Troubleshoot ) If (-Not $global:nsxtProxyConnection) { Write-error "No NSX-T Proxy Connection found, please use Connect-NSXTProxy" } Else { - $expression = @{ - resource_type = "IPAddressExpression"; - ip_addresses = $IPAddress; + if ($PSCmdlet.ParameterSetName -eq 'Tag') { + $expression = @{ + resource_type = 'Condition' + member_type = 'VirtualMachine' + value = $Tag + key = 'Tag' + operator = 'EQUALS' + } + } elseif ($PSCmdlet.ParameterSetName -eq 'VmName') { + $expression = @{ + resource_type = 'Condition' + member_type = 'VirtualMachine' + value = $VmName + key = 'Name' + operator = $Operator.ToUpper() + } + } else { + $expression = @{ + resource_type = "IPAddressExpression"; + ip_addresses = $IPAddress; + } } $payload = @{ From c1e181ea1152453527f73971c93921487c046146 Mon Sep 17 00:00:00 2001 From: LucD Date: Mon, 18 Nov 2019 13:34:04 +0100 Subject: [PATCH 7/7] On the off chance someone does not have PowerCLI installed Handle ToString() error when PCLI is not present Signed-off-by: Luc Dekens --- Scripts/At_Your_Fingertips/NewProfile.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/At_Your_Fingertips/NewProfile.ps1 b/Scripts/At_Your_Fingertips/NewProfile.ps1 index a4b9f8d..66ea5aa 100644 --- a/Scripts/At_Your_Fingertips/NewProfile.ps1 +++ b/Scripts/At_Your_Fingertips/NewProfile.ps1 @@ -89,7 +89,7 @@ function Set-Title $pcliModule = Get-Module -Name VMware.PowerCLI -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1 - $pcli = " - PCLI: $($pcliModule.Version.ToString())" + $pcli = " - PCLI: $(if($pcliModule){$pcliModule.Version.ToString()}else{'na'})" # If git is present and if in a git controlled folder, display repositoryname/current_branch $gitStr = ''