@@ -152,6 +152,8 @@ Function New-NSXTSegment {
|
|||||||
This cmdlet creates a new NSX-T Segment (Logical Networks)
|
This cmdlet creates a new NSX-T Segment (Logical Networks)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-NSXTSegment -Name "sddc-cgw-network-4" -Gateway "192.168.4.1/24" -DHCP -DHCPRange "192.168.4.2-192.168.4.254"
|
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
|
.EXAMPLE
|
||||||
New-NSXTSegment -Name "sddc-cgw-network-5" -Gateway "192.168.5.1/24"
|
New-NSXTSegment -Name "sddc-cgw-network-5" -Gateway "192.168.5.1/24"
|
||||||
#>
|
#>
|
||||||
@@ -159,6 +161,7 @@ Function New-NSXTSegment {
|
|||||||
[Parameter(Mandatory=$True)]$Name,
|
[Parameter(Mandatory=$True)]$Name,
|
||||||
[Parameter(Mandatory=$True)]$Gateway,
|
[Parameter(Mandatory=$True)]$Gateway,
|
||||||
[Parameter(Mandatory=$False)]$DHCPRange,
|
[Parameter(Mandatory=$False)]$DHCPRange,
|
||||||
|
[Parameter(Mandatory=$False)]$DomainName,
|
||||||
[Switch]$DHCP,
|
[Switch]$DHCP,
|
||||||
[Switch]$Troubleshoot
|
[Switch]$Troubleshoot
|
||||||
)
|
)
|
||||||
@@ -179,6 +182,11 @@ Function New-NSXTSegment {
|
|||||||
display_name = $Name;
|
display_name = $Name;
|
||||||
subnets = @($subnets)
|
subnets = @($subnets)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($DomainName) {
|
||||||
|
$payload.domain_name = $DomainName
|
||||||
|
}
|
||||||
|
|
||||||
$body = $payload | ConvertTo-Json -depth 4
|
$body = $payload | ConvertTo-Json -depth 4
|
||||||
|
|
||||||
$method = "PUT"
|
$method = "PUT"
|
||||||
@@ -469,7 +477,7 @@ Function New-NSXTFirewall {
|
|||||||
[Parameter(Mandatory=$False)]$SourceGroup,
|
[Parameter(Mandatory=$False)]$SourceGroup,
|
||||||
[Parameter(Mandatory=$False)]$DestinationGroup,
|
[Parameter(Mandatory=$False)]$DestinationGroup,
|
||||||
[Parameter(Mandatory=$True)]$Service,
|
[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)]$InfraScope,
|
||||||
[Parameter(Mandatory=$false)]$SourceInfraGroup,
|
[Parameter(Mandatory=$false)]$SourceInfraGroup,
|
||||||
[Parameter(Mandatory=$false)]$DestinationInfraGroup,
|
[Parameter(Mandatory=$false)]$DestinationInfraGroup,
|
||||||
@@ -746,18 +754,46 @@ Function New-NSXTGroup {
|
|||||||
This cmdlet creates a new NSX-T Firewall Rule on MGW or CGW
|
This cmdlet creates a new NSX-T Firewall Rule on MGW or CGW
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-NSXTGroup -GatewayType MGW -Name Foo -IPAddress @("172.31.0.0/24")
|
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 (
|
Param (
|
||||||
[Parameter(Mandatory=$True)]$Name,
|
[Parameter(Mandatory=$True)]$Name,
|
||||||
[Parameter(Mandatory=$true)][ValidateSet("MGW","CGW")][String]$GatewayType,
|
[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
|
[Switch]$Troubleshoot
|
||||||
)
|
)
|
||||||
|
|
||||||
If (-Not $global:nsxtProxyConnection) { Write-error "No NSX-T Proxy Connection found, please use Connect-NSXTProxy" } Else {
|
If (-Not $global:nsxtProxyConnection) { Write-error "No NSX-T Proxy Connection found, please use Connect-NSXTProxy" } Else {
|
||||||
$expression = @{
|
if ($PSCmdlet.ParameterSetName -eq 'Tag') {
|
||||||
resource_type = "IPAddressExpression";
|
$expression = @{
|
||||||
ip_addresses = $IPAddress;
|
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 = @{
|
$payload = @{
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ function Set-Title
|
|||||||
$pcliModule = Get-Module -Name VMware.PowerCLI -ListAvailable |
|
$pcliModule = Get-Module -Name VMware.PowerCLI -ListAvailable |
|
||||||
Sort-Object -Property Version -Descending |
|
Sort-Object -Property Version -Descending |
|
||||||
Select-Object -First 1
|
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
|
# If git is present and if in a git controlled folder, display repositoryname/current_branch
|
||||||
$gitStr = ''
|
$gitStr = ''
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created by: Alan Renouf
|
Created by: Alan Renouf
|
||||||
Organization: VMware
|
Organization: VMware
|
||||||
Blog: http://virtu-al.net
|
Blog: http://virtu-al.net
|
||||||
Twitter: @alanrenouf
|
Twitter: @alanrenouf
|
||||||
===========================================================================
|
===========================================================================
|
||||||
#>
|
#>
|
||||||
|
|
||||||
Foreach ($vmhost in Get-VMHost) {
|
Foreach ($vmhost in Get-VMHost) {
|
||||||
|
|||||||
63
Scripts/Set-ClusterDpm.ps1
Normal file
63
Scripts/Set-ClusterDpm.ps1
Normal file
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user