License PowerCLI-Examples-Scripts repository under BSD-2 Clause (#462)

As part of the VMware open source program, we have to update this repository with the correct license and copyright information.
We add the BSD-2 Clause License for this repository.
We mark all source code provided by VMware with the Copyright notice under BSD-2 Clause license.

* Update repository license to BSD 2-Clause License

* Update Copyright
This commit is contained in:
dmilov
2021-06-07 09:58:47 +03:00
committed by GitHub
parent db68f439a3
commit fb641c8a1c
110 changed files with 1066 additions and 790 deletions

View File

@@ -1,42 +0,0 @@
# PowerCLI-Example-Scripts
VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT
Notice to User: This Technology Preview License Agreement (the “Agreement”) is a CONTRACT between you (either an individual or a single entity) (“you” or “Licensee”) and VMware, Inc. (“VMware”), which covers your use of the Technology Preview Software (as defined below). If you do not agree to the terms of this Agreement, then do not install or use the Technology Preview Software. By explicitly accepting this Agreement, however, or by installing, copying, downloading, accessing, or otherwise using the Technology Preview Software, you are acknowledging and agreeing to be bound by the following terms.
1. DEFINITIONS. (a) “Technology Preview Software” means the unreleased, concept version of VMwares software, in object form only, excluding any Open Source Software provided with the such software, and the media and Documentation provided by VMware to Licensee and for which Licensee is granted a use license pursuant to this Agreement. (b) “Documentation” means the printed and online written reference material furnished to Licensee in conjunction with the Technology Preview Software, including, without limitation, instructions, testing guidelines, and end user guides. (c) “Intellectual Property Rights” shall mean all intellectual property rights, including, without limitation, patent, copyright, trademark, and trade secret. (d) “Open Source Software” means various open source software components provided with the Technology Preview Software that are licensed to you under the terms of the applicable license agreements included with such open source software components or other materials for the Technology Preview Software. (e) “Updates” means a modification, error correction, bug fix, new release, or other update to or for the Technology Preview Software.
2. LICENSE GRANT, USE AND OWNERSHIP.
(a) Limited License. Subject to the terms and conditions of this Agreement, VMware grants to Licensee a non-exclusive, non-transferable license (without the right to sublicense) (i) to use the Technology Preview Software in accordance with the Documentation solely for purposes of internal testing and evaluation, (ii) to use the Documentation provided with the Technology Preview Software in support of Licensees authorized use of the Technology Preview Software, and (iii) to copy the Technology Preview Software for archival or backup purposes, provided that all titles and trademarks, copyright, and restricted rights notices are reproduced on such copies.
(b) Evaluation Feedback. The purpose of this limited license is the testing and evaluation of the Technology Preview Software as set forth above. In furtherance of this purpose, Licensee shall provide feedback to VMware concerning the functionality and performance of the Technology Preview Software from time to time as reasonably requested by VMware, including, without limitation, identifying potential errors and improvements. Licensee will provide the requested feedback in a manner that is convenient to Licensee subject to reasonable availability of Licensees personnel. Notwithstanding the foregoing, prior to Licensee disclosing to VMware any information under this Agreement that Licensee considers proprietary or confidential, Licensee shall obtain VMwares prior written approval to disclose such information to VMware, and without such prior written approval from VMware, Licensee shall not disclose any such information to VMware. VMware may use feedback to improve or enhance its products and, accordingly, you hereby grant to VMware a non-exclusive, perpetual, irrevocable, royalty-free, transferable, worldwide right and license, with the right to sublicense, to use, reproduce, disclose, distribute, perform, display, modify, prepare derivative works of and otherwise exploit the feedback and other information without restriction in any manner now known or in the future conceived and to make, use, sell, offer to sell, import and export any product or service that incorporates the feedback and other information.
(c) Restrictions. Licensee shall not copy or use the Technology Preview Software (including the Documentation) except as expressly permitted in this Agreement. Except to the extent that any applicable mandatory laws prevent VMware restraining Licensee from doing so, Licensee will not, and will not permit any third party to, sublicense, rent, copy, modify, create derivative works of, translate, reverse engineer, decompile, disassemble, or otherwise reduce to human perceivable form any portion of the Technology Preview Software or accompanying Documentation. Without limiting the generality of the foregoing, Licensee shall not use the Technology Preview Software for Licensees product development or any other commercial purpose. The Technology Preview Software and all performance data and test results, including without limitation, benchmark test results (collectively “Performance Data”) relating to the Technology Preview Software are the Confidential Information of VMware, and will be treated in accordance with the terms of Section 4 of this Agreement. Accordingly, Licensee shall not publish or disclose to any third party any Performance Data relating to the Technology Preview Software.
(d) Ownership. VMware shall own and retain all right, title and interest in and to the Intellectual Property Rights in the Technology Preview Software, subject only to the limited license expressly set forth in Section 2(a) hereof. Licensee does not acquire any other rights, express or implied, in the Technology Preview Software. ALL RIGHTS NOT EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.
(e) No Support Services. VMware is under no obligation to support the Technology Preview Software in any way or to provide any Updates to Licensee. In the event VMware, in its sole discretion, supplies any Update to Licensee, the Update shall be deemed Technology Preview Software under this Agreement and shall be subject to the terms and conditions of this Agreement.
(f) Third-Party Software. The Technology Preview Software may enable a computer to run multiple instances of third-party guest operating systems and application programs. Licensee acknowledges that Licensee is responsible for obtaining any licenses necessary to operate any third-party software, including guest operating systems and application programs.
(g) Open Source Software. Except for Sections 5, 6 and 7, the terms and conditions of this Agreement shall not apply to any Open Source Software accompanying the Technology Preview Software. Any such Open Source Software is provided under the terms of the open source license agreement or copyright notice accompanying such Open Source Software or in the open source licenses file accompanying the Technology Preview Software.
3. TERM AND TERMINATION. Licensees rights with respect to the Technology Preview Software will terminate upon the earlier of (a) automatic expiration of the Technology Preview Software based on the system date, or (b) termination by VMware, in its sole discretion, of Licensees rights with respect to the Technology Preview Software provided under this Agreement upon notice on the VMware website. Upon any expiration or termination of rights with respect to the Technology Preview Software under this Agreement, the rights and licenses granted to Licensee under this Agreement shall immediately terminate, and Licensee shall immediately cease using, and will destroy or render practically inaccessible the Technology Preview Software, Documentation, and all other tangible items in Licensees possession or control that contain Confidential Information. The rights and obligations of the parties set forth in Sections 2(b), 2(c), 2(d), 2(e), 2(f), 2(g), 3, 4, 5, 6 and 7 shall survive termination or expiration of this Agreement for any reason.
4. CONFIDENTIALITY. (a) Confidentiality. "Confidential Information" means the Technology Preview Software, all information regarding the Technology Preview Software (including any trade secrets, know-how, inventions, techniques, processes, and algorithms embodied in the Technology Preview Software), Documentation, Performance Data, any Updates, and other information provided by VMware to Licensee under this Agreement, whether disclosed orally, in writing, or by examination or inspection, other than information that Licensee can demonstrate (i) was already known to Licensee, other than under an obligation of confidentiality, at the time of disclosure; (ii) was generally available in the public domain at the time of disclosure to Licensee; (iii) became generally available in the public domain after disclosure other than through any act or omission of Licensee; (iv) was subsequently lawfully disclosed to Licensee by a third party without any obligation of confidentiality; or (v) was independently developed by Licensee without use of or reference to any information or materials disclosed by VMware or its suppliers. If Licensee is required to disclose Confidential Information by applicable law or court order, Licensee shall notify VMware of the required disclosure promptly in writing and shall cooperate with VMware in any lawful action to contest or limit the scope of the required disclosure. Confidential Information shall include, without limitation, any information relating to VMware products, product roadmaps, and other technical, business, financial and product development plans, forecasts and strategies. Licensee shall not use any Confidential Information for any purpose other than as expressly authorized under this Agreement. In no event shall Licensee use the Technology Preview Software or any Confidential Information to develop, manufacture, market, sell, or distribute any product or service, including any VMware products. Licensee shall not disclose any Confidential Information to any third party. Without limiting the foregoing, Licensee shall use at least the same degree of care that it uses to prevent the disclosure of its own confidential information of like importance, but in no event less than reasonable care, to prevent the disclosure of such Confidential Information. (b) Additional Confidentiality Restrictions for Highly Confidential Technology Preview Software. For certain Technology Preview Software designated by VMware as highly confidential (“Highly Confidential Technology Preview Software”) in VMwares correspondence to you regarding this Technology Preview Software or in any Documentation, additional heightened confidentiality restrictions designated below will apply. (i) Licensee shall limit dissemination of Highly Confidential Technology Preview Software and related information concerning product features, future technologies and roadmaps only to Information Technology teams and/or software/solutions development teams of Licensee designated by VMware, and only to individuals on those teams who have a need to know the Confidential Information for purposes expressly authorized under this Agreement. For clarity and without limiting the generality of the foregoing, Licensee shall not disseminate any Highly Confidential Technology Preview Software to Licensee's sales and marketing field organizations. Licensee will assign an employee who will be primarily responsible (“Primary Contact”) for ensuring that the terms of this Agreement are complied with. (ii) Licensee acknowledges that damages for improper disclosure of Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps may be irreparable and that monetary damages would be inadequate to compensate VMware for any breach of this Agreement. In the event that VMware reasonably believes that Licensee has disseminated certain of such Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps to an unauthorized party, Licensee will be immediately removed from VMwares Technology Preview Software program and will not be permitted to participate in any VMware Technology Preview Software program in the future. Additionally, all rights and licenses granted to Licensee under this Agreement shall immediately terminate in accordance with Section 3 herein (Term and Termination). (c) Remedies. In addition to all other remedies available in law or otherwise, VMware is entitled to seek equitable relief, including injunctive relief, against the threatened breach of this Agreement or the continuation of any such breach.
5. LIMITATION OF LIABILITY. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE IS PROVIDED WITHOUT CHARGE FOR LIMITED EVALUATION PURPOSES. ACCORDINGLY, THE TOTAL LIABILITY OF VMWARE AND ITS LICENSORS ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL NOT EXCEED US$100.00. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT SHALL VMWARE OR ITS LICENSORS HAVE LIABILITY FOR ANY INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY (INCLUDING WITHOUT LIMITATION, TORT, STATUTE, CONTRACT OR OTHER), EVEN IF VMWARE AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
6. WARRANTY DISCLAIMER. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE, OPEN SOURCE SOFTWARE, DOCUMENTATION, AND ANY UPDATES MAY CONTAIN ERRORS AND ARE PROVIDED FOR LIMITED EVALUATION ONLY. THE TECHNOLOGY PREVIEW SOFTWARE, THE OPEN SOURCE SOFTWARE, THE DOCUMENTATION, AND ANY UPDATES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. VMWARE AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. Licensee acknowledges that VMware has not publicly announced the availability of the Technology Preview Software, that such Technology Preview Software may contain features currently under development, that VMware has not promised or guaranteed to Licensee that such Technology Preview Software will be announced or made available to anyone in the future, that VMware has no express or implied obligation to Licensee to announce or introduce the Technology Preview Software, that VMware has no obligation to introduce a product similar to or compatible with the Technology Preview Software, and that any version number (if any) referenced is subject to change and does not in any way represent VMwares commitment to release any product in the future. Accordingly, Licensee acknowledges that any research or development that it performs regarding the Technology Preview Software or any product associated with the Technology Preview Software is done entirely at Licensees own risk. Specifically, the Technology Preview Software may contain features, functionality or modules that will not be included in the production version of the Technology Preview Software, if released, or that will be marketed separately for additional fees.
7. OTHER PROVISIONS. (a) Governing Law. This Agreement, and all disputes arising out of or related thereto, shall be governed by and construed under the laws of the State of California without reference to conflict of laws principles. All such disputes shall be subject to the exclusive jurisdiction of the state and federal courts located in Santa Clara County, California, and the parties agree and submit to the personal and exclusive jurisdiction and venue of these courts. The United Nations Convention for the International Sale of Goods shall not apply. (b) Export Control.  The Technology Preview Software is of United States origin and is provided subject to the U.S. Export Administration Regulations. Diversion contrary to U.S. law is prohibited. Without limiting the foregoing, you agree that (i) you are not, and are not acting on behalf of, any person who is a citizen, national, or resident of, or who is controlled by the government of, Cuba, Iran, North Korea, Sudan, or Syria, or any other country to which the United States has prohibited export transactions; (ii) you are not, and are not acting on behalf of, any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (iii) you will not use the Technology Preview Software for, and will not permit the Technology Preview Software to be used for, any purposes prohibited by law, including, without limitation, for any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. U.S. Export Control Classification Numbers (ECCNs) may be found at VMware help page: http://www.vmware.com/help/export-control. (c) Modification. This is the entire agreement between the parties relating to the subject matter hereof and all other terms are rejected. No waiver or modification of this Agreement shall be valid unless in writing signed by each party. The waiver of a breach of any term hereof shall in no way be construed as a waiver of any other term or breach hereof. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the remaining provisions of this Agreement shall remain in full force and effect. (d) Data Privacy. Licensee agrees that VMware may process technical and related usage information about Licensees use of the Technology Preview Software for statistical and analytical purposes. Usage information is collected strictly for internal statistical and analytical purposes for the development of VMware products and services. Licensee understands that any log files generated in order to obtain support from VMware may contain sensitive, confidential or personal information. Licensee should consider obfuscating any logs before sending them to VMware. VMwares privacy policy (http://www.vmware.com/help/privacy.html) shall apply.
8. ASSIGNMENT. Licensee shall not assign this Agreement or any rights or obligations hereunder, directly or indirectly, by operation of law, merger, acquisition of stock or assets, or otherwise, without the prior written consent of VMware. Any attempted assignment or transfer in violation of the foregoing will be null and void. Subject to the foregoing, this Agreement shall inure to the benefit of and be binding upon the parties and their respective successors and permitted assigns.
9. CONTACT INFORMATION. If you have any questions about this Agreement, please direct all correspondence to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. VMware is a trademark of VMware, Inc. and is registered in the U.S. and numerous other countries.
Rev. 2014Mar10

12
LICENSE.txt Normal file
View File

@@ -0,0 +1,12 @@
PowerCLI-Example-Scripts
Copyright 2021 VMware, Inc.
BSD 2-Clause License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Backup-VCSAToFile { Function Backup-VCSAToFile {
<# <#
.NOTES .NOTES

View File

@@ -1,4 +1,8 @@
Function Get-ContentLibrary { <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-ContentLibrary {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-XVCMStatus { Function Get-XVCMStatus {
<# <#
.NOTES .NOTES
@@ -12,7 +16,7 @@ Function Get-XVCMStatus {
.EXAMPLE .EXAMPLE
Get-XVCMStatus Get-XVCMStatus
#> #>
$Uri = "http://localhost:8080/api/status" #Updated for 2.0, Old: "http://localhost:8080/api/ping" $Uri = "http://localhost:8080/api/status" #Updated for 2.0, Old: "http://localhost:8080/api/ping"
$results = Invoke-WebRequest -Uri $Uri -Method GET -TimeoutSec 5 $results = Invoke-WebRequest -Uri $Uri -Method GET -TimeoutSec 5

View File

@@ -47,7 +47,7 @@ Function Get-HostViews {
} }
write-progress -activity "Collecting ESXi Host Views" -completed write-progress -activity "Collecting ESXi Host Views" -completed
$allHosts $allHosts
} }
} }
Function Get-DatastoreMountInfo { Function Get-DatastoreMountInfo {
@@ -74,7 +74,7 @@ Function Get-DatastoreMountInfo {
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?" Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
} }
$allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname} $allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname}
#Build the array of custom Host Objects #Build the array of custom Host Objects
$allHosts = Get-HostViews -datastore $allDatastores $allHosts = Get-HostViews -datastore $allDatastores
$output = @() $output = @()
@@ -89,9 +89,9 @@ Function Get-DatastoreMountInfo {
$thisDatastore = $alldatastores | ? {$_.ExtensionData.Info.vmfs.extent[0].diskname -eq $device.canonicalName} $thisDatastore = $alldatastores | ? {$_.ExtensionData.Info.vmfs.extent[0].diskname -eq $device.canonicalName}
$hostviewDSAttachState = "" $hostviewDSAttachState = ""
if ($device.operationalState[0] -eq "ok") { if ($device.operationalState[0] -eq "ok") {
$hostviewDSAttachState = "Attached" $hostviewDSAttachState = "Attached"
} elseif ($device.operationalState[0] -eq "off") { } elseif ($device.operationalState[0] -eq "off") {
$hostviewDSAttachState = "Detached" $hostviewDSAttachState = "Detached"
} else { } else {
$hostviewDSAttachState = $device.operationalstate[0] $hostviewDSAttachState = $device.operationalstate[0]
} }

View File

@@ -1,15 +1,15 @@
function Get-NICDetails { function Get-NICDetails {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2017.02 ver 1.0 Base Release 2017.02 ver 1.0 Base Release
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
- -
=========================================================================== ===========================================================================
Tested Against Environment: Tested Against Environment:
@@ -35,11 +35,11 @@
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[String] $Clustername [String] $Clustername
) )
Begin { Begin {
@@ -49,14 +49,14 @@ Begin {
$Validate = $False $Validate = $False
thow "No Cluster '$myCluster' found!" thow "No Cluster '$myCluster' found!"
} }
} }
Process { Process {
$MyView = @() $MyView = @()
if ($Validate -eq $True) { if ($Validate -eq $True) {
foreach ($myVMhost in ($myCluster | Get-VMHost)) { foreach ($myVMhost in ($myCluster | Get-VMHost)) {
$esxcli2 = Get-ESXCLI -VMHost $myVMhost -V2 $esxcli2 = Get-ESXCLI -VMHost $myVMhost -V2
@@ -85,7 +85,7 @@ Process {
} }
} }
$MyView $MyView
} }

View File

@@ -1,15 +1,15 @@
function Get-NewAndRemovedVMs { function Get-NewAndRemovedVMs {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.12 ver 1.0 Base Release 2016.12 ver 1.0 Base Release
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
https://github.com/alanrenouf/vCheck-vSphere https://github.com/alanrenouf/vCheck-vSphere
=========================================================================== ===========================================================================
Tested Against Environment: Tested Against Environment:
@@ -22,10 +22,10 @@ function Get-NewAndRemovedVMs {
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This Function report newly created and deleted VMs by Cluster. This Function report newly created and deleted VMs by Cluster.
.Example .Example
Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize
.Example .Example
Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90 Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90
@@ -51,7 +51,7 @@ param(
) )
Begin { Begin {
function Get-VIEventPlus { function Get-VIEventPlus {
param( param(
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity,
[string[]]$EventType, [string[]]$EventType,
@@ -117,7 +117,7 @@ Begin {
{ {
$events | % { $_.createdTime = $_.createdTime.ToLocalTime() } $events | % { $_.createdTime = $_.createdTime.ToLocalTime() }
} }
$events $events
} }
} }

View File

@@ -1,16 +1,16 @@
function Get-VMmaxIOPS { function Get-VMmaxIOPS {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.10 ver 1.0 Base Release 2016.10 ver 1.0 Base Release
2016.11 ver 1.1 Added vSphere 6.5 Support, New Counters, More Error Handling 2016.11 ver 1.1 Added vSphere 6.5 Support, New Counters, More Error Handling
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/ http://www.lucd.info/2011/04/22/get-the-maximum-iops/
https://communities.vmware.com/thread/485386 https://communities.vmware.com/thread/485386
=========================================================================== ===========================================================================
@@ -24,7 +24,7 @@ function Get-VMmaxIOPS {
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This Function will Create a VM Disk IOPS Report This Function will Create a VM Disk IOPS Report
.Example .Example
Get-VM TST* | Get-VMmaxIOPS -Minutes 60 | FT -Autosize Get-VM TST* | Get-VMmaxIOPS -Minutes 60 | FT -Autosize
@@ -34,17 +34,17 @@ function Get-VMmaxIOPS {
Get-VMmaxIOPS -VMs $SampleVMs -Minutes 60 Get-VMmaxIOPS -VMs $SampleVMs -Minutes 60
.PARAMETER VMs .PARAMETER VMs
Specify the VMs Specify the VMs
.PARAMETER Minutes .PARAMETER Minutes
Specify the Minutes to report (10080 is one Week) Specify the Minutes to report (10080 is one Week)
#Requires PS -Version 4.0 #Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)] [Parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $VMs, [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $VMs,
@@ -55,7 +55,7 @@ param(
Begin { Begin {
# none # none
} }
Process { Process {
if ($_.PowerState -eq "PoweredOn") { if ($_.PowerState -eq "PoweredOn") {
#region: Global Definitions #region: Global Definitions
[int]$TimeRange = "-" + $Minutes [int]$TimeRange = "-" + $Minutes
@@ -82,7 +82,7 @@ Process {
#region: Creating Reports #region: Creating Reports
Write-Verbose "$(Get-Date -Format G) Create Report..." Write-Verbose "$(Get-Date -Format G) Create Report..."
$reportPerf = @() $reportPerf = @()
$reportPerf = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{ $reportPerf = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{
New-Object PSObject -Property @{ New-Object PSObject -Property @{
VM = $_.Values[0] VM = $_.Values[0]
@@ -98,7 +98,7 @@ Process {
} }
Write-Verbose "$(Get-Date -Format G) Create Report completed" Write-Verbose "$(Get-Date -Format G) Create Report completed"
#endregion #endregion
} }
Else { Else {
@@ -108,7 +108,7 @@ Process {
} }
End { End {
# none # none
} }
} }

View File

@@ -1,16 +1,16 @@
function Konfig-ESXi { function Konfig-ESXi {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.12 ver 1.0 Base Release 2016.12 ver 1.0 Base Release
2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements 2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
Function My-Logger : http://www.virtuallyghetto.com/ Function My-Logger : http://www.virtuallyghetto.com/
=========================================================================== ===========================================================================
Tested Against Environment: Tested Against Environment:
@@ -18,7 +18,7 @@ function Konfig-ESXi {
PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1
PowerShell Version: 4.0, 5.0 PowerShell Version: 4.0, 5.0
OS Version: Windows 8.1, Server 2012 R2 OS Version: Windows 8.1, Server 2012 R2
Keyword: ESXi, NTP, SSH, Syslog, SATP, Keyword: ESXi, NTP, SSH, Syslog, SATP,
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
@@ -29,7 +29,7 @@ function Konfig-ESXi {
* Syslog * Syslog
* Power Management * Power Management
* HP 3PAR SATP/PSP Rule * HP 3PAR SATP/PSP Rule
* ... * ...
.Example .Example
Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514" Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514"
@@ -51,14 +51,14 @@ function Konfig-ESXi {
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[String] $VMHost, [String] $VMHost,
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=1)] [Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=1)]
[array]$NTP, [array]$NTP,
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=2)] [Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=2)]
[String] $syslog [String] $syslog
) )
Begin { Begin {
@@ -75,11 +75,11 @@ Begin {
} }
function Set-MyESXiOption { function Set-MyESXiOption {
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[String] $Name, [String] $Name,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)] [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)]
[String] $Value [String] $Value
) )
process { process {
$myESXiOption = Get-AdvancedSetting -Entity $ESXiHost -Name $Name $myESXiOption = Get-AdvancedSetting -Entity $ESXiHost -Name $Name
@@ -89,7 +89,7 @@ Begin {
} }
else { else {
My-Logger " ESXi Option $Name already has Value $Value" My-Logger " ESXi Option $Name already has Value $Value"
} }
} }
} }
} }
@@ -100,7 +100,7 @@ Process {
#region: Start vCenter Connection #region: Start vCenter Connection
My-Logger "Starting to Process ESXi Server Connection to $VMHost ..." My-Logger "Starting to Process ESXi Server Connection to $VMHost ..."
if (($global:DefaultVIServers).count -gt 0) { if (($global:DefaultVIServers).count -gt 0) {
Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue
} }
$VIConnection = Connect-VIServer -Server $VMHost $VIConnection = Connect-VIServer -Server $VMHost
if (-not $VIConnection.IsConnected) { if (-not $VIConnection.IsConnected) {
@@ -118,9 +118,9 @@ Process {
#endregion #endregion
if ($Validate -eq $True) { if ($Validate -eq $True) {
#region: Enable SSH and disable SSH Warning #region: Enable SSH and disable SSH Warning
$SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'} $SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'}
My-Logger "Starting SSH Service..." My-Logger "Starting SSH Service..."
if($SSHService.Running -ne $True){ if($SSHService.Running -ne $True){
Start-VMHostService -HostService $SSHService -Confirm:$false | Out-Null Start-VMHostService -HostService $SSHService -Confirm:$false | Out-Null
@@ -140,12 +140,12 @@ Process {
#endregion #endregion
#region: Config NTP #region: Config NTP
My-Logger "Removing existing NTP Server..." My-Logger "Removing existing NTP Server..."
try { try {
$ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false $ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false
} }
catch [System.Exception] { catch [System.Exception] {
Write-Warning "Error during removing existing NTP Servers." Write-Warning "Error during removing existing NTP Servers."
} }
My-Logger "Setting new NTP Servers..." My-Logger "Setting new NTP Servers..."
foreach ($myNTP in $NTP) { foreach ($myNTP in $NTP) {
@@ -154,16 +154,16 @@ Process {
My-Logger "Configure NTP Service..." My-Logger "Configure NTP Service..."
$NTPService = $ESXiHost | Get-VMHostService| Where-Object {$_.key -eq "ntpd"} $NTPService = $ESXiHost | Get-VMHostService| Where-Object {$_.key -eq "ntpd"}
if($NTPService.Running -eq $True){ if($NTPService.Running -eq $True){
Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null
} }
if($NTPService.Policy -ne "on"){ if($NTPService.Policy -ne "on"){
Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null
} }
My-Logger "Configure Local Time..." My-Logger "Configure Local Time..."
$HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem $HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem
$HostTimeSystem.UpdateDateTime([DateTime]::UtcNow) $HostTimeSystem.UpdateDateTime([DateTime]::UtcNow)
My-Logger "Start NTP Service..." My-Logger "Start NTP Service..."
Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null
@@ -181,16 +181,16 @@ Process {
#endregion #endregion
#region: Configure Static HighPower #region: Configure Static HighPower
My-Logger "Setting PowerProfile to Static HighPower..." My-Logger "Setting PowerProfile to Static HighPower..."
try { try {
$HostView = ($ESXiHost | Get-View) $HostView = ($ESXiHost | Get-View)
(Get-View $HostView.ConfigManager.PowerSystem).ConfigurePowerPolicy(1) (Get-View $HostView.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
} }
catch [System.Exception] { catch [System.Exception] {
Write-Warning "Error during Configure Static HighPower. See latest errors..." Write-Warning "Error during Configure Static HighPower. See latest errors..."
} }
#endregion #endregion
#region: Conf Syslog #region: Conf Syslog
My-Logger "Setting Syslog Firewall Rule ..." My-Logger "Setting Syslog Firewall Rule ..."
$SyslogFW = ($ESXiHost | Get-VMHostFirewallException | where {$_.Name -eq 'syslog'}) $SyslogFW = ($ESXiHost | Get-VMHostFirewallException | where {$_.Name -eq 'syslog'})
@@ -225,7 +225,7 @@ Process {
$esxcli2.storage.nmp.satp.rule.add.Invoke($arguments) $esxcli2.storage.nmp.satp.rule.add.Invoke($arguments)
} }
catch { catch {
Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..." Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..."
} }
#endregion #endregion

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
@{ @{
ModuleToProcess = 'NSXT.psm1' ModuleToProcess = 'NSXT.psm1'
ModuleVersion = '1.0.0.0' ModuleVersion = '1.0.0.0'
@@ -34,7 +38,7 @@
'Get-NSXTIPAMIPBlock', 'Get-NSXTIPAMIPBlock',
'Set-NSXTIPAMIPBlock', 'Set-NSXTIPAMIPBlock',
'Remove-NSXTIPAMIPBlock' 'Remove-NSXTIPAMIPBlock'
PrivateData = @{ PrivateData = @{
PSData = @{ PSData = @{

View File

@@ -1,4 +1,8 @@
Function Get-NSXTController { <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-NSXTController {
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipeline=$true)][string]$Id [parameter(Mandatory=$false,ValueFromPipeline=$true)][string]$Id
) )
@@ -10,7 +14,7 @@
} else { } else {
$nodes = $clusterNodeService.list().results | where { $_.manager_role -eq $null } $nodes = $clusterNodeService.list().results | where { $_.manager_role -eq $null }
} }
$results = @() $results = @()
foreach ($node in $nodes) { foreach ($node in $nodes) {
$nodeId = $node.id $nodeId = $node.id
@@ -64,7 +68,7 @@ Function Get-NSXTFabricNode {
Version = $node.os_version; Version = $node.os_version;
Status = $nodeStatusResult.host_node_deployment_status Status = $nodeStatusResult.host_node_deployment_status
ManagerStatus = $nodeStatusResult.mpa_connectivity_status ManagerStatus = $nodeStatusResult.mpa_connectivity_status
ControllerStatus = $nodeStatusResult.lcp_connectivity_status ControllerStatus = $nodeStatusResult.lcp_connectivity_status
} }
$results+=$tmp $results+=$tmp
} }
@@ -177,13 +181,13 @@ Function Get-NSXTTransportNode {
.Synopsis .Synopsis
Retrieves the transport_node information Retrieves the transport_node information
.DESCRIPTION .DESCRIPTION
Retrieves transport_node information for a single or multiple IDs. Execute with no parameters to get all ports, specify a transport_node if known. Retrieves transport_node information for a single or multiple IDs. Execute with no parameters to get all ports, specify a transport_node if known.
.EXAMPLE .EXAMPLE
Get-NSXTTransportNode Get-NSXTTransportNode
.EXAMPLE .EXAMPLE
Get-NSXTThingTemplate -Tranport_node_id "TN ID" Get-NSXTThingTemplate -Tranport_node_id "TN ID"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
[Alias("Id","Tranportnode_id")] [Alias("Id","Tranportnode_id")]
@@ -214,7 +218,7 @@ Function Get-NSXTTransportNode {
} }
foreach ($NSXTransportNode in $NSXTransportNodes) { foreach ($NSXTransportNode in $NSXTransportNodes) {
$results = [NSXTransportNode]::new() $results = [NSXTransportNode]::new()
$results.Name = $NSXTransportNode.display_name; $results.Name = $NSXTransportNode.display_name;
$results.Transport_node_id = $NSXTransportNode.Id; $results.Transport_node_id = $NSXTransportNode.Id;
@@ -225,7 +229,7 @@ Function Get-NSXTTransportNode {
$results.transport_zone_endpoints = $NSXTransportNode.transport_zone_endpoints; $results.transport_zone_endpoints = $NSXTransportNode.transport_zone_endpoints;
$results.host_switches = $NSXTransportNode.host_switches $results.host_switches = $NSXTransportNode.host_switches
$results $results
} }
} }
} }
@@ -239,8 +243,8 @@ Function Get-NSXTTraceFlow {
Get-NSXTTraceFlow Get-NSXTTraceFlow
.EXAMPLE .EXAMPLE
Get-NSXTTraceFlow -traceflow_id "TF ID Get-NSXTTraceFlow -traceflow_id "TF ID
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipeline=$true)] [parameter(Mandatory=$false,ValueFromPipeline=$true)]
[Alias("Id")] [Alias("Id")]
@@ -248,7 +252,7 @@ Function Get-NSXTTraceFlow {
) )
$NSXTraceFlowsService = Get-NsxtService -Name "com.vmware.nsx.traceflows" $NSXTraceFlowsService = Get-NsxtService -Name "com.vmware.nsx.traceflows"
if($traceflow_id) { if($traceflow_id) {
$NSXTraceFlows = $NSXTraceFlowsService.get($traceflow_id) $NSXTraceFlows = $NSXTraceFlowsService.get($traceflow_id)
} else { } else {
@@ -267,7 +271,7 @@ Function Get-NSXTTraceFlow {
} }
foreach ($NSXTraceFlow in $NSXTraceFlows) { foreach ($NSXTraceFlow in $NSXTraceFlows) {
$results = [NSXTraceFlow]::new() $results = [NSXTraceFlow]::new()
$results.traceflow_id = $NSXTraceFlow.Id; $results.traceflow_id = $NSXTraceFlow.Id;
$results.Operation_State = $NSXTraceFlow.operation_state; $results.Operation_State = $NSXTraceFlow.operation_state;
@@ -277,7 +281,7 @@ Function Get-NSXTTraceFlow {
$results.dropped = $NSXTraceFlow.Counters.dropped_count; $results.dropped = $NSXTraceFlow.Counters.dropped_count;
$results.analysis = $NSXTraceFlow.analysis $results.analysis = $NSXTraceFlow.analysis
$results $results
} }
} }
Function Get-NSXTTraceFlowObservations { Function Get-NSXTTraceFlowObservations {
@@ -290,8 +294,8 @@ Function Get-NSXTTraceFlowObservations {
Get-NSXTTraceFlowObservations -traceflow_id "TF ID" Get-NSXTTraceFlowObservations -traceflow_id "TF ID"
.EXAMPLE .EXAMPLE
Get-NSXTTraceFlow | Get-NSXTTraceFlowObservations Get-NSXTTraceFlow | Get-NSXTTraceFlowObservations
#> #>
Param ( Param (
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("Id")] [Alias("Id")]
@@ -302,9 +306,9 @@ Function Get-NSXTTraceFlowObservations {
{ {
$NSXTraceFlowsObservService = Get-NsxtService -Name "com.vmware.nsx.traceflows.observations" $NSXTraceFlowsObservService = Get-NsxtService -Name "com.vmware.nsx.traceflows.observations"
} }
Process Process
{ {
if($traceflow_id) { if($traceflow_id) {
$NSXTraceFlowsObserv = $NSXTraceFlowsObservService.list($traceflow_id) $NSXTraceFlowsObserv = $NSXTraceFlowsObservService.list($traceflow_id)
} else { } else {
@@ -327,7 +331,7 @@ Function Get-NSXTEdgeCluster {
Get-NSXTEdgeCluster -edge_cluster_id "Edge Cluster ID" Get-NSXTEdgeCluster -edge_cluster_id "Edge Cluster ID"
.EXAMPLE .EXAMPLE
Get-NSXTThingTemplate | where name -eq "My Edge Cluster Name" Get-NSXTThingTemplate | where name -eq "My Edge Cluster Name"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -360,7 +364,7 @@ Function Get-NSXTEdgeCluster {
else { else {
$NSXEdgeClusters = $NSXTEdgeClustersService.list().results $NSXEdgeClusters = $NSXTEdgeClustersService.list().results
} }
foreach ($NSXEdgeCluster in $NSXEdgeClusters) { foreach ($NSXEdgeCluster in $NSXEdgeClusters) {
$results = [NSXEdgeCluster]::new() $results = [NSXEdgeCluster]::new()
@@ -392,7 +396,7 @@ Function Get-NSXTLogicalRouter {
Get-NSXTLogicalRouter | where name -eq "LR Name" Get-NSXTLogicalRouter | where name -eq "LR Name"
.EXAMPLE .EXAMPLE
(Get-NSXTLogicalRouter -Logical_router_id "LR ID").per_node_status (Get-NSXTLogicalRouter -Logical_router_id "LR ID").per_node_status
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -404,17 +408,17 @@ Function Get-NSXTLogicalRouter {
{ {
$NSXTLogicalRoutersService = Get-NsxtService -Name "com.vmware.nsx.logical_routers" $NSXTLogicalRoutersService = Get-NsxtService -Name "com.vmware.nsx.logical_routers"
$NSXTLogicalRoutersStatusService = Get-NsxtService -Name "com.vmware.nsx.logical_routers.status" $NSXTLogicalRoutersStatusService = Get-NsxtService -Name "com.vmware.nsx.logical_routers.status"
class per_node_status { class per_node_status {
$service_router_id $service_router_id
[ValidateSet("ACTIVE","STANDBY","DOWN","SYNC","UNKNOWN")] [ValidateSet("ACTIVE","STANDBY","DOWN","SYNC","UNKNOWN")]
$high_availability_status $high_availability_status
$transport_node_id $transport_node_id
per_node_status(){} per_node_status(){}
per_node_status( per_node_status(
$service_router_id, $service_router_id,
$high_availability_status, $high_availability_status,
$transport_node_id $transport_node_id
) { ) {
@@ -423,7 +427,7 @@ Function Get-NSXTLogicalRouter {
$this.transport_node_id = $transport_node_id $this.transport_node_id = $transport_node_id
} }
} }
class NSXTLogicalRouter { class NSXTLogicalRouter {
[string]$Name [string]$Name
[string]$Logical_router_id [string]$Logical_router_id
@@ -453,10 +457,10 @@ Function Get-NSXTLogicalRouter {
} }
foreach ($NSXLogicalRouter in $NSXLogicalRouters) { foreach ($NSXLogicalRouter in $NSXLogicalRouters) {
$NSXTLogicalRoutersStatus = $NSXTLogicalRoutersStatusService.get($NSXLogicalRouter.id) $NSXTLogicalRoutersStatus = $NSXTLogicalRoutersStatusService.get($NSXLogicalRouter.id)
$results = [NSXTLogicalRouter]::new() $results = [NSXTLogicalRouter]::new()
foreach ($NSXTLogicalRouterStatus in $NSXTLogicalRoutersStatus.per_node_status) { foreach ($NSXTLogicalRouterStatus in $NSXTLogicalRoutersStatus.per_node_status) {
$results.per_node_status += [per_node_status]::new($NSXTLogicalRouterStatus.service_router_id,$NSXTLogicalRouterStatus.high_availability_status,$NSXTLogicalRouterStatus.transport_node_id) $results.per_node_status += [per_node_status]::new($NSXTLogicalRouterStatus.service_router_id,$NSXTLogicalRouterStatus.high_availability_status,$NSXTLogicalRouterStatus.transport_node_id)
} }
@@ -474,7 +478,7 @@ Function Get-NSXTLogicalRouter {
$results.advanced_config =$NSXLogicalRouter.advanced_config; $results.advanced_config =$NSXLogicalRouter.advanced_config;
$results.firewall_sections =$NSXLogicalRouter.firewall_sections $results.firewall_sections =$NSXLogicalRouter.firewall_sections
$results $results
} }
} }
} }
@@ -492,8 +496,8 @@ Function Get-NSXTRoutingTable {
Get-NSXTLogicalRouter | where name -eq INT-T1 | Get-NSXTRoutingTable -transport_node_id ((Get-NSXTTransportNode | where name -match "INT")[0].transport_node_id) Get-NSXTLogicalRouter | where name -eq INT-T1 | Get-NSXTRoutingTable -transport_node_id ((Get-NSXTTransportNode | where name -match "INT")[0].transport_node_id)
.EXAMPLE .EXAMPLE
Get-NSXTLogicalRouter | where name -eq INT-T1 | Get-NSXTRoutingTable -transport_node_id (((Get-NSXTLogicalRouter | where name -eq INT-T1).per_node_status | where high_availability_status -eq ACTIVE).transport_node_id) Get-NSXTLogicalRouter | where name -eq INT-T1 | Get-NSXTRoutingTable -transport_node_id (((Get-NSXTLogicalRouter | where name -eq INT-T1).per_node_status | where high_availability_status -eq ACTIVE).transport_node_id)
#> #>
Param ( Param (
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[string]$Logical_router_id, [string]$Logical_router_id,
@@ -515,14 +519,14 @@ Function Get-NSXTRoutingTable {
hidden [string]$logical_router_port_id hidden [string]$logical_router_port_id
[long]$admin_distance [long]$admin_distance
} }
} }
Process Process
{ {
$NSXTRoutingTable = $NSXTRoutingTableService.list($Logical_router_id,$transport_node_id,$null,$null,$null,$null,$null,'realtime') $NSXTRoutingTable = $NSXTRoutingTableService.list($Logical_router_id,$transport_node_id,$null,$null,$null,$null,$null,'realtime')
foreach ($NSXTRoute in $NSXTRoutingTable.results) { foreach ($NSXTRoute in $NSXTRoutingTable.results) {
$results = [NSXTRoutingTable]::new() $results = [NSXTRoutingTable]::new()
$results.Logical_router_id = $Logical_router_id; $results.Logical_router_id = $Logical_router_id;
$results.lr_component_type = $NSXTRoute.lr_component_type; $results.lr_component_type = $NSXTRoute.lr_component_type;
@@ -545,7 +549,7 @@ Function Get-NSXTFabricVM {
Retrieves all VM's attached to the fabric. Retrieves all VM's attached to the fabric.
.EXAMPLE .EXAMPLE
Get-NSXTFabricVM Get-NSXTFabricVM
#> #>
Begin Begin
{ {
$NSXTVMService = Get-NsxtService -Name "com.vmware.nsx.fabric.virtual_machines" $NSXTVMService = Get-NsxtService -Name "com.vmware.nsx.fabric.virtual_machines"
@@ -567,7 +571,7 @@ Function Get-NSXTFabricVM {
{ {
$NSXTVMs = $NSXTVMService.list().results $NSXTVMs = $NSXTVMService.list().results
foreach ($NSXTVM in $NSXTVMs) { foreach ($NSXTVM in $NSXTVMs) {
$results = [NSXVM]::new() $results = [NSXVM]::new()
@@ -595,9 +599,9 @@ Function Get-NSXTBGPNeighbors {
.EXAMPLE .EXAMPLE
Get-NSXTBGPNeighbors -logical_router_id "LR ID" Get-NSXTBGPNeighbors -logical_router_id "LR ID"
.EXAMPLE .EXAMPLE
Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTBGPNeighbors Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTBGPNeighbors
#> #>
Param ( Param (
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("Id")] [Alias("Id")]
@@ -639,7 +643,7 @@ Function Get-NSXTBGPNeighbors {
$NSXTThings = $NSXTThingsService.list($logical_router_id).results $NSXTThings = $NSXTThingsService.list($logical_router_id).results
foreach ($NSXTThing in $NSXTThings) { foreach ($NSXTThing in $NSXTThings) {
$results = [NSXTBGPNeighbors]::new() $results = [NSXTBGPNeighbors]::new()
$results.Name = $NSXTThing.display_name; $results.Name = $NSXTThing.display_name;
$results.logical_router_id = $NSXTThing.logical_router_id; $results.logical_router_id = $NSXTThing.logical_router_id;
@@ -664,7 +668,7 @@ Function Get-NSXTBGPNeighbors {
$results.source_address = $NSXTThing.source_address; $results.source_address = $NSXTThing.source_address;
$results.source_addresses = $NSXTThing.source_addresses $results.source_addresses = $NSXTThing.source_addresses
$results $results
} }
} }
} }
@@ -682,7 +686,7 @@ Function Get-NSXTForwardingTable {
Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTForwardingTable -transport_node_id ((Get-NSXTTransportNode | where name -match "Edge Name")[0].transport_node_id) Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTForwardingTable -transport_node_id ((Get-NSXTTransportNode | where name -match "Edge Name")[0].transport_node_id)
.EXAMPLE .EXAMPLE
Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTForwardingTable -transport_node_id (((Get-NSXTLogicalRouter | where name -eq "Edge Name").per_node_status | where high_availability_status -eq ACTIVE).transport_node_id) Get-NSXTLogicalRouter | where name -eq "LR Name" | Get-NSXTForwardingTable -transport_node_id (((Get-NSXTLogicalRouter | where name -eq "Edge Name").per_node_status | where high_availability_status -eq ACTIVE).transport_node_id)
#> #>
Param ( Param (
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
@@ -704,14 +708,14 @@ Function Get-NSXTForwardingTable {
[string]$route_type [string]$route_type
hidden [string]$logical_router_port_id hidden [string]$logical_router_port_id
} }
} }
Process Process
{ {
$NSXTForwardingTable = $NSXTForwardingTableService.list($Logical_router_id,$transport_node_id,$null,$null,$null,$null,$null,$null,'realtime') $NSXTForwardingTable = $NSXTForwardingTableService.list($Logical_router_id,$transport_node_id,$null,$null,$null,$null,$null,$null,'realtime')
foreach ($NSXTForwarding in $NSXTForwardingTable.results) { foreach ($NSXTForwarding in $NSXTForwardingTable.results) {
$results = [NSXTForwardingTable]::new() $results = [NSXTForwardingTable]::new()
$results.Logical_router_id = $Logical_router_id; $results.Logical_router_id = $Logical_router_id;
$results.lr_component_type = $NSXTForwarding.lr_component_type; $results.lr_component_type = $NSXTForwarding.lr_component_type;
@@ -730,12 +734,12 @@ Function Get-NSXTNetworkRoutes {
.Synopsis .Synopsis
Retrieves the network routes information Retrieves the network routes information
.DESCRIPTION .DESCRIPTION
Retrieves the network routes information for a single or multiple routes. Retrieves the network routes information for a single or multiple routes.
.EXAMPLE .EXAMPLE
Get-NSXTNetworkRoutes Get-NSXTNetworkRoutes
.EXAMPLE .EXAMPLE
Get-NSXTNetworkRoutes -route_id "Route ID" Get-NSXTNetworkRoutes -route_id "Route ID"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -759,8 +763,8 @@ Function Get-NSXTNetworkRoutes {
$scope $scope
$src $src
} }
} }
Process Process
{ {
if ($route_id) { if ($route_id) {
@@ -769,9 +773,9 @@ Function Get-NSXTNetworkRoutes {
else { else {
$NSXTNetworkRoutes = $NSXTNetworkRoutesService.list().results $NSXTNetworkRoutes = $NSXTNetworkRoutesService.list().results
} }
foreach ($NSXTRoute in $NSXTNetworkRoutes) { foreach ($NSXTRoute in $NSXTNetworkRoutes) {
$results = [NSXTNetworkRoutes]::new() $results = [NSXTNetworkRoutes]::new()
$results.route_id = $NSXTRoute.route_id; $results.route_id = $NSXTRoute.route_id;
$results.route_type = $NSXTRoute.route_type; $results.route_type = $NSXTRoute.route_type;
@@ -803,8 +807,8 @@ Function Get-NSXTLogicalRouterPorts {
Get-NSXTLogicalRouterPorts -logical_router_id "LR Name" Get-NSXTLogicalRouterPorts -logical_router_id "LR Name"
.EXAMPLE .EXAMPLE
Get-NSXTLogicalRouterPorts -logical_router_id (Get-NSXTLogicalRouter | where name -eq "LR Name") Get-NSXTLogicalRouterPorts -logical_router_id (Get-NSXTLogicalRouter | where name -eq "LR Name")
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
[Alias("Id")] [Alias("Id")]
@@ -831,7 +835,7 @@ Function Get-NSXTLogicalRouterPorts {
$this.prefix_length = $prefix_length $this.prefix_length = $prefix_length
} }
} }
class NSXTLogicalRouterPorts { class NSXTLogicalRouterPorts {
[string]$Name [string]$Name
$Id $Id
@@ -859,7 +863,7 @@ Function Get-NSXTLogicalRouterPorts {
} }
foreach ($NSXTLogicalRouterPort in $NSXTLogicalRouterPorts) { foreach ($NSXTLogicalRouterPort in $NSXTLogicalRouterPorts) {
$results = [NSXTLogicalRouterPorts]::new() $results = [NSXTLogicalRouterPorts]::new()
foreach ($subnet in $NSXTLogicalRouterPort.subnets) { foreach ($subnet in $NSXTLogicalRouterPort.subnets) {
@@ -875,7 +879,7 @@ Function Get-NSXTLogicalRouterPorts {
$results.mac_address = $NSXTLogicalRouterPort.mac_address $results.mac_address = $NSXTLogicalRouterPort.mac_address
$results.linked_logical_switch_port_id = $NSXTLogicalRouterPort.linked_logical_switch_port_id $results.linked_logical_switch_port_id = $NSXTLogicalRouterPort.linked_logical_switch_port_id
$results $results
} }
} }
} }
@@ -891,7 +895,7 @@ Function Get-NSXTTransportZone {
Get-NSXTTransportZone -zone_id "Zone ID" Get-NSXTTransportZone -zone_id "Zone ID"
.EXAMPLE .EXAMPLE
Get-NSXTTransportZone -name "Zone1" Get-NSXTTransportZone -name "Zone1"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -934,7 +938,7 @@ Function Get-NSXTTransportZone {
} }
foreach ($NSXTTransportZone in $NSXTTransportZones) { foreach ($NSXTTransportZone in $NSXTTransportZones) {
$results = [NSXTTransportZone]::new() $results = [NSXTTransportZone]::new()
$results.Name = $NSXTTransportZone.display_name; $results.Name = $NSXTTransportZone.display_name;
$results.ID = $NSXTTransportZone.Id; $results.ID = $NSXTTransportZone.Id;
@@ -948,7 +952,7 @@ Function Get-NSXTTransportZone {
$results.protection = $NSXTTransportZone.protection; $results.protection = $NSXTTransportZone.protection;
$results.uplink_teaming_policy_names = $NSXTTransportZone.uplink_teaming_policy_names $results.uplink_teaming_policy_names = $NSXTTransportZone.uplink_teaming_policy_names
$results $results
} }
} }
} }
@@ -964,7 +968,7 @@ Function Get-NSXTLogicalSwitch {
Get-NSXTLogicalSwitch -lswitch_id "switch id" Get-NSXTLogicalSwitch -lswitch_id "switch id"
.EXAMPLE .EXAMPLE
Get-NSXTLogicalSwitch -name "switch name" Get-NSXTLogicalSwitch -name "switch name"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -1013,7 +1017,7 @@ Function Get-NSXTLogicalSwitch {
} }
foreach ($NSXTLogicalSwitch in $NSXTLogicalSwitches) { foreach ($NSXTLogicalSwitch in $NSXTLogicalSwitches) {
$results = [NSXTLogicalSwitch]::new() $results = [NSXTLogicalSwitch]::new()
$results.Name = $NSXTLogicalSwitch.display_name; $results.Name = $NSXTLogicalSwitch.display_name;
$results.Id = $NSXTLogicalSwitch.Id; $results.Id = $NSXTLogicalSwitch.Id;
@@ -1033,7 +1037,7 @@ Function Get-NSXTLogicalSwitch {
$results.vlan = $NSXTLogicalSwitch.vlan; $results.vlan = $NSXTLogicalSwitch.vlan;
$results.vlan_trunk_spec = $NSXTLogicalSwitch.vlan_trunk_spec $results.vlan_trunk_spec = $NSXTLogicalSwitch.vlan_trunk_spec
$results $results
} }
} }
} }
@@ -1047,7 +1051,7 @@ Function Get-NSXTIPPool {
Get-NSXTIPPool Get-NSXTIPPool
.EXAMPLE .EXAMPLE
Get-NSXTThingTemplate -pool_id "Pool ID" Get-NSXTThingTemplate -pool_id "Pool ID"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -1084,12 +1088,12 @@ Function Get-NSXTIPPool {
$NSXTIPPools = $NSXTIPPoolService.list().results | where {$_.display_name -eq $name} $NSXTIPPools = $NSXTIPPoolService.list().results | where {$_.display_name -eq $name}
} }
else { else {
$NSXTIPPools = $NSXTIPPoolService.list().results $NSXTIPPools = $NSXTIPPoolService.list().results
} }
} }
foreach ($NSXTIPPool in $NSXTIPPools) { foreach ($NSXTIPPool in $NSXTIPPools) {
$results = [NSXTIPPool]::new() $results = [NSXTIPPool]::new()
$results.Name = $NSXTIPPool.display_name; $results.Name = $NSXTIPPool.display_name;
$results.ID = $NSXTIPPool.id; $results.ID = $NSXTIPPool.id;
@@ -1102,7 +1106,7 @@ Function Get-NSXTIPPool {
$results.RangeStart = $NSXTIPPool.subnets.allocation_ranges.start; $results.RangeStart = $NSXTIPPool.subnets.allocation_ranges.start;
$results.RangeEnd = $NSXTIPPool.subnets.allocation_ranges.end $results.RangeEnd = $NSXTIPPool.subnets.allocation_ranges.end
$results $results
} }
} }
} }
@@ -1119,7 +1123,7 @@ Function Get-NSXTIPAMIPBlock {
.EXAMPLE .EXAMPLE
Get-NSXTIPAMIPBlock -name "Block Name" Get-NSXTIPAMIPBlock -name "Block Name"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -1158,7 +1162,7 @@ Function Get-NSXTIPAMIPBlock {
} }
foreach ($NSXTIPAMIPBlock in $NSXTIPAMIPBlocks) { foreach ($NSXTIPAMIPBlock in $NSXTIPAMIPBlocks) {
$results = [ip_block]::new() $results = [ip_block]::new()
$results.Name = $NSXTIPAMIPBlock.display_name; $results.Name = $NSXTIPAMIPBlock.display_name;
$results.block_id = $NSXTIPAMIPBlock.id; $results.block_id = $NSXTIPAMIPBlock.id;
@@ -1168,7 +1172,7 @@ Function Get-NSXTIPAMIPBlock {
$results.resource_type = $NSXTIPAMIPBlock.resource_type $results.resource_type = $NSXTIPAMIPBlock.resource_type
$results $results
} }
} }
} }
@@ -1184,7 +1188,7 @@ Function Get-NSXTClusterNode {
Get-NSXTClusterNode -node_id "Node Id" Get-NSXTClusterNode -node_id "Node Id"
.EXAMPLE .EXAMPLE
Get-NSXTClusterNode -name "Name" Get-NSXTClusterNode -name "Name"
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -1226,7 +1230,7 @@ Function Get-NSXTClusterNode {
} }
foreach ($NSXTClusterNode in $NSXTClusterNodes) { foreach ($NSXTClusterNode in $NSXTClusterNodes) {
$results = [NSXTClusterNode]::new() $results = [NSXTClusterNode]::new()
$results.Name = $NSXTClusterNode.display_name; $results.Name = $NSXTClusterNode.display_name;
$results.node_id = $NSXTClusterNode.Id; $results.node_id = $NSXTClusterNode.Id;
@@ -1246,7 +1250,7 @@ Function Get-NSXTClusterNode {
} }
$results $results
} }
} }
} }
@@ -1263,9 +1267,9 @@ Function Set-NSXTLogicalRouter {
Set-NSXTLogicalRouter -display_name "Name" -high_availability_mode "ACTIVE_ACTIVE" -router_type "TIER0" -edge_cluster_id "Edge Cluster ID" Set-NSXTLogicalRouter -display_name "Name" -high_availability_mode "ACTIVE_ACTIVE" -router_type "TIER0" -edge_cluster_id "Edge Cluster ID"
.EXAMPLE .EXAMPLE
Set-NSXTLogicalRouter -display_name "Name" -high_availability_mode "ACTIVE_STANDBY" -router_type "TIER1" -description "this is my new tier1 lr" Set-NSXTLogicalRouter -display_name "Name" -high_availability_mode "ACTIVE_STANDBY" -router_type "TIER1" -description "this is my new tier1 lr"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')] ConfirmImpact='Medium')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
@@ -1275,20 +1279,20 @@ Function Set-NSXTLogicalRouter {
[parameter(Mandatory=$false, [parameter(Mandatory=$false,
ParameterSetName='TIER1')] ParameterSetName='TIER1')]
[string]$description, [string]$description,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ParameterSetName='TIER0')] ParameterSetName='TIER0')]
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ParameterSetName='TIER1')] ParameterSetName='TIER1')]
[string]$display_name, [string]$display_name,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ParameterSetName='TIER0')] ParameterSetName='TIER0')]
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ParameterSetName='TIER1')] ParameterSetName='TIER1')]
[ValidateSet("ACTIVE_ACTIVE","ACTIVE_STANDBY")] [ValidateSet("ACTIVE_ACTIVE","ACTIVE_STANDBY")]
[string]$high_availability_mode, [string]$high_availability_mode,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ParameterSetName='TIER0')] ParameterSetName='TIER0')]
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
@@ -1315,7 +1319,7 @@ Function Set-NSXTLogicalRouter {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTLogicalRouterService = Get-NsxtService -Name "com.vmware.nsx.logical_routers" $NSXTLogicalRouterService = Get-NsxtService -Name "com.vmware.nsx.logical_routers"
} }
@@ -1340,13 +1344,13 @@ Function Set-NSXTLogicalRouter {
if ($pscmdlet.ShouldProcess($logical_router_request.display_name, "Create logical router")) if ($pscmdlet.ShouldProcess($logical_router_request.display_name, "Create logical router"))
{ {
$NSXTLogicalRouter = $NSXTLogicalRouterService.create($logical_router_request) $NSXTLogicalRouter = $NSXTLogicalRouterService.create($logical_router_request)
} }
} }
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
$NSXTLogicalRouter $NSXTLogicalRouter
@@ -1363,22 +1367,22 @@ Function Set-NSXTLogicalSwitch {
Set-NSXTLogicalSwitch -display_name "Name" -transport_zone_id "TP Zone ID" Set-NSXTLogicalSwitch -display_name "Name" -transport_zone_id "TP Zone ID"
.EXAMPLE .EXAMPLE
Set-NSXTLogicalSwitch -display_name "Name" -transport_zone_id "TP Zone ID" -admin_state "UP" -replication_mode "MTEP" -ip_pool_id "IP Pool Name" Set-NSXTLogicalSwitch -display_name "Name" -transport_zone_id "TP Zone ID" -admin_state "UP" -replication_mode "MTEP" -ip_pool_id "IP Pool Name"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')] ConfirmImpact='Medium')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
Param ( Param (
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$description, [string]$description,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[string]$display_name, [string]$display_name,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[string]$transport_zone_id, [string]$transport_zone_id,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateSet("UP","DOWN")] [ValidateSet("UP","DOWN")]
[string]$admin_state, [string]$admin_state,
@@ -1405,7 +1409,7 @@ Function Set-NSXTLogicalSwitch {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTLogicalSwitchService = Get-NsxtService -Name "com.vmware.nsx.logical_switches" $NSXTLogicalSwitchService = Get-NsxtService -Name "com.vmware.nsx.logical_switches"
} }
@@ -1428,13 +1432,13 @@ Function Set-NSXTLogicalSwitch {
{ {
$NSXTLogicalSwitch = $NSXTLogicalSwitchService.create($logical_switch_request) $NSXTLogicalSwitch = $NSXTLogicalSwitchService.create($logical_switch_request)
} }
} }
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
$NSXTLogicalSwitch $NSXTLogicalSwitch
@@ -1446,23 +1450,23 @@ Function Set-NSXTIPAMIPBlock {
.Synopsis .Synopsis
Creates an IPAM IP Block Creates an IPAM IP Block
.DESCRIPTION .DESCRIPTION
Creates a IPAM IP Block with a cidr parameter. Creates a IPAM IP Block with a cidr parameter.
.EXAMPLE .EXAMPLE
Set-NSXTIPAMIPBlock -name "IPAM Block Name" -cidr "192.168.0.0/24" Set-NSXTIPAMIPBlock -name "IPAM Block Name" -cidr "192.168.0.0/24"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')] ConfirmImpact='Medium')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
Param ( Param (
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$description, [string]$description,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$display_name, [string]$display_name,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$cidr [string]$cidr
@@ -1482,7 +1486,7 @@ Function Set-NSXTIPAMIPBlock {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTIPAMIPBlockService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_blocks" $NSXTIPAMIPBlockService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_blocks"
} }
@@ -1500,7 +1504,7 @@ Function Set-NSXTIPAMIPBlock {
{ {
# Should process # Should process
if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool")) if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool"))
{ {
$NSXTIPAMIPBlock = $NSXTIPAMIPBlockService.create($IPAMIPBlock_request) $NSXTIPAMIPBlock = $NSXTIPAMIPBlockService.create($IPAMIPBlock_request)
} }
} }
@@ -1508,7 +1512,7 @@ Function Set-NSXTIPAMIPBlock {
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
$NSXTIPAMIPBlock $NSXTIPAMIPBlock
@@ -1525,9 +1529,9 @@ Function Set-NSXTIPPool {
Set-NSXTIPPool -display_name "Pool Name" -allocation_start "192.168.1.2" -allocation_end "192.168.1.100" -cidr "192.168.1.0/24" Set-NSXTIPPool -display_name "Pool Name" -allocation_start "192.168.1.2" -allocation_end "192.168.1.100" -cidr "192.168.1.0/24"
.EXAMPLE .EXAMPLE
Set-NSXTIPPool -display_name "Test Pool Name" -allocation_start "192.168.1.2" -allocation_end "192.168.1.100" -cidr "192.168.1.0/24" -dns_nameservers "192.168.1.1" -gateway_ip "192.168.1.1" -dns_suffix "evil corp" Set-NSXTIPPool -display_name "Test Pool Name" -allocation_start "192.168.1.2" -allocation_end "192.168.1.100" -cidr "192.168.1.0/24" -dns_nameservers "192.168.1.1" -gateway_ip "192.168.1.1" -dns_suffix "evil corp"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='High')] ConfirmImpact='High')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
@@ -1535,13 +1539,13 @@ Function Set-NSXTIPPool {
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$display_name, [string]$display_name,
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$description, [string]$description,
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$dns_nameservers, [string]$dns_nameservers,
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$dns_suffix, [string]$dns_suffix,
@@ -1575,9 +1579,9 @@ Function Set-NSXTIPPool {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTIPPoolService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_pools" $NSXTIPPoolService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_pools"
# Classes unused - part of early testing # Classes unused - part of early testing
class allocation_ranges { class allocation_ranges {
[string]$start [string]$start
@@ -1591,7 +1595,7 @@ Function Set-NSXTIPPool {
[string]$dns_suffix [string]$dns_suffix
[string]$cidr [string]$cidr
[string]$gateway_ip [string]$gateway_ip
#hidden $self #hidden $self
} }
class ip_pool { class ip_pool {
@@ -1632,12 +1636,12 @@ Function Set-NSXTIPPool {
$ip_pool.subnets[0].gateway_ip = $gateway_ip $ip_pool.subnets[0].gateway_ip = $gateway_ip
$ip_pool.revision = 0 $ip_pool.revision = 0
$ip_pool.tags = @() $ip_pool.tags = @()
try try
{ {
# Should process # Should process
if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool")) if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool"))
{ {
$NSXTIPPoolService.create($ip_pool) $NSXTIPPoolService.create($ip_pool)
} }
} }
@@ -1657,14 +1661,14 @@ Function Remove-NSXTIPAMIPBlock {
.Synopsis .Synopsis
Removes an IPAM IP Block Removes an IPAM IP Block
.DESCRIPTION .DESCRIPTION
Removes a IPAM IP Block with a block_id parameter. Removes a IPAM IP Block with a block_id parameter.
.EXAMPLE .EXAMPLE
Remove-NSXTIPAMIPBlock -block_id "id" Remove-NSXTIPAMIPBlock -block_id "id"
.EXAMPLE .EXAMPLE
Get-NSXTIPAMIPBlock | where name -eq "IPAM Test2" | Remove-NSXTIPAMIPBlock Get-NSXTIPAMIPBlock | where name -eq "IPAM Test2" | Remove-NSXTIPAMIPBlock
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='High')] ConfirmImpact='High')]
Param ( Param (
@@ -1688,7 +1692,7 @@ Function Remove-NSXTIPAMIPBlock {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTIPAMIPBlockService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_blocks" $NSXTIPAMIPBlockService = Get-NsxtService -Name "com.vmware.nsx.pools.ip_blocks"
} }
@@ -1698,7 +1702,7 @@ Function Remove-NSXTIPAMIPBlock {
{ {
# Should process # Should process
if ($pscmdlet.ShouldProcess($block_id, "Delete IP Pool")) if ($pscmdlet.ShouldProcess($block_id, "Delete IP Pool"))
{ {
$NSXTIPAMIPBlockService.delete($block_id) $NSXTIPAMIPBlockService.delete($block_id)
} }
} }
@@ -1706,7 +1710,7 @@ Function Remove-NSXTIPAMIPBlock {
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
} }
} }
@@ -1719,14 +1723,14 @@ Function Set-NSXTTraceFlow {
.DESCRIPTION .DESCRIPTION
Create a TraceFlow for later observation. Create a TraceFlow for later observation.
.EXAMPLE .EXAMPLE
Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC" Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC"
.EXAMPLE .EXAMPLE
Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC" | Get-NSXTTraceFlow Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC" | Get-NSXTTraceFlow
.EXAMPLE .EXAMPLE
Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC" | Get-NSXTTraceFlow | Get-NSXTTraceFlowObservations Set-NSXTTraceFlow -transport_type "UNICAST" -lport_id "LP ID" -src_ip "IP Address" -src_mac "MAC" -dst_ip "IP Address" -dst_mac "MAC" | Get-NSXTTraceFlow | Get-NSXTTraceFlowObservations
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')] ConfirmImpact='Medium')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
@@ -1747,7 +1751,7 @@ Function Set-NSXTTraceFlow {
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[ValidateScript({$_ -match [IPAddress]$_})] [ValidateScript({$_ -match [IPAddress]$_})]
[string] [string]
$src_ip, $src_ip,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
@@ -1765,7 +1769,7 @@ Function Set-NSXTTraceFlow {
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[ValidateScript({$_ -match [IPAddress]$_ })] [ValidateScript({$_ -match [IPAddress]$_ })]
[string] [string]
$dst_ip, $dst_ip,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
@@ -1784,7 +1788,7 @@ Function Set-NSXTTraceFlow {
{ {
if (-not $global:DefaultNsxtServers.isconnected) if (-not $global:DefaultNsxtServers.isconnected)
{ {
try try
{ {
Connect-NsxtServer -Menu -ErrorAction Stop Connect-NsxtServer -Menu -ErrorAction Stop
@@ -1795,11 +1799,11 @@ Function Set-NSXTTraceFlow {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTraceFlowsService = Get-NsxtService -Name "com.vmware.nsx.traceflows" $NSXTraceFlowsService = Get-NsxtService -Name "com.vmware.nsx.traceflows"
# Comment out custom classes # Comment out custom classes
<# <#
class ip_header { class ip_header {
[string]$src_ip [string]$src_ip
[string]$dst_ip [string]$dst_ip
@@ -1819,7 +1823,7 @@ Function Set-NSXTTraceFlow {
[long]$frame_size [long]$frame_size
[eth_header]$eth_header = [eth_header]::new() [eth_header]$eth_header = [eth_header]::new()
[ip_header]$ip_header = [ip_header]::new() [ip_header]$ip_header = [ip_header]::new()
packet_data(){ packet_data(){
$this.routed = 'true' $this.routed = 'true'
$this.transport_type = 'UNICAST' $this.transport_type = 'UNICAST'
@@ -1845,7 +1849,7 @@ Function Set-NSXTTraceFlow {
$traceflow_request.lport_id = $lport_id $traceflow_request.lport_id = $lport_id
$traceflow_request.packet.transport_type = $transport_type $traceflow_request.packet.transport_type = $transport_type
$eth_header = [ordered]@{'src_mac' = $src_mac;'eth_type' = '2048';'dst_mac' = $dst_mac} $eth_header = [ordered]@{'src_mac' = $src_mac;'eth_type' = '2048';'dst_mac' = $dst_mac}
$ip_header = [ordered]@{src_ip = $src_ip;protocol = '1';ttl = '64';dst_ip = $dst_ip} $ip_header = [ordered]@{src_ip = $src_ip;protocol = '1';ttl = '64';dst_ip = $dst_ip}
$traceflow_request.packet | Add-Member -NotePropertyMembers $eth_header -TypeName eth_header $traceflow_request.packet | Add-Member -NotePropertyMembers $eth_header -TypeName eth_header
@@ -1894,7 +1898,7 @@ Function Get-NSXTThingTemplate {
Get-NSXTThingTemplate -param2 "LR Name" Get-NSXTThingTemplate -param2 "LR Name"
.EXAMPLE .EXAMPLE
Get-NSXTThingTemplate -param2 (Get-NSXTLogicalRouter | where name -eq "LR Name") Get-NSXTThingTemplate -param2 (Get-NSXTLogicalRouter | where name -eq "LR Name")
#> #>
Param ( Param (
[parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
@@ -1938,7 +1942,7 @@ Function Get-NSXTThingTemplate {
} }
foreach ($NSXTThing in $NSXTThings) { foreach ($NSXTThing in $NSXTThings) {
$results = [NSXTThing]::new() $results = [NSXTThing]::new()
$results.Name = $NSXTThing.display_name; $results.Name = $NSXTThing.display_name;
$results.Logical_router_id = $NSXTThing.Id; $results.Logical_router_id = $NSXTThing.Id;
@@ -1947,7 +1951,7 @@ Function Get-NSXTThingTemplate {
$results.thing2 = $NSXTThing.thing2 $results.thing2 = $NSXTThing.thing2
$results $results
} }
} }
} }
@@ -1957,29 +1961,29 @@ Function Set-NSXTThingTemplate {
.Synopsis .Synopsis
Creates a THING Creates a THING
.DESCRIPTION .DESCRIPTION
Creates a THING with a number of required parameters. Creates a THING with a number of required parameters.
.EXAMPLE .EXAMPLE
Set-NSXTThingTemplateh -param1 "Name" -param2 "TP Zone ID" Set-NSXTThingTemplateh -param1 "Name" -param2 "TP Zone ID"
.EXAMPLE .EXAMPLE
Set-NSXTThingTemplateh -param1 "Name" -param2 "TP Zone ID" Set-NSXTThingTemplateh -param1 "Name" -param2 "TP Zone ID"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='Medium')] ConfirmImpact='Medium')]
# Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types # Paramameter Set variants will be needed Multicast & Broadcast Traffic Types as well as VM & Logical Port Types
Param ( Param (
[parameter(Mandatory=$false)] [parameter(Mandatory=$false)]
[string]$description, [string]$description,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$display_name, [string]$display_name,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$transport_zone_id, [string]$transport_zone_id,
[parameter(Mandatory=$true)] [parameter(Mandatory=$true)]
[ValidateSet("UP","DOWN")] [ValidateSet("UP","DOWN")]
[string]$admin_state, [string]$admin_state,
@@ -2007,7 +2011,7 @@ Function Set-NSXTThingTemplate {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTTHINGService = Get-NsxtService -Name "com.vmware.nsx.THING" $NSXTTHINGService = Get-NsxtService -Name "com.vmware.nsx.THING"
} }
@@ -2027,7 +2031,7 @@ Function Set-NSXTThingTemplate {
{ {
# Should process # Should process
if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool")) if ($pscmdlet.ShouldProcess($ip_pool.display_name, "Create IP Pool"))
{ {
$NSXTTHING = $NSXTTHINGService.create($logical_THING_request) $NSXTTHING = $NSXTTHINGService.create($logical_THING_request)
} }
} }
@@ -2035,7 +2039,7 @@ Function Set-NSXTThingTemplate {
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
$NSXTTHING $NSXTTHING
@@ -2048,12 +2052,12 @@ Function Remove-NSXTThingTemplate {
.Synopsis .Synopsis
Removes an IPAM IP Block Removes an IPAM IP Block
.DESCRIPTION .DESCRIPTION
Removes a IPAM IP Block with a block_id parameter. Removes a IPAM IP Block with a block_id parameter.
.EXAMPLE .EXAMPLE
Remove-NSXTIPAMIPBlock -block_id "id" Remove-NSXTIPAMIPBlock -block_id "id"
#> #>
[CmdletBinding(SupportsShouldProcess=$true, [CmdletBinding(SupportsShouldProcess=$true,
ConfirmImpact='High')] ConfirmImpact='High')]
Param ( Param (
@@ -2077,7 +2081,7 @@ Function Remove-NSXTThingTemplate {
throw "Could not connect to an NSX-T Manager, please try again" throw "Could not connect to an NSX-T Manager, please try again"
} }
} }
$NSXTTHINGkService = Get-NsxtService -Name "com.vmware.nsx.THING" $NSXTTHINGkService = Get-NsxtService -Name "com.vmware.nsx.THING"
} }
@@ -2087,7 +2091,7 @@ Function Remove-NSXTThingTemplate {
{ {
# Should process # Should process
if ($pscmdlet.ShouldProcess($thing_id, "Delete IP Pool")) if ($pscmdlet.ShouldProcess($thing_id, "Delete IP Pool"))
{ {
$NSXTTHINGkService.delete($thing_id) $NSXTTHINGkService.delete($thing_id)
} }
} }
@@ -2095,7 +2099,7 @@ Function Remove-NSXTThingTemplate {
catch catch
{ {
throw $Error[0].Exception.ServerError.data throw $Error[0].Exception.ServerError.data
# more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file. # more error data found in the NSX-T Manager /var/log/vmware/nsx-manager.log file.
} }
} }
} }

View File

@@ -30,18 +30,18 @@ add-type @"
.SYNOPSIS .SYNOPSIS
Push Messages to VMware vRealize Log Insight. Push Messages to VMware vRealize Log Insight.
.DESCRIPTION .DESCRIPTION
Creates a Messages in VMware vRealize Log Insight via the Ingestion API Creates a Messages in VMware vRealize Log Insight via the Ingestion API
.EXAMPLE .EXAMPLE
Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test"
.EXAMPLE .EXAMPLE
Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" -Hostname MyTEST -FieldName myTest -FieldContent myTest Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" -Hostname MyTEST -FieldName myTest -FieldContent myTest
.PARAMETER vLIServer .PARAMETER vLIServer
Specify the FQDN of your vRealize Log Insight Appliance Specify the FQDN of your vRealize Log Insight Appliance
.PARAMETER vLIAgentID .PARAMETER vLIAgentID
Specify the vRealize Log Insight Agent ID, e.g. "12862842-5A6D-679C-0E38-0E2BE888BB28" Specify the vRealize Log Insight Agent ID, e.g. "12862842-5A6D-679C-0E38-0E2BE888BB28"
@@ -54,13 +54,13 @@ add-type @"
.PARAMETER FieldName .PARAMETER FieldName
Specify the a Optional Field Name for vRealize Log Insight Specify the a Optional Field Name for vRealize Log Insight
.PARAMETER FieldContent .PARAMETER FieldContent
Specify the a Optional FieldContent for the Field in -FieldName for vRealize Log Insight Specify the a Optional FieldContent for the Field in -FieldName for vRealize Log Insight
If FielName is missing and FieldContent is given, it will be ignored If FielName is missing and FieldContent is given, it will be ignored
#Requires PS -Version 3.0 #Requires PS -Version 3.0
#> #>
function Push-vLIMessage { function Push-vLIMessage {
@@ -88,9 +88,9 @@ function Push-vLIMessage {
name = "hostname" name = "hostname"
content = $Hostname content = $Hostname
} }
$Fields = @($Field_vLI, $Field_HostName) $Fields = @($Field_vLI, $Field_HostName)
if ($FieldName) { if ($FieldName) {
$Field_Custom = [ordered]@{ $Field_Custom = [ordered]@{
name = $FieldName name = $FieldName
@@ -98,14 +98,14 @@ function Push-vLIMessage {
} }
$Fields += @($Field_Custom) $Fields += @($Field_Custom)
} }
$Restcall = @{ $Restcall = @{
messages = ([Object[]]([ordered]@{ messages = ([Object[]]([ordered]@{
text = ($Text) text = ($Text)
fields = ([Object[]]$Fields) fields = ([Object[]]$Fields)
})) }))
} | convertto-json -Depth 4 } | convertto-json -Depth 4
$Resturl = ("http://" + $vLIServer + ":9000/api/v1/messages/ingest/" + $vLIAgentID) $Resturl = ("http://" + $vLIServer + ":9000/api/v1/messages/ingest/" + $vLIAgentID)
try try
{ {

View File

@@ -1,18 +1,22 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-VMEvcMode { function Get-VMEvcMode {
<# <#
.SYNOPSIS .SYNOPSIS
Gathers information on the EVC status of a VM Gathers information on the EVC status of a VM
.DESCRIPTION .DESCRIPTION
Will provide the EVC status for the specified VM Will provide the EVC status for the specified VM
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name .PARAMETER Name
VM name which the function should be ran against VM name which the function should be ran against
.EXAMPLE .EXAMPLE
Get-VMEvcMode -Name vmName Get-VMEvcMode -Name vmName
Retreives the EVC status of the provided VM Retreives the EVC status of the provided VM
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name $Name
@@ -33,7 +37,7 @@ function Get-VMEvcMode {
} }
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name} elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."} if ($evVM -eq $null) {Write-Warning "No VMs found."}
else { else {
$output = @() $output = @()
@@ -55,20 +59,20 @@ function Get-VMEvcMode {
} }
function Remove-VMEvcMode { function Remove-VMEvcMode {
<# <#
.SYNOPSIS .SYNOPSIS
Removes the EVC status of a VM Removes the EVC status of a VM
.DESCRIPTION .DESCRIPTION
Will remove the EVC status for the specified VM Will remove the EVC status for the specified VM
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name .PARAMETER Name
VM name which the function should be ran against VM name which the function should be ran against
.EXAMPLE .EXAMPLE
Remove-VMEvcMode -Name vmName Remove-VMEvcMode -Name vmName
Removes the EVC status of the provided VM Removes the EVC status of the provided VM
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name $Name
@@ -90,7 +94,7 @@ function Remove-VMEvcMode {
} }
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name} elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."} if ($evVM -eq $null) {Write-Warning "No VMs found."}
else { else {
foreach ($v in $evVM) { foreach ($v in $evVM) {
@@ -99,17 +103,17 @@ function Remove-VMEvcMode {
$v.ExtensionData.ApplyEvcModeVM_Task($null, $true) | Out-Null $v.ExtensionData.ApplyEvcModeVM_Task($null, $true) | Out-Null
$updateVM += $v.Name $updateVM += $v.Name
} }
else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."} else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."}
} }
if ($updateVM) { if ($updateVM) {
Start-Sleep -Seconds 2 Start-Sleep -Seconds 2
Get-VMEvcMode -Name $updateVM Get-VMEvcMode -Name $updateVM
} }
} }
@@ -119,12 +123,12 @@ function Remove-VMEvcMode {
} }
function Set-VMEvcMode { function Set-VMEvcMode {
<# <#
.SYNOPSIS .SYNOPSIS
Configures the EVC status of a VM Configures the EVC status of a VM
.DESCRIPTION .DESCRIPTION
Will configure the EVC status for the specified VM Will configure the EVC status for the specified VM
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name .PARAMETER Name
VM name which the function should be ran against VM name which the function should be ran against
@@ -134,7 +138,7 @@ function Set-VMEvcMode {
Set-VMEvcMode -Name vmName -EvcMode intel-sandybridge Set-VMEvcMode -Name vmName -EvcMode intel-sandybridge
Configures the EVC status of the provided VM to be 'intel-sandybridge' Configures the EVC status of the provided VM to be 'intel-sandybridge'
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name, $Name,
@@ -159,7 +163,7 @@ function Set-VMEvcMode {
} }
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name} elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."} if ($evVM -eq $null) {Write-Warning "No VMs found."}
else { else {
@@ -172,17 +176,17 @@ function Set-VMEvcMode {
$v.ExtensionData.ApplyEvcModeVM_Task($evcMask, $true) | Out-Null $v.ExtensionData.ApplyEvcModeVM_Task($evcMask, $true) | Out-Null
$updateVM += $v.Name $updateVM += $v.Name
} }
else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."} else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."}
} }
if ($updateVM) { if ($updateVM) {
Start-Sleep -Seconds 2 Start-Sleep -Seconds 2
Get-VMEvcMode -Name $updateVM Get-VMEvcMode -Name $updateVM
} }
} }

View File

@@ -1,4 +1,8 @@
Function New-PHAProvider { <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function New-PHAProvider {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================

View File

@@ -1,17 +1,21 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Recommend-Sizing { function Recommend-Sizing {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.11 ver 1.0 Base Release 2016.11 ver 1.0 Base Release
2016.11 ver 1.1 Optional Stats Collection 2016.11 ver 1.1 Optional Stats Collection
2016.11 ver 1.2 VM Stats from Realtime Data and new Counters 2016.11 ver 1.2 VM Stats from Realtime Data and new Counters
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/ http://www.lucd.info/2011/04/22/get-the-maximum-iops/
https://communities.vmware.com/thread/485386 https://communities.vmware.com/thread/485386
=========================================================================== ===========================================================================
@@ -25,16 +29,16 @@ function Recommend-Sizing {
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources. This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources.
.Example .Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose
.Example .Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02 Recommend-Sizing -ClusterNames Cluster01, Cluster02
.Example .Example
Recommend-Sizing -ClusterNames Cluster01 Recommend-Sizing -ClusterNames Cluster01
.PARAMETER ClusterNames .PARAMETER ClusterNames
List of your vSphere Cluser Names to process. List of your vSphere Cluser Names to process.
@@ -53,14 +57,14 @@ function Recommend-Sizing {
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[Array] $ClusterNames, [Array] $ClusterNames,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, ParameterSetName = "Stats")] [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, ParameterSetName = "Stats")]
[switch] $Stats, [switch] $Stats,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2, ParameterSetName = "Stats")] [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2, ParameterSetName = "Stats")]
[int] $StatsRange = 1440 [int] $StatsRange = 1440
) )
Begin { Begin {
if ($Stats) { if ($Stats) {
@@ -70,7 +74,7 @@ Begin {
$Validate = $True $Validate = $True
#region: Check Clusters #region: Check Clusters
Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..." Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..."
foreach ($ClusterName in $ClusterNames) { foreach ($ClusterName in $ClusterNames) {
$TestCluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue -Verbose:$False $TestCluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue -Verbose:$False
if(!($TestCluster)){ if(!($TestCluster)){
@@ -82,7 +86,7 @@ Begin {
$Validate = $False $Validate = $False
} }
} }
Write-Verbose "$(Get-Date -Format G) Cluster Validation completed" Write-Verbose "$(Get-Date -Format G) Cluster Validation completed"
#endregion #endregion
} }
@@ -91,7 +95,7 @@ Process {
if ($Validate -eq $True) { if ($Validate -eq $True) {
foreach ($ClusterName in $ClusterNames) { foreach ($ClusterName in $ClusterNames) {
#region: Get Cluster Objects #region: Get Cluster Objects
Write-Verbose "$(Get-Date -Format G) Collect $ClusterName Cluster Objects..." Write-Verbose "$(Get-Date -Format G) Collect $ClusterName Cluster Objects..."
$Cluster = Get-Cluster -Name $ClusterName -Verbose:$False $Cluster = Get-Cluster -Name $ClusterName -Verbose:$False
$ClusterVMs = $Cluster | Get-VM -Verbose:$False $ClusterVMs = $Cluster | Get-VM -Verbose:$False
$ClusterVMsPoweredOn = $ClusterVMs | where {$_.PowerState -eq "PoweredOn"} $ClusterVMsPoweredOn = $ClusterVMs | where {$_.PowerState -eq "PoweredOn"}
@@ -101,24 +105,24 @@ Process {
$HostsAverageMemoryUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property MemoryUsageGB).Average / ($ClusterHosts | Measure-Object -Average -Property MemoryTotalGB).Average) * 100,1 )) $HostsAverageMemoryUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property MemoryUsageGB).Average / ($ClusterHosts | Measure-Object -Average -Property MemoryTotalGB).Average) * 100,1 ))
$HostsAverageCpuUsageMhz = [math]::round( ($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average,1 ) $HostsAverageCpuUsageMhz = [math]::round( ($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average,1 )
$HostsAverageCpuUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average / ($ClusterHosts | Measure-Object -Average -Property CpuTotalMhz).Average) * 100,1 )) $HostsAverageCpuUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average / ($ClusterHosts | Measure-Object -Average -Property CpuTotalMhz).Average) * 100,1 ))
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Cluster Objects completed" Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Cluster Objects completed"
#endregion #endregion
#region: CPU Calculation #region: CPU Calculation
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details..." Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details..."
$VMvCPUs = ($ClusterVMs | Measure-Object -Sum -Property NumCpu).sum $VMvCPUs = ($ClusterVMs | Measure-Object -Sum -Property NumCpu).sum
$LogicalThreads = $Cluster.ExtensionData.Summary.NumCpuThreads $LogicalThreads = $Cluster.ExtensionData.Summary.NumCpuThreads
$CpuCores = $Cluster.ExtensionData.Summary.NumCpuCores $CpuCores = $Cluster.ExtensionData.Summary.NumCpuCores
$vCPUpCPUratio = [math]::round( $VMvCPUs / $LogicalThreads,1 ) $vCPUpCPUratio = [math]::round( $VMvCPUs / $LogicalThreads,1 )
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details completed." Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details completed."
#endregion #endregion
#region: Memory Calculation #region: Memory Calculation
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details..." Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details..."
$AllocatedVMMemoryGB = [math]::round( ($ClusterVMs | Measure-Object -Sum -Property MemoryGB).sum ) $AllocatedVMMemoryGB = [math]::round( ($ClusterVMs | Measure-Object -Sum -Property MemoryGB).sum )
$PhysicalMemory = [math]::round( $Cluster.ExtensionData.Summary.TotalMemory / 1073741824,1 ) $PhysicalMemory = [math]::round( $Cluster.ExtensionData.Summary.TotalMemory / 1073741824,1 )
$MemoryUsage = [math]::round( ($AllocatedVMMemoryGB / $PhysicalMemory) * 100 ,1 ) $MemoryUsage = [math]::round( ($AllocatedVMMemoryGB / $PhysicalMemory) * 100 ,1 )
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed" Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed"
#endregion #endregion
if ($Stats) { if ($Stats) {
@@ -129,10 +133,10 @@ Process {
$VMStats = Get-Stat -Realtime -Stat $VMMetrics -Entity $ClusterVMsPoweredOn -Start $Start -Verbose:$False $VMStats = Get-Stat -Realtime -Stat $VMMetrics -Entity $ClusterVMsPoweredOn -Start $Start -Verbose:$False
Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) VM Stats completed" Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) VM Stats completed"
#endregion #endregion
#region: Creating VM Stats Report #region: Creating VM Stats Report
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Stats Report..." Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Stats Report..."
$ReportVMPerf = @() $ReportVMPerf = @()
$ReportVMPerf = $VMStats | Group-Object -Property {$_.Entity.Name},Instance | %{ $ReportVMPerf = $VMStats | Group-Object -Property {$_.Entity.Name},Instance | %{
New-Object PSObject -Property @{ New-Object PSObject -Property @{
IOPSWriteAvg = ($_.Group | ` IOPSWriteAvg = ($_.Group | `
@@ -168,7 +172,7 @@ Process {
CapacityGB = $CapacityGB CapacityGB = $CapacityGB
} }
$reportDiskSpace += $Report $reportDiskSpace += $Report
} }
} }
} }
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report completed" Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report completed"
@@ -188,9 +192,9 @@ Process {
DrsEnabled = $Cluster.DrsEnabled DrsEnabled = $Cluster.DrsEnabled
Hosts = $Cluster.ExtensionData.Summary.NumHosts Hosts = $Cluster.ExtensionData.Summary.NumHosts
HostsAverageMemoryUsageGB = $HostsAverageMemoryUsageGB HostsAverageMemoryUsageGB = $HostsAverageMemoryUsageGB
HostsAverageMemoryUsage = "$HostsAverageMemoryUsage %" HostsAverageMemoryUsage = "$HostsAverageMemoryUsage %"
HostsAverageCpuUsageMhz = $HostsAverageCpuUsageMhz HostsAverageCpuUsageMhz = $HostsAverageCpuUsageMhz
HostsAverageCpuUsage = "$HostsAverageCpuUsage %" HostsAverageCpuUsage = "$HostsAverageCpuUsage %"
PhysicalCPUCores = $CpuCores PhysicalCPUCores = $CpuCores
LogicalCPUThreads = $LogicalThreads LogicalCPUThreads = $LogicalThreads
VMs = $ClusterVMs.count VMs = $ClusterVMs.count
@@ -198,7 +202,7 @@ Process {
VMvCPUs = $VMvCPUs VMvCPUs = $VMvCPUs
vCPUpCPUratio = "$vCPUpCPUratio : 1" vCPUpCPUratio = "$vCPUpCPUratio : 1"
PhysicalMemoryGB = $PhysicalMemory PhysicalMemoryGB = $PhysicalMemory
AllocatedVMMemoryGB = $AllocatedVMMemoryGB AllocatedVMMemoryGB = $AllocatedVMMemoryGB
ClusterMemoryUsage = "$MemoryUsage %" ClusterMemoryUsage = "$MemoryUsage %"
SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 ) SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 )
SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 ) SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 )
@@ -217,7 +221,7 @@ Process {
Else { Else {
Write-Error "Validation Failed! Processing Skipped" Write-Error "Validation Failed! Processing Skipped"
} }
} }
End { End {

View File

@@ -1,4 +1,13 @@
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
# It is assumed that the connection to VC and SRM Server have already been made # It is assumed that the connection to VC and SRM Server have already been made
Function Get-SrmConfigReportSite { Function Get-SrmConfigReportSite {
@@ -151,7 +160,7 @@ Function Get-SrmConfigReportProtectedVm {
@{Label="Final Power State"; Expression={$_.finalPowerState} }, @{Label="Final Power State"; Expression={$_.finalPowerState} },
@{Label="Pre-PowerOn Callouts"; Expression={$_.preCallouts} }, @{Label="Pre-PowerOn Callouts"; Expression={$_.preCallouts} },
@{Label="Post-PowerOn Callouts"; Expression={$_.postCallouts} } @{Label="Post-PowerOn Callouts"; Expression={$_.postCallouts} }
} }
Function Get-SrmConfigReport { Function Get-SrmConfigReport {

View File

@@ -1,4 +1,13 @@
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
# It is assumed that the connections to active VC and SRM Server have already been made # It is assumed that the connections to active VC and SRM Server have already been made
Import-Module Meadowcroft.SRM -Prefix Srm Import-Module Meadowcroft.SRM -Prefix Srm

View File

@@ -2,7 +2,7 @@
Version 2.0, January 2004 Version 2.0, January 2004
http://www.apache.org/licenses/ http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions. 1. Definitions.
@@ -55,7 +55,7 @@ APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner] Copyright 2017-2021 VMware, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -65,9 +65,9 @@ To apply the Apache License to your work, attach the following boilerplate notic
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.

View File

@@ -1,4 +1,13 @@
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<# <#
.SYNOPSIS .SYNOPSIS
@@ -48,7 +57,7 @@ Function Get-ProtectionGroup {
$pgi = $pg.GetInfo() $pgi = $pg.GetInfo()
$selected = (-not $Name -or ($Name -eq $pgi.Name)) -and (-not $Type -or ($Type -eq $pgi.Type)) $selected = (-not $Name -or ($Name -eq $pgi.Name)) -and (-not $Type -or ($Type -eq $pgi.Type))
if ($selected) { if ($selected) {
Add-Member -InputObject $pg -MemberType NoteProperty -Name "Name" -Value $pgi.Name Add-Member -InputObject $pg -MemberType NoteProperty -Name "Name" -Value $pgi.Name
$pg $pg
} }
} }
@@ -95,7 +104,7 @@ Function Get-ProtectedVM {
try { try {
$_.Vm.UpdateViewData() $_.Vm.UpdateViewData()
} catch { } catch {
Write-Error $_ Write-Error $_
} finally { } finally {
$_ $_
} }
@@ -359,7 +368,7 @@ Function New-ProtectionGroup {
if ($pscmdlet.ShouldProcess($Name, "New")) { if ($pscmdlet.ShouldProcess($Name, "New")) {
$task = $api.Protection.CreateHbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs) $task = $api.Protection.CreateHbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs)
} }
} elseif ($ArrayReplication) { } elseif ($ArrayReplication) {
#create list of managed object references from VM and/or VM view arrays #create list of managed object references from VM and/or VM view arrays
$moRefs = @() $moRefs = @()
@@ -373,7 +382,7 @@ Function New-ProtectionGroup {
if ($pscmdlet.ShouldProcess($Name, "New")) { if ($pscmdlet.ShouldProcess($Name, "New")) {
$task = $api.Protection.CreateAbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs) $task = $api.Protection.CreateAbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs)
} }
} else { } else {
throw "Undetermined protection group type" throw "Undetermined protection group type"
} }
@@ -386,7 +395,7 @@ Function New-ProtectionGroup {
if ($pg) { if ($pg) {
$unProtectedVMs = Get-UnProtectedVM -ProtectionGroup $pg $unProtectedVMs = Get-UnProtectedVM -ProtectionGroup $pg
$unProtectedVMs | Protect-VM -ProtectionGroup $pg $unProtectedVMs | Protect-VM -ProtectionGroup $pg
} }
return $pg return $pg
} }

View File

@@ -1,4 +1,13 @@
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<# <#
.SYNOPSIS .SYNOPSIS
@@ -121,13 +130,13 @@ Function Get-RecoveryPlanResult {
[DateTime] $startedBefore, [DateTime] $startedBefore,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer [VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
) )
$api = Get-ServerApiEndpoint -SrmServer $SrmServer $api = Get-ServerApiEndpoint -SrmServer $SrmServer
# Get the history objects # Get the history objects
$history = $api.Recovery.GetHistory($RecoveryPlan.MoRef) $history = $api.Recovery.GetHistory($RecoveryPlan.MoRef)
$resultCount = $history.GetResultCount() $resultCount = $history.GetResultCount()
if ($resultCount -gt 0) { if ($resultCount -gt 0) {
$results = $history.GetRecoveryResult($resultCount) $results = $history.GetRecoveryResult($resultCount)
@@ -270,7 +279,7 @@ Function Set-RecoverySetting {
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings [Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings
) )
$moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView -ProtectedVm $ProtectedVm $moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView -ProtectedVm $ProtectedVm
if ($RecoveryPlan -and $moRef -and $RecoverySettings) { if ($RecoveryPlan -and $moRef -and $RecoverySettings) {
@@ -416,9 +425,9 @@ Function Add-PostRecoveryCommand {
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings, [Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand [Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand
) )
Add_Command -RecoverySettings $RecoverySettings -SrmCommand $SrmCommand -PostRecovery $true Add_Command -RecoverySettings $RecoverySettings -SrmCommand $SrmCommand -PostRecovery $true
return $RecoverySettings return $RecoverySettings
} }
@@ -446,7 +455,7 @@ Function Remove-PostRecoveryCommand {
if ($pscmdlet.ShouldProcess($SrmCommand.Description, "Remove")) { if ($pscmdlet.ShouldProcess($SrmCommand.Description, "Remove")) {
$RecoverySettings.PostPowerOnCallouts.Remove($SrmCommand) $RecoverySettings.PostPowerOnCallouts.Remove($SrmCommand)
} }
return $RecoverySettings return $RecoverySettings
} }
@@ -494,7 +503,7 @@ Function New-RecoveryPlan {
$protectionGroupmRefs += @( $ProtectionGroups | ForEach-Object { $_.MoRef } | Select-Object -Unique) $protectionGroupmRefs += @( $ProtectionGroups | ForEach-Object { $_.MoRef } | Select-Object -Unique)
[VMware.VimAutomation.Srm.Views.CreateRecoveryPlanTask] $task = $null [VMware.VimAutomation.Srm.Views.CreateRecoveryPlanTask] $task = $null
if ($PSCmdlet.ShouldProcess($Name, "New")) { if ($PSCmdlet.ShouldProcess($Name, "New")) {
$task = $api.Recovery.CreateRecoveryPlan( $task = $api.Recovery.CreateRecoveryPlan(
$Name, $Name,

View File

@@ -1,4 +1,13 @@
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<# <#
.SYNOPSIS .SYNOPSIS

View File

@@ -1,4 +1,13 @@
# <#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
#
# Module manifest for module 'Meadowcroft.Srm' # Module manifest for module 'Meadowcroft.Srm'
# #

View File

@@ -1,3 +1,11 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets # SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<# <#

View File

@@ -1,7 +1,10 @@
Copyright (c) 2017 VMware, Inc. All Rights Reserved. Copyright (c) 2017-2021 VMware, Inc. All Rights Reserved.
This product is licensed to you under the Apache License version 2.0 (the "License"). You may not use this product except in compliance with the License. This product is licensed to you under the Apache License version 2.0 (the "License"). You may not use this product except in compliance with the License.
This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
Copyright (c) 2021 VMware, Inc. All Rights Reserved.
This product is licensed to you under the BSD-2-Clause License. You may not use this product except in compliance with the License.

View File

@@ -1,15 +1,15 @@
function Set-CBT { function Set-CBT {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.11 ver 1.0 Base Release 2016.11 ver 1.0 Base Release
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
http://wahlnetwork.com/2015/12/01/change-block-tracking-cbt-powercli/ http://wahlnetwork.com/2015/12/01/change-block-tracking-cbt-powercli/
=========================================================================== ===========================================================================
Tested Against Environment: Tested Against Environment:
@@ -22,13 +22,13 @@ function Set-CBT {
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This Function enables or disables CBT. This Function enables or disables CBT.
.Example .Example
Get-VN TST* | Set-CBT -DisableCBT Get-VN TST* | Set-CBT -DisableCBT
.Example .Example
Get-VN TST* | Set-CBT -EnableCBT Get-VN TST* | Set-CBT -EnableCBT
.PARAMETER DisableCBT .PARAMETER DisableCBT
Disables CBT for any VMs found with it enabled Disables CBT for any VMs found with it enabled
@@ -41,7 +41,7 @@ function Set-CBT {
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")] [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs, [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs,
@@ -52,7 +52,7 @@ function Set-CBT {
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[Switch]$DisableCBT [Switch]$DisableCBT
) )
Process { Process {
$vmconfigspec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec $vmconfigspec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec
Write-Verbose -Message "Walking through given VMs" Write-Verbose -Message "Walking through given VMs"
@@ -60,7 +60,7 @@ Process {
{ {
if ($DisableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $true -and $myVM.ExtensionData.Snapshot -eq $null) if ($DisableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $true -and $myVM.ExtensionData.Snapshot -eq $null)
{ {
try try
{ {
Write-Verbose -Message "Reconfiguring $($myVM.name) to disable CBT" -Verbose Write-Verbose -Message "Reconfiguring $($myVM.name) to disable CBT" -Verbose
$vmconfigspec.ChangeTrackingEnabled = $false $vmconfigspec.ChangeTrackingEnabled = $false
@@ -75,7 +75,7 @@ Process {
} }
} }
catch catch
{ {
throw $myVM throw $myVM
} }
@@ -94,13 +94,13 @@ Process {
$SnapShot | Remove-Snapshot -Confirm:$false $SnapShot | Remove-Snapshot -Confirm:$false
} }
} }
else else
{ {
if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT) if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT)
{ {
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" Write-Warning -Message "Skipping $($myVM.name) - Snapshots found"
} }
elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT) elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT)
{ {
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" Write-Warning -Message "Skipping $($myVM.name) - Snapshots found"
} }

View File

@@ -1,40 +1,44 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Start-UNMAP { function Start-UNMAP {
<# <#
.SYNOPSIS .SYNOPSIS
Process SCSI UNMAP on VMware Datastores Process SCSI UNMAP on VMware Datastores
.DESCRIPTION .DESCRIPTION
This Function will process SCSI UNMAP on VMware Datastores via ESXCLI -V2 This Function will process SCSI UNMAP on VMware Datastores via ESXCLI -V2
.Example .Example
Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5*
.Example .Example
Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* -Verbose -WhatIf Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* -Verbose -WhatIf
.Notes .Notes
NAME: Start-UNMAP.psm1 NAME: Start-UNMAP.psm1
AUTHOR: Markus Kraus AUTHOR: Markus Kraus
LASTEDIT: 23.09.2016 LASTEDIT: 23.09.2016
VERSION: 1.0 VERSION: 1.0
KEYWORDS: VMware, vSphere, ESXi, SCSI, VAAI, UNMAP KEYWORDS: VMware, vSphere, ESXi, SCSI, VAAI, UNMAP
.Link .Link
http://mycloudrevolution.com/ http://mycloudrevolution.com/
#Requires PS -Version 4.0 #Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#> #>
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact='High')] [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
param( param(
[Parameter(Mandatory=$true, Position=0)] [Parameter(Mandatory=$true, Position=0)]
[String]$ClusterName, [String]$ClusterName,
[Parameter(Mandatory=$true, Position=1)] [Parameter(Mandatory=$true, Position=1)]
[String]$DSWildcard [String]$DSWildcard
) )
Process { Process {
$Validate = $true $Validate = $true
#region: PowerCLI Session Timeout #region: PowerCLI Session Timeout
Write-Verbose "Set Session Timeout ..." Write-Verbose "Set Session Timeout ..."
$initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds $initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds
@@ -90,10 +94,10 @@ function Start-UNMAP {
} }
#endregion #endregion
#region: Revert PowerCLI Session Timeout #region: Revert PowerCLI Session Timeout
Write-Verbose "Revert Session Timeout ..." Write-Verbose "Revert Session Timeout ..."
Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds $initialTimeout -Confirm:$False | Out-Null Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds $initialTimeout -Confirm:$False | Out-Null
#endregion #endregion
} }
} }

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VAMISummary { Function Get-VAMISummary {
<# <#
.NOTES .NOTES
@@ -201,7 +206,7 @@ Function Set-VAMITimeSync {
[Parameter(Mandatory=$false,HelpMessage="NTP Servers need to be either a string separated by ',' or an array of servers")] [Parameter(Mandatory=$false,HelpMessage="NTP Servers need to be either a string separated by ',' or an array of servers")]
$NTPServers $NTPServers
) )
$timeSyncMode = ( Get-VAMIServiceAPI -NameFilter "timesync").get() $timeSyncMode = ( Get-VAMIServiceAPI -NameFilter "timesync").get()
if ($timeSyncMode.gettype().name -eq "PSCustomObject") { if ($timeSyncMode.gettype().name -eq "PSCustomObject") {
if ($SyncMode.ToUpper() -ne $timeSyncMode.mode.toupper()) { if ($SyncMode.ToUpper() -ne $timeSyncMode.mode.toupper()) {
@@ -746,7 +751,7 @@ Function New-VAMIUser {
$CreateSpec.role = $Role $CreateSpec.role = $Role
$CreateSpec.email = $Email $CreateSpec.email = $Email
$CreateSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$Password $CreateSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$Password
if ($CreateSpec.psobject.properties.name -contains "username") { if ($CreateSpec.psobject.properties.name -contains "username") {
$CreateSpec.username = $Name $CreateSpec.username = $Name
try { try {

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VCHAConfig { Function Get-VCHAConfig {
<# <#
.NOTES .NOTES

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VCSAPasswordPolicy { Function Get-VCSAPasswordPolicy {
<# <#
.DESCRIPTION Retrieves vCenter Server Appliance SSO and Local OS Password Policy Configuration .DESCRIPTION Retrieves vCenter Server Appliance SSO and Local OS Password Policy Configuration

View File

@@ -1,5 +1,9 @@
function Get-VMCPSettings { <#
<# Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-VMCPSettings {
<#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created on: 10/27/2015 9:25 PM Created on: 10/27/2015 9:25 PM
@@ -11,7 +15,7 @@
Modified on: 10/11/2016 Modified on: 10/11/2016
Modified by: Erwan Quélin Modified by: Erwan Quélin
Twitter: @erwanquelin Twitter: @erwanquelin
Github: https://github.com/equelin Github: https://github.com/equelin
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This function will allow users to view the VMCP settings for their clusters This function will allow users to view the VMCP settings for their clusters
@@ -94,7 +98,7 @@
} }
function Set-VMCPSettings { function Set-VMCPSettings {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created on: 10/27/2015 9:25 PM Created on: 10/27/2015 9:25 PM
@@ -106,7 +110,7 @@ function Set-VMCPSettings {
Modified on: 10/11/2016 Modified on: 10/11/2016
Modified by: Erwan Quélin Modified by: Erwan Quélin
Twitter: @erwanquelin Twitter: @erwanquelin
Github: https://github.com/equelin Github: https://github.com/equelin
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This function will allow users to enable/disable VMCP and also allow This function will allow users to enable/disable VMCP and also allow
@@ -147,21 +151,21 @@ function Set-VMCPSettings {
.EXAMPLE .EXAMPLE
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$True -VmStorageProtectionForPDL ` Set-VMCPSettings -cluster LAB-CL -enableVMCP:$True -VmStorageProtectionForPDL `
restartAggressive -VmStorageProtectionForAPD restartAggressive ` restartAggressive -VmStorageProtectionForAPD restartAggressive `
-VmTerminateDelayForAPDSec 2000 -VmReactionOnAPDCleared reset -VmTerminateDelayForAPDSec 2000 -VmReactionOnAPDCleared reset
This will enable VMCP and configure the Settings on cluster LAB-CL This will enable VMCP and configure the Settings on cluster LAB-CL
.EXAMPLE .EXAMPLE
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$False -VmStorageProtectionForPDL ` Set-VMCPSettings -cluster LAB-CL -enableVMCP:$False -VmStorageProtectionForPDL `
disabled -VmStorageProtectionForAPD disabled ` disabled -VmStorageProtectionForAPD disabled `
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none -VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
This will disable VMCP and configure the Settings on cluster LAB-CL This will disable VMCP and configure the Settings on cluster LAB-CL
.EXAMPLE .EXAMPLE
Set-VMCPSettings -enableVMCP:$False -VmStorageProtectionForPDL ` Set-VMCPSettings -enableVMCP:$False -VmStorageProtectionForPDL `
disabled -VmStorageProtectionForAPD disabled ` disabled -VmStorageProtectionForAPD disabled `
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none -VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
This will disable VMCP and configure the Settings on all clusters available This will disable VMCP and configure the Settings on all clusters available
#> #>
@@ -173,7 +177,7 @@ function Set-VMCPSettings {
ValueFromPipelineByPropertyName=$True, ValueFromPipelineByPropertyName=$True,
HelpMessage='What is the Cluster Name?')] HelpMessage='What is the Cluster Name?')]
$cluster, $cluster,
[Parameter(Mandatory=$False, [Parameter(Mandatory=$False,
ValueFromPipeline=$False, ValueFromPipeline=$False,
HelpMessage='$True=Enabled $False=Disabled')] HelpMessage='$True=Enabled $False=Disabled')]
@@ -184,24 +188,24 @@ function Set-VMCPSettings {
HelpMessage='Actions that can be taken in response to a PDL event')] HelpMessage='Actions that can be taken in response to a PDL event')]
[ValidateSet("disabled","warning","restartAggressive")] [ValidateSet("disabled","warning","restartAggressive")]
[string]$VmStorageProtectionForPDL, [string]$VmStorageProtectionForPDL,
[Parameter(Mandatory=$False, [Parameter(Mandatory=$False,
ValueFromPipeline=$False, ValueFromPipeline=$False,
HelpMessage='Options available for an APD response')] HelpMessage='Options available for an APD response')]
[ValidateSet("disabled","restartConservative","restartAggressive","warning")] [ValidateSet("disabled","restartConservative","restartAggressive","warning")]
[string]$VmStorageProtectionForAPD, [string]$VmStorageProtectionForAPD,
[Parameter(Mandatory=$False, [Parameter(Mandatory=$False,
ValueFromPipeline=$False, ValueFromPipeline=$False,
HelpMessage='Value in seconds')] HelpMessage='Value in seconds')]
[Int]$VmTerminateDelayForAPDSec, [Int]$VmTerminateDelayForAPDSec,
[Parameter(Mandatory=$False, [Parameter(Mandatory=$False,
ValueFromPipeline=$False, ValueFromPipeline=$False,
HelpMessage='This setting will instruct vSphere HA to take a certain action if an APD event is cleared')] HelpMessage='This setting will instruct vSphere HA to take a certain action if an APD event is cleared')]
[ValidateSet("reset","none")] [ValidateSet("reset","none")]
[string]$VmReactionOnAPDCleared, [string]$VmReactionOnAPDCleared,
[Parameter(Mandatory=$False)] [Parameter(Mandatory=$False)]
[VMware.VimAutomation.Types.VIServer[]]$Server = $global:DefaultVIServers [VMware.VimAutomation.Types.VIServer[]]$Server = $global:DefaultVIServers
) )
@@ -232,14 +236,14 @@ function Set-VMCPSettings {
# Create the object we will configure # Create the object we will configure
$settings = New-Object VMware.Vim.ClusterConfigSpecEx $settings = New-Object VMware.Vim.ClusterConfigSpecEx
$settings.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo $settings.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
# Based on $enableVMCP switch # Based on $enableVMCP switch
if ($enableVMCP -eq $false) { if ($enableVMCP -eq $false) {
$settings.dasConfig.vmComponentProtecting = "disabled" $settings.dasConfig.vmComponentProtecting = "disabled"
} }
elseif ($enableVMCP -eq $true) { elseif ($enableVMCP -eq $true) {
$settings.dasConfig.vmComponentProtecting = "enabled" $settings.dasConfig.vmComponentProtecting = "enabled"
} }
#Create the VMCP object to work with #Create the VMCP object to work with
$settings.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings $settings.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings
@@ -295,7 +299,7 @@ function Set-VMCPSettings {
} else { } else {
$settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmTerminateDelayForAPDSec = $ActualSettings.'APD Timeout (Seconds)' $settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmTerminateDelayForAPDSec = $ActualSettings.'APD Timeout (Seconds)'
} }
# Reaction On APD Cleared # Reaction On APD Cleared
If ($PSBoundParameters.ContainsKey('VmReactionOnAPDCleared')) { If ($PSBoundParameters.ContainsKey('VmReactionOnAPDCleared')) {
$settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmReactionOnAPDCleared = "$VmReactionOnAPDCleared" $settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmReactionOnAPDCleared = "$VmReactionOnAPDCleared"

View File

@@ -1,4 +1,8 @@
Function Get-CSPAccessToken { <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-CSPAccessToken {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.Community.CISTag' # Module manifest for module 'VMware.Community.CISTag'
# #

View File

@@ -1,25 +1,29 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-CISTag { function Get-CISTag {
<# <#
.SYNOPSIS .SYNOPSIS
Gathers tag information from the CIS REST API endpoint Gathers tag information from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will provide a list of tags Will provide a list of tags
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag name which should be retreived Tag name which should be retreived
.PARAMETER Category .PARAMETER Category
Tag category name which should be retreived Tag category name which should be retreived
.PARAMETER Id .PARAMETER Id
Tag ID which should be retreived Tag ID which should be retreived
.EXAMPLE .EXAMPLE
Get-CISTag Get-CISTag
Retreives all tag information Retreives all tag information
.EXAMPLE .EXAMPLE
Get-CISTag -Name tagName Get-CISTag -Name tagName
Retreives the tag information based on the specified name Retreives the tag information based on the specified name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param( param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name, [String]$Name,
@@ -30,7 +34,7 @@ function Get-CISTag {
) )
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else { If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag $tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
if ($PSBoundParameters.ContainsKey("Id")) { if ($PSBoundParameters.ContainsKey("Id")) {
$tagOutput = $tagSvc.get($Id) $tagOutput = $tagSvc.get($Id)
} else { } else {
@@ -50,9 +54,9 @@ function Get-CISTag {
if ($PSBoundParameters.ContainsKey("Name")) { if ($PSBoundParameters.ContainsKey("Name")) {
if ($vCenterConn){ if ($vCenterConn){
$tagOutput = $vCTagList | Where-Object {$_.Name -eq $Name} $tagOutput = $vCTagList | Where-Object {$_.Name -eq $Name}
} else {$tagOutput = $tagArray | Where-Object {$_.Name -eq $Name}} } else {$tagOutput = $tagArray | Where-Object {$_.Name -eq $Name}}
} elseif ($PSBoundParameters.ContainsKey("Category")) { } elseif ($PSBoundParameters.ContainsKey("Category")) {
if ($vCenterConn){ if ($vCenterConn){
$tagOutput = $vCTagList | Where-Object {$_.Category -eq $Category} $tagOutput = $vCTagList | Where-Object {$_.Category -eq $Category}
} else { } else {
$tagCatid = Get-CISTagCategory -Name $Category | Select-Object -ExpandProperty Id $tagCatid = Get-CISTagCategory -Name $Category | Select-Object -ExpandProperty Id
@@ -74,12 +78,12 @@ function Get-CISTag {
} }
function New-CISTag { function New-CISTag {
<# <#
.SYNOPSIS .SYNOPSIS
Creates a new tag from the CIS REST API endpoint Creates a new tag from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will create a new tag Will create a new tag
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag name which should be created Tag name which should be created
@@ -93,7 +97,7 @@ function New-CISTag {
New-CISTag -Name tagName -Category categoryName -Description "Tag Descrition" New-CISTag -Name tagName -Category categoryName -Description "Tag Descrition"
Creates a new tag based on the specified name Creates a new tag based on the specified name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param( param(
[Parameter(Mandatory=$true,Position=0)] [Parameter(Mandatory=$true,Position=0)]
[String]$Name, [String]$Name,
@@ -106,7 +110,7 @@ function New-CISTag {
) )
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else { If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag $tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
$tagCreateHelper = $tagSvc.Help.create.create_spec.Create() $tagCreateHelper = $tagSvc.Help.create.create_spec.Create()
$tagCreateHelper.name = $Name $tagCreateHelper.name = $Name
if ($PSBoundParameters.ContainsKey("Category")) { if ($PSBoundParameters.ContainsKey("Category")) {
@@ -126,22 +130,22 @@ function New-CISTag {
} }
function Remove-CISTag { function Remove-CISTag {
<# <#
.SYNOPSIS .SYNOPSIS
Removes a tag from the CIS REST API endpoint Removes a tag from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will delete a new tag Will delete a new tag
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag name which should be removed Tag name which should be removed
.PARAMETER ID .PARAMETER ID
Tag ID which should be removed Tag ID which should be removed
.EXAMPLE .EXAMPLE
Remove-CISTag -Name tagName Remove-CISTag -Name tagName
Removes a new tag based on the specified name Removes a new tag based on the specified name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param( param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name, [String]$Name,
@@ -150,7 +154,7 @@ function Remove-CISTag {
) )
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else { If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag $tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
if ($ID) { if ($ID) {
$tagSvc.delete($ID) $tagSvc.delete($ID)
} else { } else {
@@ -162,25 +166,25 @@ function Remove-CISTag {
} }
function Get-CISTagCategory { function Get-CISTagCategory {
<# <#
.SYNOPSIS .SYNOPSIS
Gathers tag category information from the CIS REST API endpoint Gathers tag category information from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will provide a list of tag categories Will provide a list of tag categories
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag category name which should be retreived Tag category name which should be retreived
.PARAMETER Id .PARAMETER Id
Tag category ID which should be retreived Tag category ID which should be retreived
.EXAMPLE .EXAMPLE
Get-CISTagCategory Get-CISTagCategory
Retreives all tag category information Retreives all tag category information
.EXAMPLE .EXAMPLE
Get-CISTagCategory -Name tagCategoryName Get-CISTagCategory -Name tagCategoryName
Retreives the tag category information based on the specified name Retreives the tag category information based on the specified name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param( param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name, [String]$Name,
@@ -210,26 +214,26 @@ function Get-CISTagCategory {
} }
function New-CISTagCategory { function New-CISTagCategory {
<# <#
.SYNOPSIS .SYNOPSIS
Creates a new tag category from the CIS REST API endpoint Creates a new tag category from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will create a new tag category Will create a new tag category
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag category name which should be created Tag category name which should be created
.PARAMETER Description .PARAMETER Description
Tag category ID which should be retreived Tag category ID which should be retreived
.PARAMETER Cardinality .PARAMETER Cardinality
Tag category ID which should be retreived Tag category ID which should be retreived
.PARAMETER AssociableTypes .PARAMETER AssociableTypes
Tag category ID which should be retreived Tag category ID which should be retreived
.EXAMPLE .EXAMPLE
New-CISTagCategory -Name NewTagCategoryName -Description "New Tag Category Description" -Cardinality "Single" -AssociableTypes New-CISTagCategory -Name NewTagCategoryName -Description "New Tag Category Description" -Cardinality "Single" -AssociableTypes
Creates a new tag category with the specified information Creates a new tag category with the specified information
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param( param(
[Parameter(Mandatory=$true,Position=0)] [Parameter(Mandatory=$true,Position=0)]
[String]$Name, [String]$Name,
@@ -261,15 +265,15 @@ function New-CISTagCategory {
} }
function Remove-CISTagCategory { function Remove-CISTagCategory {
<# <#
.SYNOPSIS .SYNOPSIS
Removes tag category information from the CIS REST API endpoint Removes tag category information from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will remove a tag category Will remove a tag category
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Name .PARAMETER Name
Tag category name which should be removed Tag category name which should be removed
.PARAMETER Id .PARAMETER Id
Tag category ID which should be removed Tag category ID which should be removed
.EXAMPLE .EXAMPLE
@@ -277,7 +281,7 @@ function Remove-CISTagCategory {
Removes the tag category information based on the specified name Removes the tag category information based on the specified name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param( param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name, [String]$Name,
@@ -297,12 +301,12 @@ function Remove-CISTagCategory {
} }
function Get-CISTagAssignment { function Get-CISTagAssignment {
<# <#
.SYNOPSIS .SYNOPSIS
Displays a list of the tag assignments from the CIS REST API endpoint Displays a list of the tag assignments from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will provide a list of the tag assignments Will provide a list of the tag assignments
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Category .PARAMETER Category
Tag category name which should be referenced Tag category name which should be referenced
@@ -311,7 +315,7 @@ function Get-CISTagAssignment {
.PARAMETER ObjectId .PARAMETER ObjectId
Object ID which should be retreived Object ID which should be retreived
.EXAMPLE .EXAMPLE
Get-CISTagAssignment Get-CISTagAssignment
Retreives all tag assignment information Retreives all tag assignment information
.EXAMPLE .EXAMPLE
Get-CISTagAssignment -Entity VMName Get-CISTagAssignment -Entity VMName
@@ -320,7 +324,7 @@ function Get-CISTagAssignment {
Get-CISTagAssignment -ObjectId 'vm-11' Get-CISTagAssignment -ObjectId 'vm-11'
Retreives all tag assignments for the VM object Retreives all tag assignments for the VM object
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param( param(
[Parameter(Mandatory=$false,Position=0)] [Parameter(Mandatory=$false,Position=0)]
[String]$Category, [String]$Category,
@@ -357,7 +361,7 @@ function Get-CISTagAssignment {
$filterVmNameObj.names.add($Entity) | Out-Null $filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm $objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"} if ($objId) {$objType = "VirtualMachine"}
else { else {
$dsSvc = Get-CisService com.vmware.vcenter.datastore $dsSvc = Get-CisService com.vmware.vcenter.datastore
$filterDsNameObj = $dsSvc.Help.list.filter.Create() $filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null $filterDsNameObj.names.add($Entity) | Out-Null
@@ -371,7 +375,7 @@ function Get-CISTagAssignment {
} }
$tagIdOutput = $tagAssocSvc.list_attached_tags($objObject) $tagIdOutput = $tagAssocSvc.list_attached_tags($objObject)
} else { } else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag $tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
$tagIdOutput = @() $tagIdOutput = @()
$tagCategories = Get-CISTagCategory | Sort-Object -Property Name $tagCategories = Get-CISTagCategory | Sort-Object -Property Name
if ($Category) { if ($Category) {
@@ -404,7 +408,7 @@ function Get-CISTagAssignment {
$filterDsObj = $dsSvc.help.list.filter.create() $filterDsObj = $dsSvc.help.list.filter.create()
$filterDsObj.datastores.add($obj.Id) | Out-Null $filterDsObj.datastores.add($obj.Id) | Out-Null
$objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name $objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name
} else {$objName = 'Object Not Found'} } else {$objName = 'Object Not Found'}
$tempObject = "" | Select-Object Tag, Entity $tempObject = "" | Select-Object Tag, Entity
$tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name $tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name
$tempObject.Entity = $objName $tempObject.Entity = $objName
@@ -436,7 +440,7 @@ function Get-CISTagAssignment {
$filterDsObj = $dsSvc.help.list.filter.create() $filterDsObj = $dsSvc.help.list.filter.create()
$filterDsObj.datastores.add($obj.Id) | Out-Null $filterDsObj.datastores.add($obj.Id) | Out-Null
$objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name $objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name
} else {$objName = 'Object Not Found'} } else {$objName = 'Object Not Found'}
$tempObject = "" | Select-Object Tag, Entity $tempObject = "" | Select-Object Tag, Entity
$tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name $tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name
$tempObject.Entity = $objName $tempObject.Entity = $objName
@@ -449,12 +453,12 @@ function Get-CISTagAssignment {
} }
function New-CISTagAssignment { function New-CISTagAssignment {
<# <#
.SYNOPSIS .SYNOPSIS
Creates new tag assignments from the CIS REST API endpoint Creates new tag assignments from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will create new tag assignments Will create new tag assignments
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Tag .PARAMETER Tag
Tag name which should be referenced Tag name which should be referenced
@@ -471,7 +475,7 @@ function New-CISTagAssignment {
New-CISTagAssignment -TagId $tagId -ObjectId 'vm-11' New-CISTagAssignment -TagId $tagId -ObjectId 'vm-11'
Creates a tag assignment between the Tag ID and the Object ID Creates a tag assignment between the Tag ID and the Object ID
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param( param(
[Parameter(Mandatory=$false,Position=0)] [Parameter(Mandatory=$false,Position=0)]
$Tag, $Tag,
@@ -603,19 +607,19 @@ function New-CISTagAssignment {
$objObject.type = $objType $objObject.type = $objType
$tagAssocSvc.attach($TagId,$objObject) | Out-Null $tagAssocSvc.attach($TagId,$objObject) | Out-Null
} }
} else {Write-Output "Multiple tags with multiple objects are not a supported call."} } else {Write-Output "Multiple tags with multiple objects are not a supported call."}
} }
} }
function Remove-CISTagAssignment { function Remove-CISTagAssignment {
<# <#
.SYNOPSIS .SYNOPSIS
Removes a tag assignment from the CIS REST API endpoint Removes a tag assignment from the CIS REST API endpoint
.DESCRIPTION .DESCRIPTION
Will remove provided tag assignments Will remove provided tag assignments
.NOTES .NOTES
Author: Kyle Ruddy, @kmruddy Author: Kyle Ruddy, @kmruddy
.PARAMETER Tag .PARAMETER Tag
Tag name which should be removed Tag name which should be removed
@@ -632,7 +636,7 @@ function Remove-CISTagAssignment {
Remove-CISTagAssignment -Tag TagName -Entity VMName Remove-CISTagAssignment -Tag TagName -Entity VMName
Removes the tag assignment between the Tag name and the Entity name Removes the tag assignment between the Tag name and the Entity name
#> #>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')] [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param( param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
$Tag, $Tag,

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-DRaas { Function Connect-DRaas {
<# <#
.NOTES .NOTES

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.HCX' # Module manifest for module 'VMware.HCX'
# #

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-HcxServer { Function Connect-HcxServer {
<# <#
.NOTES .NOTES
@@ -1057,7 +1061,7 @@ Function Set-HcxLocation {
if(-not $cityDetails) { if(-not $cityDetails) {
Write-Host -ForegroundColor Red "Invalid input for City and/or Country, please provide the exact input from Get-HcxCity cmdlet" Write-Host -ForegroundColor Red "Invalid input for City and/or Country, please provide the exact input from Get-HcxCity cmdlet"
break break
} }
$locationConfig = @{ $locationConfig = @{
@@ -1089,7 +1093,7 @@ Function Set-HcxLocation {
if($results.StatusCode -eq 204) { if($results.StatusCode -eq 204) {
Write-Host -ForegroundColor Green "Successfully registered datacenter location $City to HCX Manager" Write-Host -ForegroundColor Green "Successfully registered datacenter location $City to HCX Manager"
} else { } else {
Write-Error "Failed to registerd datacenter location in HCX Manager" Write-Error "Failed to registerd datacenter location in HCX Manager"
} }
} else { } else {
Write-Error "Failed to search for city $City" Write-Error "Failed to search for city $City"

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.VMC.NSXT' # Module manifest for module 'VMware.VMC.NSXT'
# #

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-NSXTProxy { Function Connect-NSXTProxy {
<# <#
.NOTES .NOTES

Binary file not shown.

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VMCCommand { Function Get-VMCCommand {
<# <#
.NOTES .NOTES
@@ -34,7 +38,7 @@ Function Connect-VMCVIServer {
Blog: http://vmware.com/go/powercli Blog: http://vmware.com/go/powercli
Twitter: @powercli Twitter: @powercli
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Cmdlet to connect to your VMC vCenter Server Cmdlet to connect to your VMC vCenter Server
.DESCRIPTION .DESCRIPTION
@@ -50,7 +54,7 @@ Function Connect-VMCVIServer {
[switch]$Autologin, [switch]$Autologin,
[switch]$UseManagementIP [switch]$UseManagementIP
) )
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else { If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
$creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc $creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc
If($UseManagementIP){ If($UseManagementIP){
@@ -297,7 +301,7 @@ Function Get-VMCSDDCVersion {
Blog: http://vmware.com/go/powercli Blog: http://vmware.com/go/powercli
Twitter: @powercli Twitter: @powercli
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Returns SDDC Version Returns SDDC Version
.DESCRIPTION .DESCRIPTION
@@ -707,7 +711,7 @@ Function Get-VMCLogicalNetwork {
.DESCRIPTION .DESCRIPTION
Retruns VMC Logical Networks for a given SDDC Retruns VMC Logical Networks for a given SDDC
.EXAMPLE .EXAMPLE
Get-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name> Get-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name>
.EXAMPLE .EXAMPLE
Get-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name> -LogicalNetworkName <Logical Network Name> Get-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name> -LogicalNetworkName <Logical Network Name>
#> #>
@@ -738,7 +742,7 @@ Function Get-VMCLogicalNetwork {
$logicalNetworks = do{ $logicalNetworks = do{
$netData = $logicalNetworkService.get_0($orgId,$sddcId,$pagesize,$index) $netData = $logicalNetworkService.get_0($orgId,$sddcId,$pagesize,$index)
$netData.data | Sort-Object -Property id $netData.data | Sort-Object -Property id
$index = $index + $netdata.paging_info.page_size $index = $index + $netdata.paging_info.page_size
} }
until($index -ge $netData.paging_info.total_count) until($index -ge $netData.paging_info.total_count)
@@ -840,7 +844,7 @@ Function New-VMCLogicalNetwork {
$orgId = (Get-VMCOrg -Name $OrgName).Id $orgId = (Get-VMCOrg -Name $OrgName).Id
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id $sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
if(-not $orgId) { if(-not $orgId) {
Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input" Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input"
break break
@@ -1166,7 +1170,7 @@ Twitter: @LucD22
$edges = do{ $edges = do{
$edgeData = $edgeService.get($orgId,$sddcId,$EdgeType,'',$index) $edgeData = $edgeService.get($orgId,$sddcId,$EdgeType,'',$index)
$edgeData.edge_page.data | Sort-Object -Property id $edgeData.edge_page.data | Sort-Object -Property id
$index = $index + $edgeData.edge_page.paging_info.page_size $index = $index + $edgeData.edge_page.paging_info.page_size
} }
until($index -ge $edgeData.paging_info.total_count) until($index -ge $edgeData.paging_info.total_count)
$edges | %{ $edges | %{
@@ -1227,7 +1231,7 @@ Twitter: @LucD22
State = $_.edge_VM_status State = $_.edge_VM_status
HAState = $_.ha_state HAState = $_.ha_state
Index = $_.index Index = $_.index
} }
} }
$featureStatus = $status.feature_statuses | %{ $featureStatus = $status.feature_statuses | %{
[pscustomobject]@{ [pscustomobject]@{
@@ -1333,7 +1337,7 @@ Twitter: @LucD22
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id $edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
# $epoch = Get-Date 01/01/1970 # $epoch = Get-Date 01/01/1970
# #
# if($start){ # if($start){
# $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds # $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds
# } # }
@@ -1398,7 +1402,7 @@ Twitter: @LucD22
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id $edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
# $epoch = Get-Date 01/01/1970 # $epoch = Get-Date 01/01/1970
# #
# if($start){ # if($start){
# $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds # $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds
# } # }
@@ -1436,7 +1440,7 @@ Function New-VMCSDDCCluster {
Blog: https://www.kmruddy.com Blog: https://www.kmruddy.com
Twitter: @kmruddy Twitter: @kmruddy
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Creates a new cluster for the designated SDDC Creates a new cluster for the designated SDDC
.DESCRIPTION .DESCRIPTION
@@ -1485,7 +1489,7 @@ Function Get-VMCSDDCCluster {
Blog: https://www.kmruddy.com Blog: https://www.kmruddy.com
Twitter: @kmruddy Twitter: @kmruddy
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Retreives cluster information for the designated SDDC Retreives cluster information for the designated SDDC
.DESCRIPTION .DESCRIPTION
@@ -1534,7 +1538,7 @@ Function New-VMCSDDCCluster {
Blog: https://www.kmruddy.com Blog: https://www.kmruddy.com
Twitter: @kmruddy Twitter: @kmruddy
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Creates a new cluster for the designated SDDC Creates a new cluster for the designated SDDC
.DESCRIPTION .DESCRIPTION
@@ -1583,7 +1587,7 @@ Function Remove-VMCSDDCCluster {
Blog: https://www.kmruddy.com Blog: https://www.kmruddy.com
Twitter: @kmruddy Twitter: @kmruddy
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Removes a specified cluster from the designated SDDC Removes a specified cluster from the designated SDDC
.DESCRIPTION .DESCRIPTION

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.VMEncryption' # Module manifest for module 'VMware.VMEncryption'
# #

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Script Module : VMware.VMEncryption # Script Module : VMware.VMEncryption
# Version : 1.2 # Version : 1.2

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Script Module : VMware.VsanEncryption # Script Module : VMware.VsanEncryption
# Version : 1.0 # Version : 1.0
# Author : Jase McCarty, VMware Storage & Availability Business Unit # Author : Jase McCarty, VMware Storage & Availability Business Unit
@@ -26,19 +31,19 @@
Function Invoke-VsanEncryptionRekey { Function Invoke-VsanEncryptionRekey {
<# <#
.SYNOPSIS .SYNOPSIS
This function will initiate a ReKey of a vSAN Cluster. Shallow ReKeying (KEK Only) or Deep ReKeying (DEK Also) are supported, as well as Reduced Redundancy if necessary. This function will initiate a ReKey of a vSAN Cluster. Shallow ReKeying (KEK Only) or Deep ReKeying (DEK Also) are supported, as well as Reduced Redundancy if necessary.
.DESCRIPTION .DESCRIPTION
This function will initiate a ReKey of a vSAN Cluster. Shallow ReKeying (KEK Only) or Deep ReKeying (DEK Also) are supported, as well as Reduced Redundancy if necessary. This function will initiate a ReKey of a vSAN Cluster. Shallow ReKeying (KEK Only) or Deep ReKeying (DEK Also) are supported, as well as Reduced Redundancy if necessary.
.PARAMETER Cluster .PARAMETER Cluster
Specifies the Cluster to perform the rekey process on Specifies the Cluster to perform the rekey process on
.PARAMETER DeepRekey .PARAMETER DeepRekey
Use to invoke a Deep Rekey ($true) or a Shallow ($false or omit) Use to invoke a Deep Rekey ($true) or a Shallow ($false or omit)
.PARAMETER ReducedRedundancy .PARAMETER ReducedRedundancy
For clusters that have 4 or more hosts, this will allow for reduced redundancy. For clusters that have 4 or more hosts, this will allow for reduced redundancy.
For clusters that have 2 or 3 hosts, this does not need to be set (can be). For clusters that have 2 or 3 hosts, this does not need to be set (can be).
.EXAMPLE .EXAMPLE
@@ -53,7 +58,7 @@ Function Invoke-VsanEncryptionRekey {
[Parameter(Mandatory = $False)][Boolean]$ReducedRedundancy [Parameter(Mandatory = $False)][Boolean]$ReducedRedundancy
) )
# Get the Cluster # Get the Cluster
$VsanCluster = Get-Cluster -Name $Cluster $VsanCluster = Get-Cluster -Name $Cluster
# Get the vSAN Cluster Configuration View # Get the vSAN Cluster Configuration View
@@ -95,71 +100,71 @@ Function Invoke-VsanEncryptionRekey {
Function Set-VsanEncryptionKms { Function Set-VsanEncryptionKms {
<# <#
.SYNOPSIS .SYNOPSIS
This function will set the KMS to be used with vSAN Encryption This function will set the KMS to be used with vSAN Encryption
.DESCRIPTION .DESCRIPTION
This function will set the KMS to be used with vSAN Encryption This function will set the KMS to be used with vSAN Encryption
.PARAMETER Cluster .PARAMETER Cluster
Specifies the Cluster to set the KMS server for Specifies the Cluster to set the KMS server for
.PARAMETER KmsCluster .PARAMETER KmsCluster
Use to set the KMS Cluster to be used with vSAN Encryption Use to set the KMS Cluster to be used with vSAN Encryption
.EXAMPLE .EXAMPLE
C:\PS>Set-VsanEncryptionKms -Cluster "ClusterName" -KmsCluster "vCenter KMS Cluster Entry" C:\PS>Set-VsanEncryptionKms -Cluster "ClusterName" -KmsCluster "vCenter KMS Cluster Entry"
#> #>
# Set our Parameters # Set our Parameters
[CmdletBinding()]Param( [CmdletBinding()]Param(
[Parameter(Mandatory = $True)][String]$Cluster, [Parameter(Mandatory = $True)][String]$Cluster,
[Parameter(Mandatory = $False)][String]$KmsCluster [Parameter(Mandatory = $False)][String]$KmsCluster
) )
# Get the Cluster # Get the Cluster
$VsanCluster = Get-Cluster -Name $Cluster $VsanCluster = Get-Cluster -Name $Cluster
# Get the list of KMS Servers that are included # Get the list of KMS Servers that are included
$KmsClusterList = Get-KmsCluster $KmsClusterList = Get-KmsCluster
# Was a KMS Cluster Specified? # Was a KMS Cluster Specified?
# Specified: Is it in the list? # Specified: Is it in the list?
# Is it not in the list? # Is it not in the list?
# Not Specified: Present a list # Not Specified: Present a list
If ($KmsCluster) { If ($KmsCluster) {
If ($KmsClusterList.Name.Contains($KmsCluster)) { If ($KmsClusterList.Name.Contains($KmsCluster)) {
Write-Host "$KmsCluster In the list, proceeding" -ForegroundColor Green Write-Host "$KmsCluster In the list, proceeding" -ForegroundColor Green
$KmsClusterProfile = $KmsClusterList | Where-Object {$_.Name -eq $KmsCluster} $KmsClusterProfile = $KmsClusterList | Where-Object {$_.Name -eq $KmsCluster}
} else { } else {
$Count = 0 $Count = 0
Foreach ($KmsClusterItem in $KmsClusterList) { Foreach ($KmsClusterItem in $KmsClusterList) {
Write-Host "$Count) $KmsClusterItem " Write-Host "$Count) $KmsClusterItem "
$Count = $Count + 1 $Count = $Count + 1
} }
$KmsClusterEntry = Read-Host -Prompt "$KmsCluster is not valid, please select one of the existing KMS Clusters to use" $KmsClusterEntry = Read-Host -Prompt "$KmsCluster is not valid, please select one of the existing KMS Clusters to use"
Write-Host $KmsClusterList[$KmsClusterEntry] Write-Host $KmsClusterList[$KmsClusterEntry]
$KmsClusterProfile = $KmsClusterList[$KmsClusterEntry] $KmsClusterProfile = $KmsClusterList[$KmsClusterEntry]
} }
} else { } else {
$Count = 0 $Count = 0
Foreach ($KmsClusterItem in $KmsClusterList) { Foreach ($KmsClusterItem in $KmsClusterList) {
Write-Host "$Count) $KmsClusterItem " Write-Host "$Count) $KmsClusterItem "
$Count = $Count + 1 $Count = $Count + 1
} }
$KmsClusterEntry = Read-Host -Prompt "No KMS provided, please select one of the existing KMS Clusters to use" $KmsClusterEntry = Read-Host -Prompt "No KMS provided, please select one of the existing KMS Clusters to use"
Write-Host $KmsClusterList[$KmsClusterEntry] Write-Host $KmsClusterList[$KmsClusterEntry]
$KmsClusterProfile = $KmsClusterList[$KmsClusterEntry] $KmsClusterProfile = $KmsClusterList[$KmsClusterEntry]
} }
# Get the vSAN Cluster Configuration View # Get the vSAN Cluster Configuration View
$VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system" $VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system"
# Get Encryption State # Get Encryption State
$EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig $EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig
# If vSAN is enabled and it is Encrypted # If vSAN is enabled and it is Encrypted
If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){ If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){
@@ -181,7 +186,7 @@ Function Set-VsanEncryptionKms {
# Set the Reconfigure Specification to use the Data Encryption Configuration Spec # Set the Reconfigure Specification to use the Data Encryption Configuration Spec
$vsanReconfigSpec = New-Object VMware.Vsan.Views.VimVsanReconfigSpec $vsanReconfigSpec = New-Object VMware.Vsan.Views.VimVsanReconfigSpec
$vsanReconfigSpec.DataEncryptionConfig = $DataEncryptionConfigSpec $vsanReconfigSpec.DataEncryptionConfig = $DataEncryptionConfigSpec
# Execute the task of changing the KMS Cluster Profile Being Used # Execute the task of changing the KMS Cluster Profile Being Used
$ChangeKmsTask = $VsanVcClusterConfig.VsanClusterReconfig($VsanCluster.ExtensionData.MoRef,$vsanReconfigSpec) $ChangeKmsTask = $VsanVcClusterConfig.VsanClusterReconfig($VsanCluster.ExtensionData.MoRef,$vsanReconfigSpec)
} }
@@ -192,74 +197,74 @@ Function Set-VsanEncryptionKms {
Function Get-VsanEncryptionKms { Function Get-VsanEncryptionKms {
<# <#
.SYNOPSIS .SYNOPSIS
This function will set the KMS to be used with vSAN Encryption This function will set the KMS to be used with vSAN Encryption
.DESCRIPTION .DESCRIPTION
This function will set the KMS to be used with vSAN Encryption This function will set the KMS to be used with vSAN Encryption
.PARAMETER Cluster .PARAMETER Cluster
Specifies the Cluster to set the KMS server for Specifies the Cluster to set the KMS server for
.EXAMPLE .EXAMPLE
C:\PS>Get-VsanEncryptionKms -Cluster "ClusterName" C:\PS>Get-VsanEncryptionKms -Cluster "ClusterName"
#> #>
# Set our Parameters # Set our Parameters
[CmdletBinding()]Param([Parameter(Mandatory = $True)][String]$Cluster) [CmdletBinding()]Param([Parameter(Mandatory = $True)][String]$Cluster)
# Get the Cluster # Get the Cluster
$VsanCluster = Get-Cluster -Name $Cluster $VsanCluster = Get-Cluster -Name $Cluster
# Get the vSAN Cluster Configuration View # Get the vSAN Cluster Configuration View
$VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system" $VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system"
# Get Encryption State # Get Encryption State
$EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig $EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig
# If vSAN is enabled and it is Encrypted # If vSAN is enabled and it is Encrypted
If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){ If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){
$EncryptedVsan.KmsProviderId.Id $EncryptedVsan.KmsProviderId.Id
} }
} }
Function Set-VsanEncryptionDiskWiping { Function Set-VsanEncryptionDiskWiping {
<# <#
.SYNOPSIS .SYNOPSIS
This function will update the Disk Wiping option in vSAN Encryption This function will update the Disk Wiping option in vSAN Encryption
.DESCRIPTION .DESCRIPTION
This function will update the Disk Wiping option in vSAN Encryption This function will update the Disk Wiping option in vSAN Encryption
.PARAMETER Cluster .PARAMETER Cluster
Specifies the Cluster set the Disk Wiping Setting on Specifies the Cluster set the Disk Wiping Setting on
.PARAMETER DiskWiping .PARAMETER DiskWiping
Use to set the Disk Wiping setting for vSAN Encryption Use to set the Disk Wiping setting for vSAN Encryption
.EXAMPLE .EXAMPLE
C:\PS>Set-VsanEncryptionDiskWiping -Cluster "ClusterName" -DiskWiping $true C:\PS>Set-VsanEncryptionDiskWiping -Cluster "ClusterName" -DiskWiping $true
.EXAMPLE .EXAMPLE
C:\PS>Set-VsanEncryptionDiskWiping -Cluster "ClusterName" -DiskWiping $false C:\PS>Set-VsanEncryptionDiskWiping -Cluster "ClusterName" -DiskWiping $false
#> #>
# Set our Parameters # Set our Parameters
[CmdletBinding()]Param( [CmdletBinding()]Param(
[Parameter(Mandatory = $True)][String]$Cluster, [Parameter(Mandatory = $True)][String]$Cluster,
[Parameter(Mandatory = $True)][Boolean]$DiskWiping [Parameter(Mandatory = $True)][Boolean]$DiskWiping
) )
# Get the Cluster # Get the Cluster
$VsanCluster = Get-Cluster -Name $Cluster $VsanCluster = Get-Cluster -Name $Cluster
# Get the vSAN Cluster Configuration View # Get the vSAN Cluster Configuration View
$VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system" $VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system"
# Get Encryption State # Get Encryption State
$EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig $EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig
# If vSAN is enabled and it is Encrypted # If vSAN is enabled and it is Encrypted
If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){ If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){
@@ -287,7 +292,7 @@ Function Set-VsanEncryptionDiskWiping {
# Set the Reconfigure Specification to use the Data Encryption Configuration Spec # Set the Reconfigure Specification to use the Data Encryption Configuration Spec
$vsanReconfigSpec = New-Object VMware.Vsan.Views.VimVsanReconfigSpec $vsanReconfigSpec = New-Object VMware.Vsan.Views.VimVsanReconfigSpec
$vsanReconfigSpec.DataEncryptionConfig = $DataEncryptionConfigSpec $vsanReconfigSpec.DataEncryptionConfig = $DataEncryptionConfigSpec
# Execute the task of changing the KMS Cluster Profile Being Used # Execute the task of changing the KMS Cluster Profile Being Used
$VsanVcClusterConfig.VsanClusterReconfig($VsanCluster.ExtensionData.MoRef,$vsanReconfigSpec) $VsanVcClusterConfig.VsanClusterReconfig($VsanCluster.ExtensionData.MoRef,$vsanReconfigSpec)
@@ -298,31 +303,31 @@ Function Set-VsanEncryptionDiskWiping {
Function Get-VsanEncryptionDiskWiping { Function Get-VsanEncryptionDiskWiping {
<# <#
.SYNOPSIS .SYNOPSIS
This function will retrieve the Disk Wiping option setting in vSAN Encryption This function will retrieve the Disk Wiping option setting in vSAN Encryption
.DESCRIPTION .DESCRIPTION
This function will retrieve the Disk Wiping option setting in vSAN Encryption This function will retrieve the Disk Wiping option setting in vSAN Encryption
.PARAMETER Cluster .PARAMETER Cluster
Specifies the Cluster set the Disk Wiping Setting on Specifies the Cluster set the Disk Wiping Setting on
.EXAMPLE .EXAMPLE
C:\PS>Get-VsanEncryptionDiskWiping -Cluster "ClusterName" C:\PS>Get-VsanEncryptionDiskWiping -Cluster "ClusterName"
#> #>
# Set our Parameters # Set our Parameters
[CmdletBinding()]Param([Parameter(Mandatory = $True)][String]$Cluster) [CmdletBinding()]Param([Parameter(Mandatory = $True)][String]$Cluster)
# Get the Cluster # Get the Cluster
$VsanCluster = Get-Cluster -Name $Cluster $VsanCluster = Get-Cluster -Name $Cluster
# Get the vSAN Cluster Configuration View # Get the vSAN Cluster Configuration View
$VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system" $VsanVcClusterConfig = Get-VsanView -Id "VsanVcClusterConfigSystem-vsan-cluster-config-system"
# Get Encryption State # Get Encryption State
$EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig $EncryptedVsan = $VsanVcClusterConfig.VsanClusterGetConfig($VsanCluster.ExtensionData.MoRef).DataEncryptionConfig
# If vSAN is enabled and it is Encrypted # If vSAN is enabled and it is Encrypted
If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){ If($VsanCluster.vSanEnabled -And $EncryptedVsan.EncryptionEnabled){

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.WorkloadManagement' # Module manifest for module 'VMware.WorkloadManagement'
# #

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function New-WorkloadManagement { Function New-WorkloadManagement {
<# <#
.NOTES .NOTES
@@ -106,7 +110,7 @@ Function New-WorkloadManagement {
$mgmtNetworkMoRef = $networkService.list($networkFilterSpec).network.Value $mgmtNetworkMoRef = $networkService.list($networkFilterSpec).network.Value
if ($mgmtNetworkMoRef -eq $NULL) { if ($mgmtNetworkMoRef -eq $NULL) {
Write-Host -ForegroundColor Red "Unable to find vSphere Cluster ${MgmtNetwork}" Write-Host -ForegroundColor Red "Unable to find vSphere Cluster ${MgmtNetwork}"
break break
} }
# Cluster Moref # Cluster Moref

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.HCX' # Module manifest for module 'VMware.HCX'
# #

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-WorkspaceOneAccess { Function Connect-WorkspaceOneAccess {
<# <#
.NOTES .NOTES
@@ -626,9 +631,9 @@ Function Get-UEMConfig {
if($results.StatusCode -eq 200) { if($results.StatusCode -eq 200) {
$config = ([System.Text.Encoding]::ASCII.GetString($results.Content) | ConvertFrom-Json) $config = ([System.Text.Encoding]::ASCII.GetString($results.Content) | ConvertFrom-Json)
$config $config
} }
} }
Function Remove-UEMConfig { Function Remove-UEMConfig {
<# <#
.NOTES .NOTES

View File

@@ -1,5 +1,5 @@
<# <#
Copyright 2020-2021 VMware, Inc. Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
#> #>

View File

@@ -1,5 +1,5 @@
<# <#
Copyright 2020-2021 VMware, Inc. Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
#> #>

View File

@@ -1,5 +1,5 @@
<# <#
Copyright 2020-2021 VMware, Inc. Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
#> #>

View File

@@ -1,5 +1,5 @@
<# <#
Copyright 2020-2021 VMware, Inc. Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
#> #>

View File

@@ -1,5 +1,5 @@
<# <#
Copyright 2020-2021 VMware, Inc. Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
#> #>

View File

@@ -1,3 +1,8 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Module manifest for module 'VMware.vSphere.SsoAdmin' # Module manifest for module 'VMware.vSphere.SsoAdmin'
# #

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
# #
# Script module for module 'VMware.vSphere.SsoAdmin' # Script module for module 'VMware.vSphere.SsoAdmin'

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.IdentityModel.Selectors; using System.IdentityModel.Selectors;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -29,13 +30,13 @@ namespace VMware.vSphere.SsoAdmin.Utils
var obnMatchingServers = new List<SsoAdminServer>(); var obnMatchingServers = new List<SsoAdminServer>();
var ssoAdminServerVariable = engineIntrinsics.SessionState.PSVariable.GetValue("DefaultSsoAdminServers"); var ssoAdminServerVariable = engineIntrinsics.SessionState.PSVariable.GetValue("DefaultSsoAdminServers");
if (ssoAdminServerVariable is PSObject ssoAdminServersPsObj && if (ssoAdminServerVariable is PSObject ssoAdminServersPsObj &&
ssoAdminServersPsObj.BaseObject is List<SsoAdminServer> connectedServers) { ssoAdminServersPsObj.BaseObject is List<SsoAdminServer> connectedServers) {
foreach (var server in connectedServers) { foreach (var server in connectedServers) {
if (!string.IsNullOrEmpty(Regex.Match(server.ToString(), csharpObnValue)?.Value)) { if (!string.IsNullOrEmpty(Regex.Match(server.ToString(), csharpObnValue)?.Value)) {
obnMatchingServers.Add(server); obnMatchingServers.Add(server);
} }
} }
} }
@@ -45,9 +46,9 @@ namespace VMware.vSphere.SsoAdmin.Utils
// Non-terminating error for not matching value // Non-terminating error for not matching value
engineIntrinsics.Host.UI.WriteErrorLine($"'{obnValue}' doesn't match any objects in $global:DefaultSsoAdminServers variable"); engineIntrinsics.Host.UI.WriteErrorLine($"'{obnValue}' doesn't match any objects in $global:DefaultSsoAdminServers variable");
} }
} }
return result; return result;
} }
} }

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using NUnit.Framework; using NUnit.Framework;
using System.Linq; using System.Linq;
using System.Security; using System.Security;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -17,9 +18,9 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
private SsoAdminClient _client; private SsoAdminClient _client;
public SsoAdminServer(string hostname, public SsoAdminServer(string hostname,
string user, string user,
SecureString password, SecureString password,
X509CertificateValidator serverCertificateValidator) { X509CertificateValidator serverCertificateValidator) {
Name = hostname; Name = hostname;
@@ -56,7 +57,7 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
public void Disconnect() { public void Disconnect() {
if (--RefCount == 0) { if (--RefCount == 0) {
_client = null; _client = null;
} }
} }
public override string ToString() { public override string ToString() {

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
// ************************************************************************** /*
// Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
// ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
*/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IdentityModel.Selectors; using System.IdentityModel.Selectors;
@@ -21,9 +22,9 @@ namespace VMware.vSphere.SsoAdminClient
private VmwareSecruityTokenService _stsClient; private VmwareSecruityTokenService _stsClient;
private SamlSecurityToken _validToken; private SamlSecurityToken _validToken;
public UserPassSecurityContext( public UserPassSecurityContext(
string user, string user,
SecureString password, SecureString password,
Uri stsUri, Uri stsUri,
X509CertificateValidator serverCertificateValidator) { X509CertificateValidator serverCertificateValidator) {
if (user == null) throw new ArgumentNullException(nameof(user)); if (user == null) throw new ArgumentNullException(nameof(user));

View File

@@ -1,7 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[string] [string]
$TestVc, $TestVc,

View File

@@ -1,7 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string] [string]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,6 +1,7 @@
# ************************************************************************** <#
# Copyright 2020 VMware, Inc. Copyright 2021 VMware, Inc.
# ************************************************************************** SPDX-License-Identifier: BSD-2-Clause
#>
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]

View File

@@ -1,4 +1,9 @@
function Validate-ESXiPackages { <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Validate-ESXiPackages {
<# <#
.DESCRIPTION .DESCRIPTION
Compares all ESXi Host VIBs within a vSphere with a reference Hosts. Compares all ESXi Host VIBs within a vSphere with a reference Hosts.
@@ -28,9 +33,9 @@
.PARAMETER RefernceHost .PARAMETER RefernceHost
The VIB Reference ESXi Host The VIB Reference ESXi Host
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="vSphere Cluster to verify")] [Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="vSphere Cluster to verify")]
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl] $Cluster, [VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl] $Cluster,
@@ -38,24 +43,24 @@
[ValidateNotNullorEmpty()] [ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl] $RefernceHost [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl] $RefernceHost
) )
Process { Process {
#region: Get reference VIBs #region: Get reference VIBs
$EsxCli2 = Get-ESXCLI -VMHost $RefernceHost -V2 $EsxCli2 = Get-ESXCLI -VMHost $RefernceHost -V2
$RefernceVibList = $esxcli2.software.vib.list.invoke() $RefernceVibList = $esxcli2.software.vib.list.invoke()
#endregion #endregion
#region: Compare reference VIBs #region: Compare reference VIBs
$MyView = @() $MyView = @()
foreach ($VmHost in ($Cluster | Get-VMHost)) { foreach ($VmHost in ($Cluster | Get-VMHost)) {
$EsxCli2 = Get-ESXCLI -VMHost $VmHost -V2 $EsxCli2 = Get-ESXCLI -VMHost $VmHost -V2
$VibList = $esxcli2.software.vib.list.invoke() $VibList = $esxcli2.software.vib.list.invoke()
[Array]$VibDiff = Compare-Object -ReferenceObject $RefernceVibList.ID -DifferenceObject $VibList.ID [Array]$VibDiff = Compare-Object -ReferenceObject $RefernceVibList.ID -DifferenceObject $VibList.ID
if($VibDiff.Count -gt 0) { if($VibDiff.Count -gt 0) {
$VibDiffSideIndicator = @() $VibDiffSideIndicator = @()
foreach ($Item in $VibDiff) { foreach ($Item in $VibDiff) {
$VibDiffSideIndicator += $($Item.SideIndicator + " " + $Item.InputObject) $VibDiffSideIndicator += $($Item.SideIndicator + " " + $Item.InputObject)
} }
@@ -73,7 +78,7 @@
VibDiffSideIndicator = $VibDiffSideIndicator VibDiffSideIndicator = $VibDiffSideIndicator
} }
$MyView += $Report $MyView += $Report
} }
#region: Compare reference VIBs #region: Compare reference VIBs

View File

@@ -1,16 +1,16 @@
function Apply-Hardening { function Apply-Hardening {
<# <#
.NOTES .NOTES
=========================================================================== ===========================================================================
Created by: Markus Kraus Created by: Markus Kraus
Twitter: @VMarkus_K Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com Private Blog: mycloudrevolution.com
=========================================================================== ===========================================================================
Changelog: Changelog:
2016.11 ver 2.0 Base Release 2016.11 ver 2.0 Base Release
=========================================================================== ===========================================================================
External Code Sources: External Code Sources:
=========================================================================== ===========================================================================
Tested Against Environment: Tested Against Environment:
vSphere Version: 5.5 U2 vSphere Version: 5.5 U2
@@ -24,14 +24,14 @@ function Apply-Hardening {
Applys a set of Hardening options to your VMs Applys a set of Hardening options to your VMs
.Example .Example
Get-VM TST* | Apply-Hardening Get-VM TST* | Apply-Hardening
.Example .Example
$SampleVMs = Get-VM "TST*" $SampleVMs = Get-VM "TST*"
Apply-Hardening -VMs $SampleVMs Apply-Hardening -VMs $SampleVMs
.PARAMETER VMs .PARAMETER VMs
Specify the VMs Specify the VMs
#Requires PS -Version 4.0 #Requires PS -Version 4.0
@@ -39,7 +39,7 @@ function Apply-Hardening {
#> #>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true, [Parameter(Mandatory=$true,
ValueFromPipeline=$True, ValueFromPipeline=$True,
Position=0)] Position=0)]
@@ -47,7 +47,7 @@ param(
$VMs $VMs
) )
Process { Process {
#region: Create Options #region: Create Options
$ExtraOptions = @{ $ExtraOptions = @{
"isolation.tools.diskShrink.disable"="true"; "isolation.tools.diskShrink.disable"="true";
@@ -55,20 +55,20 @@ Process {
"isolation.tools.copy.disable"="true"; "isolation.tools.copy.disable"="true";
"isolation.tools.paste.disable"="true"; "isolation.tools.paste.disable"="true";
"isolation.tools.dnd.disable"="true"; "isolation.tools.dnd.disable"="true";
"isolation.tools.setGUIOptions.enable"="false"; "isolation.tools.setGUIOptions.enable"="false";
"log.keepOld"="10"; "log.keepOld"="10";
"log.rotateSize"="100000" "log.rotateSize"="100000"
"RemoteDisplay.maxConnections"="2"; "RemoteDisplay.maxConnections"="2";
"RemoteDisplay.vnc.enabled"="false"; "RemoteDisplay.vnc.enabled"="false";
} }
if ($DebugPreference -eq "Inquire") { if ($DebugPreference -eq "Inquire") {
Write-Output "VM Hardening Options:" Write-Output "VM Hardening Options:"
$ExtraOptions | Format-Table -AutoSize $ExtraOptions | Format-Table -AutoSize
} }
$VMConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $VMConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
Foreach ($Option in $ExtraOptions.GetEnumerator()) { Foreach ($Option in $ExtraOptions.GetEnumerator()) {
$OptionValue = New-Object VMware.Vim.optionvalue $OptionValue = New-Object VMware.Vim.optionvalue
$OptionValue.Key = $Option.Key $OptionValue.Key = $Option.Key

View File

@@ -1,4 +1,9 @@
# Fetch Cis Server hostname and credentials <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Fetch Cis Server hostname and credentials
.\CisConfig.ps1 .\CisConfig.ps1
@@ -14,4 +19,3 @@ Get-rCisTagCategory
Get-rCisTagAssignment Get-rCisTagAssignment
Disconnect-rCisServer -Server $cisServer -Confirm:$false Disconnect-rCisServer -Server $cisServer -Confirm:$false

View File

@@ -1,4 +1,9 @@
# Fetch Cis Server hostname and credentials <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Fetch Cis Server hostname and credentials
.\CisConfig.ps1 .\CisConfig.ps1
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
@@ -11,4 +16,3 @@ New-rCisTagAssignment -Entity $vm -Tag MyTag1
Get-rCisTagAssignment -Tag MyTag1 Get-rCisTagAssignment -Tag MyTag1
Disconnect-rCisServer -Server $cisServer -Confirm:$false Disconnect-rCisServer -Server $cisServer -Confirm:$false

View File

@@ -1,4 +1,9 @@
# Fetch Cis Server hostname and credentials <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Fetch Cis Server hostname and credentials
.\CisConfig.ps1 .\CisConfig.ps1
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
@@ -8,4 +13,3 @@ Get-rCisTag -Name MyTag1 | Set-rCisTag -Name MyNewTag1 -Description 'Name change
Get-rCisTagCategory -Name MyCat1 | Set-rCisTagCategory -Cardinality Multiple -Name MyNewCat1 -Description 'Name changed' Get-rCisTagCategory -Name MyCat1 | Set-rCisTagCategory -Cardinality Multiple -Name MyNewCat1 -Description 'Name changed'
Disconnect-rCisServer -Server $cisServer -Confirm:$false Disconnect-rCisServer -Server $cisServer -Confirm:$false

View File

@@ -1,4 +1,9 @@
# Fetch Cis Server hostname and credentials <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Fetch Cis Server hostname and credentials
.\CisConfig.ps1 .\CisConfig.ps1
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
@@ -10,4 +15,3 @@ Get-rCisTag -Name MyNewTag1 | Remove-rCisTag -Confirm:$false
Get-rCisTagCategory -Name MyNewCat1 | Remove-rCisTagCategory -Confirm:$false Get-rCisTagCategory -Name MyNewCat1 | Remove-rCisTagCategory -Confirm:$false
Disconnect-rCisServer -Server $cisServer -Confirm:$false Disconnect-rCisServer -Server $cisServer -Confirm:$false

View File

@@ -1,4 +1,9 @@
# Fetch Cis Server hostname and credentials <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Fetch Cis Server hostname and credentials
.\CisConfig.ps1 .\CisConfig.ps1
Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd
@@ -17,4 +22,3 @@ Get-Cluster -Name Cluster1 | Get-Datastore | %{
} }
Disconnect-rCisServer -Server $cisServer -Confirm:$false Disconnect-rCisServer -Server $cisServer -Confirm:$false

View File

@@ -1,3 +1,8 @@
$cisServer = 'vcsa.my.domain' <#
Copyright 2016-2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
$cisServer = 'vcsa.my.domain'
$cisUser = 'administrator@vsphere.local' $cisUser = 'administrator@vsphere.local'
$cisPswd = 'VMware1!' $cisPswd = 'VMware1!'

View File

@@ -1,10 +1,15 @@
<# <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
<#
=========================================================================== ===========================================================================
Created by: Jason Robinson Created by: Jason Robinson
Created on: 05/2017 Created on: 05/2017
Twitter: @jrob24 Twitter: @jrob24
Filename: New-vCenterAlarms.ps1 Filename: New-vCenterAlarms.ps1
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
Examples of creating alarms using vCenter.Alarm module Examples of creating alarms using vCenter.Alarm module

View File

@@ -1,4 +1,9 @@
<# <#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
<#
=========================================================================== ===========================================================================
Created by: Jason Robinson Created by: Jason Robinson
Created on: 05/2017 Created on: 05/2017
@@ -23,7 +28,7 @@ function New-AlarmDefinition {
This cmdlet creates a new alarm defintion on the specified entity in vCenter. This cmdlet creates a new alarm defintion on the specified entity in vCenter.
An alarm trigger is required in order to create a new alarm definition. An alarm trigger is required in order to create a new alarm definition.
They can be created by using the New-AlarmTrigger cmdlet. They can be created by using the New-AlarmTrigger cmdlet.
After the alarm definition is created, if alarm actions are required use After the alarm definition is created, if alarm actions are required use
the cmdlet New-AlarmAction to create actions for the alarm. the cmdlet New-AlarmAction to create actions for the alarm.
.PARAMETER Name .PARAMETER Name
@@ -40,7 +45,7 @@ function New-AlarmDefinition {
information about triggers, run Get-Help New-AlarmTrigger. information about triggers, run Get-Help New-AlarmTrigger.
.PARAMETER Enabled .PARAMETER Enabled
Specifies if the alarm is enabled when it is created. If unset, the Specifies if the alarm is enabled when it is created. If unset, the
default value is true. default value is true.
.PARAMETER ActionRepeatMinutes .PARAMETER ActionRepeatMinutes
Specifies the frequency how often the actions should repeat when an alarm Specifies the frequency how often the actions should repeat when an alarm
does not change state. does not change state.
@@ -48,16 +53,16 @@ function New-AlarmDefinition {
Specifies how often the alarm is triggered, measured in minutes. A zero Specifies how often the alarm is triggered, measured in minutes. A zero
value means the alarm is allowed to trigger as often as possible. A value means the alarm is allowed to trigger as often as possible. A
nonzero value means that any subsequent triggers are suppressed for a nonzero value means that any subsequent triggers are suppressed for a
period of minutes following a reported trigger. period of minutes following a reported trigger.
If unset, the default value is 0. Allowed range is 0 - 60. If unset, the default value is 0. Allowed range is 0 - 60.
.PARAMETER ToleranceRange .PARAMETER ToleranceRange
Specifies the tolerance range for the metric triggers, measure in Specifies the tolerance range for the metric triggers, measure in
percentage. A zero value means that the alarm triggers whenever the metric percentage. A zero value means that the alarm triggers whenever the metric
value is above or below the specified value. A nonzero means that the value is above or below the specified value. A nonzero means that the
alarm triggers only after reaching a certain percentage above or below alarm triggers only after reaching a certain percentage above or below
the nominal trigger value. the nominal trigger value.
If unset, the default value is 0. Allowed range is 0 - 100. If unset, the default value is 0. Allowed range is 0 - 100.
.PARAMETER Server .PARAMETER Server
Specifies the vCenter Server system on which you want to run the cmdlet. Specifies the vCenter Server system on which you want to run the cmdlet.
@@ -77,7 +82,7 @@ function New-AlarmDefinition {
Type Value Type Value
---- ----- ---- -----
Alarm alarm-1801 Alarm alarm-1801
This will create a host connection state alarm trigger and store it in This will create a host connection state alarm trigger and store it in
the variable $trigger. Then it will create a new alarm 'Host Connection' the variable $trigger. Then it will create a new alarm 'Host Connection'
on the root level of vCenter and set the action to repeat every 10 mins. on the root level of vCenter and set the action to repeat every 10 mins.
@@ -88,27 +93,27 @@ function New-AlarmDefinition {
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[Alias('AlarmName')] [Alias('AlarmName')]
[string]$Name, [string]$Name,
[string]$Description, [string]$Description,
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$Entity, [string]$Entity,
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[VMware.Vim.AlarmExpression[]]$Trigger, [VMware.Vim.AlarmExpression[]]$Trigger,
[boolean]$Enabled = $true, [boolean]$Enabled = $true,
[ValidateRange(0, 60)] [ValidateRange(0, 60)]
[int32]$ActionRepeatMinutes, [int32]$ActionRepeatMinutes,
[ValidateRange(0, 60)] [ValidateRange(0, 60)]
[int32]$ReportingFrequency = 0, [int32]$ReportingFrequency = 0,
[ValidateRange(0, 100)] [ValidateRange(0, 100)]
[int32]$ToleranceRange = 0, [int32]$ToleranceRange = 0,
[string]$Server [string]$Server
) )
BEGIN { BEGIN {
@@ -129,7 +134,7 @@ function New-AlarmDefinition {
$Object = Get-Inventory -Name $PSBoundParameters['Entity'] -ErrorAction Stop -Server $global:DefaultVIServer $Object = Get-Inventory -Name $PSBoundParameters['Entity'] -ErrorAction Stop -Server $global:DefaultVIServer
$AlarmMgr = Get-View AlarmManager -ErrorAction Stop -Server $global:DefaultVIServer $AlarmMgr = Get-View AlarmManager -ErrorAction Stop -Server $global:DefaultVIServer
} }
if ($PSCmdlet.ShouldProcess($global:DefaultVIServer, "Create alarm $($PSBoundParameters['Name'])")) { if ($PSCmdlet.ShouldProcess($global:DefaultVIServer, "Create alarm $($PSBoundParameters['Name'])")) {
$Alarm = New-Object -TypeName VMware.Vim.AlarmSpec $Alarm = New-Object -TypeName VMware.Vim.AlarmSpec
$Alarm.Name = $PSBoundParameters['Name'] $Alarm.Name = $PSBoundParameters['Name']
@@ -158,12 +163,12 @@ function New-AlarmAction {
This cmdlet differs from the VMware PowerCLI New-AlarmAction cmdlet as it This cmdlet differs from the VMware PowerCLI New-AlarmAction cmdlet as it
will create the transitions of the alarm state. It requires an alarm will create the transitions of the alarm state. It requires an alarm
action and at least one transition to be specified. action and at least one transition to be specified.
The transition indicates when the action executes and if it repeats. The transition indicates when the action executes and if it repeats.
There are only four acceptable transitions: green to yellow, yellow to There are only four acceptable transitions: green to yellow, yellow to
red, red to yellow, and yellow to green. At least one pair must be red, red to yellow, and yellow to green. At least one pair must be
specified or the results will be an invalid. specified or the results will be an invalid.
If an alarm action already exists on the alarm definition, it will be If an alarm action already exists on the alarm definition, it will be
overwritten if the same alarm action is specified. For example if the overwritten if the same alarm action is specified. For example if the
alarm definition already has an alarm action of Snmp on the transition alarm definition already has an alarm action of Snmp on the transition
@@ -171,7 +176,7 @@ function New-AlarmAction {
Snmp on the transition of yellow to red, it will overwrite the existing Snmp on the transition of yellow to red, it will overwrite the existing
action and transition. The end result will be one Snmp action on the action and transition. The end result will be one Snmp action on the
transition of yellow to red. If you want the old to transition to remain transition of yellow to red. If you want the old to transition to remain
both should be specified during the usage of the cmdlet. both should be specified during the usage of the cmdlet.
.PARAMETER AlarmDefinition .PARAMETER AlarmDefinition
Specifies the alarm definition for which you want to configure actions. Specifies the alarm definition for which you want to configure actions.
The alarm definition can be retreived by using the Get-AlarmDefinition The alarm definition can be retreived by using the Get-AlarmDefinition
@@ -209,18 +214,18 @@ function New-AlarmAction {
remain unset. remain unset.
.NOTES .NOTES
This cmdlet requires a connection to vCenter to create the alarm action. This cmdlet requires a connection to vCenter to create the alarm action.
When using this cmdlet specify the Module-Qualified cmdlet name to avoid When using this cmdlet specify the Module-Qualified cmdlet name to avoid
using the New-AlarmAction cmdlet with VMware PowerCLI. using the New-AlarmAction cmdlet with VMware PowerCLI.
.EXAMPLE .EXAMPLE
PS C:\> vCenter.Alarms\New-AlarmAction -AlarmDefinition (Get-AlarmDefintion "Host CPU Usage") -Snmp -YellowToRed Repeat PS C:\> vCenter.Alarms\New-AlarmAction -AlarmDefinition (Get-AlarmDefintion "Host CPU Usage") -Snmp -YellowToRed Repeat
This will create an Snmp alarm action on the "Host CPU Usage" alarm This will create an Snmp alarm action on the "Host CPU Usage" alarm
transition of yellow to red. The alarm action will also repeat, as per transition of yellow to red. The alarm action will also repeat, as per
the action frequency defined on the alarm. the action frequency defined on the alarm.
.EXAMPLE .EXAMPLE
PS C:\> Get-AlarmDefintion "Cluster HA Status" | vCenter.Alarms\New-AlarmAction -Email -To helpdesk@company.com -GreenToYellow Once -YellowToRed Once PS C:\> Get-AlarmDefintion "Cluster HA Status" | vCenter.Alarms\New-AlarmAction -Email -To helpdesk@company.com -GreenToYellow Once -YellowToRed Once
This will create an Email alarm action on the "Cluster HA Status" alarm This will create an Email alarm action on the "Cluster HA Status" alarm
transition of green to yellow and yellow to red. The alarm action will transition of green to yellow and yellow to red. The alarm action will
send an email to helpdesk@company.com one time per transition. send an email to helpdesk@company.com one time per transition.
@@ -229,38 +234,38 @@ function New-AlarmAction {
param ( param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[VMware.VimAutomation.ViCore.Types.V1.Alarm.AlarmDefinition]$AlarmDefinition, [VMware.VimAutomation.ViCore.Types.V1.Alarm.AlarmDefinition]$AlarmDefinition,
[Parameter(Mandatory = $true, ParameterSetName = 'Snmp')] [Parameter(Mandatory = $true, ParameterSetName = 'Snmp')]
[switch]$Snmp, [switch]$Snmp,
[Parameter(Mandatory = $true, ParameterSetName = 'Email')] [Parameter(Mandatory = $true, ParameterSetName = 'Email')]
[switch]$Email, [switch]$Email,
[Parameter(Mandatory = $true, ParameterSetName = 'Email')] [Parameter(Mandatory = $true, ParameterSetName = 'Email')]
[string[]]$To, [string[]]$To,
[Parameter(ParameterSetName = 'Email')] [Parameter(ParameterSetName = 'Email')]
[string[]]$Cc, [string[]]$Cc,
[Parameter(ParameterSetName = 'Email')] [Parameter(ParameterSetName = 'Email')]
[string]$Subject, [string]$Subject,
[Parameter(ParameterSetName = 'Email')] [Parameter(ParameterSetName = 'Email')]
[string]$Body, [string]$Body,
[ValidateSet('Once', 'Repeat')] [ValidateSet('Once', 'Repeat')]
[string]$GreenToYellow, [string]$GreenToYellow,
[ValidateSet('Once', 'Repeat')] [ValidateSet('Once', 'Repeat')]
[string]$YellowToRed, [string]$YellowToRed,
[ValidateSet('Once', 'Repeat')] [ValidateSet('Once', 'Repeat')]
[string]$RedToYellow, [string]$RedToYellow,
[ValidateSet('Once', 'Repeat')] [ValidateSet('Once', 'Repeat')]
[string]$YellowToGreen [string]$YellowToGreen
) )
BEGIN { BEGIN {
} }
PROCESS { PROCESS {
@@ -273,7 +278,7 @@ function New-AlarmAction {
$Alarm.ActionFrequency = $AlarmView.Info.ActionFrequency $Alarm.ActionFrequency = $AlarmView.Info.ActionFrequency
$Alarm.Action = New-Object VMware.Vim.GroupAlarmAction $Alarm.Action = New-Object VMware.Vim.GroupAlarmAction
$Trigger = New-Object VMware.Vim.AlarmTriggeringAction $Trigger = New-Object VMware.Vim.AlarmTriggeringAction
Write-Verbose -Message "Defining alarm actions" Write-Verbose -Message "Defining alarm actions"
if ($PSCmdlet.ParameterSetName -eq 'Snmp') { if ($PSCmdlet.ParameterSetName -eq 'Snmp') {
$Trigger.Action = New-Object -TypeName VMware.Vim.SendSNMPAction $Trigger.Action = New-Object -TypeName VMware.Vim.SendSNMPAction
@@ -292,7 +297,7 @@ function New-AlarmAction {
$Trigger.Action.Subject = $PSBoundParameters['Subject'] $Trigger.Action.Subject = $PSBoundParameters['Subject']
$Trigger.Action.Body = $PSBoundParameters['Body'] $Trigger.Action.Body = $PSBoundParameters['Body']
} }
Write-Verbose -Message "Defining alarm transitions" Write-Verbose -Message "Defining alarm transitions"
if ($PSBoundParameters.ContainsKey('GreenToYellow')) { if ($PSBoundParameters.ContainsKey('GreenToYellow')) {
$Trans1 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec $Trans1 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec
@@ -303,7 +308,7 @@ function New-AlarmAction {
} }
$Trigger.TransitionSpecs += $Trans1 $Trigger.TransitionSpecs += $Trans1
} }
if ($PSBoundParameters.ContainsKey('YellowToRed')) { if ($PSBoundParameters.ContainsKey('YellowToRed')) {
$Trans2 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec $Trans2 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec
$Trans2.StartState = 'yellow' $Trans2.StartState = 'yellow'
@@ -315,7 +320,7 @@ function New-AlarmAction {
} }
$Trigger.TransitionSpecs += $Trans2 $Trigger.TransitionSpecs += $Trans2
} }
if ($PSBoundParameters.ContainsKey('RedToYellow')) { if ($PSBoundParameters.ContainsKey('RedToYellow')) {
$Trans3 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec $Trans3 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec
$Trans3.StartState = 'red' $Trans3.StartState = 'red'
@@ -327,7 +332,7 @@ function New-AlarmAction {
} }
$Trigger.TransitionSpecs += $Trans3 $Trigger.TransitionSpecs += $Trans3
} }
if ($PSBoundParameters.ContainsKey('YellowToGreen')) { if ($PSBoundParameters.ContainsKey('YellowToGreen')) {
$Trans4 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec $Trans4 = New-Object -TypeName VMware.Vim.AlarmTriggeringActionTransitionSpec
$Trans4.StartState = 'yellow' $Trans4.StartState = 'yellow'
@@ -339,7 +344,7 @@ function New-AlarmAction {
} }
$Trigger.TransitionSpecs += $Trans4 $Trigger.TransitionSpecs += $Trans4
} }
$Alarm.Action.Action += $Trigger $Alarm.Action.Action += $Trigger
$Alarm.Expression = New-Object -TypeName VMware.Vim.OrAlarmExpression $Alarm.Expression = New-Object -TypeName VMware.Vim.OrAlarmExpression
$Alarm.Expression.Expression += $AlarmView.Info.Expression.Expression $Alarm.Expression.Expression += $AlarmView.Info.Expression.Expression
@@ -408,40 +413,40 @@ function New-AlarmTrigger {
.PARAMETER ObjectType .PARAMETER ObjectType
Specifies the type of object on which the event is logged, the object Specifies the type of object on which the event is logged, the object
type containing the state condition or the type of object containing the type containing the state condition or the type of object containing the
metric. metric.
When creating a state alarm trigger the only acceptable values are When creating a state alarm trigger the only acceptable values are
'HostSystem' or 'VirtualMachine'. The supported state types for each object 'HostSystem' or 'VirtualMachine'. The supported state types for each object
are as follows: are as follows:
VirtualMachine type: runtime.powerState or summary.quickStats.guestHeartbeatStatus VirtualMachine type: runtime.powerState or summary.quickStats.guestHeartbeatStatus
HostSystem type: runtime.connectionState HostSystem type: runtime.connectionState
.OUTPUTS .OUTPUTS
(Event|State|Metric)AlarmExpression (Event|State|Metric)AlarmExpression
.NOTES .NOTES
This cmdlet requires the PowerCLI module to be imported. This cmdlet requires the PowerCLI module to be imported.
.LINK .LINK
Event Alarm Trigger Event Alarm Trigger
http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.EventAlarmExpression.html http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.EventAlarmExpression.html
State Alarm Trigger State Alarm Trigger
http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.StateAlarmExpression.html http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.StateAlarmExpression.html
Metric Alarm Trigger Metric Alarm Trigger
http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.MetricAlarmExpression.html http://pubs.vmware.com/vsphere-6-0/topic/com.vmware.wssdk.apiref.doc/vim.alarm.MetricAlarmExpression.html
.EXAMPLE .EXAMPLE
PS C:\> New-AlarmTrigger -EventType "DasDisabledEvent" -Status Red -ObjectType ClusterComputeResource PS C:\> New-AlarmTrigger -EventType "DasDisabledEvent" -Status Red -ObjectType ClusterComputeResource
Comparisons : Comparisons :
EventType : DasDisabledEvent EventType : DasDisabledEvent
ObjectType : ClusterComputeResource ObjectType : ClusterComputeResource
Status : red Status : red
Creates an event trigger on 'DasDisabledEvent' (HA Disabled) with a Creates an event trigger on 'DasDisabledEvent' (HA Disabled) with a
status on 'Red'. The object type is a ClusterComputerResource because status on 'Red'. The object type is a ClusterComputerResource because
this event occurs at a cluster level. this event occurs at a cluster level.
.EXAMPLE .EXAMPLE
PS C:\> New-AlarmTrigger -MetricId (Get-MetricId | Where Name -EQ 'cpu.usage.average').Key -Operator isAbove -Yellow 90 -YellowInterval 30 -Red 98 -RedInterval 15 -ObjectType HostSytem PS C:\> New-AlarmTrigger -MetricId (Get-MetricId | Where Name -EQ 'cpu.usage.average').Key -Operator isAbove -Yellow 90 -YellowInterval 30 -Red 98 -RedInterval 15 -ObjectType HostSytem
Operator : isAbove Operator : isAbove
Type : HostSytem Type : HostSytem
Metric : VMware.Vim.PerfMetricId Metric : VMware.Vim.PerfMetricId
@@ -449,7 +454,7 @@ function New-AlarmTrigger {
YellowInterval : 30 YellowInterval : 30
Red : 9800 Red : 9800
RedInterval : 15 RedInterval : 15
Creates a trigger on the 'cpu.usage.average' metric where the warning Creates a trigger on the 'cpu.usage.average' metric where the warning
condition must be above 90% for 30mins and the alert condition must be condition must be above 90% for 30mins and the alert condition must be
above 98% for 15mins. The object type is a HostSystem. above 98% for 15mins. The object type is a HostSystem.
@@ -461,7 +466,7 @@ function New-AlarmTrigger {
StatePath : runtime.connectionState StatePath : runtime.connectionState
Yellow : Disconnected Yellow : Disconnected
Red : notResponding Red : notResponding
Creates a trigger on the 'runtime.connectionState' condition where the Creates a trigger on the 'runtime.connectionState' condition where the
warning condition is 'disconnected' and the alert condition is warning condition is 'disconnected' and the alert condition is
'notResponding'. The object type is a HostSystem. 'notResponding'. The object type is a HostSystem.
@@ -470,51 +475,51 @@ function New-AlarmTrigger {
param ( param (
[Parameter(Mandatory = $true, ParameterSetName = 'Event')] [Parameter(Mandatory = $true, ParameterSetName = 'Event')]
[string]$EventType, [string]$EventType,
[Parameter(ParameterSetName = 'Event')] [Parameter(ParameterSetName = 'Event')]
[string]$EventTypeId, [string]$EventTypeId,
[Parameter(Mandatory = $true, ParameterSetName = 'Event')] [Parameter(Mandatory = $true, ParameterSetName = 'Event')]
[ValidateSet('Green', 'Yellow', 'Red')] [ValidateSet('Green', 'Yellow', 'Red')]
[string]$Status, [string]$Status,
[Parameter(Mandatory = $true, ParameterSetName = 'State')] [Parameter(Mandatory = $true, ParameterSetName = 'State')]
[ValidateSet('runtime.powerState', 'summary.quickStats.guestHeartbeatStatus', 'runtime.connectionState')] [ValidateSet('runtime.powerState', 'summary.quickStats.guestHeartbeatStatus', 'runtime.connectionState')]
[string]$StateType, [string]$StateType,
[Parameter(Mandatory = $true, ParameterSetName = 'State')] [Parameter(Mandatory = $true, ParameterSetName = 'State')]
[VMware.Vim.StateAlarmOperator]$StateOperator, [VMware.Vim.StateAlarmOperator]$StateOperator,
[Parameter(ParameterSetName = 'State')] [Parameter(ParameterSetName = 'State')]
[ValidateSet('disconnected', 'notResponding', 'connected', 'noHeartbeat', 'intermittentHeartbeat', 'poweredOn', 'poweredOff', 'suspended')] [ValidateSet('disconnected', 'notResponding', 'connected', 'noHeartbeat', 'intermittentHeartbeat', 'poweredOn', 'poweredOff', 'suspended')]
[string]$YellowStateCondition, [string]$YellowStateCondition,
[Parameter(ParameterSetName = 'State')] [Parameter(ParameterSetName = 'State')]
[ValidateSet('disconnected', 'notResponding', 'connected', 'noHeartbeat', 'intermittentHeartbeat', 'poweredOn', 'poweredOff', 'suspended')] [ValidateSet('disconnected', 'notResponding', 'connected', 'noHeartbeat', 'intermittentHeartbeat', 'poweredOn', 'poweredOff', 'suspended')]
[string]$RedStateCondition, [string]$RedStateCondition,
[Parameter(Mandatory = $true, ParameterSetName = 'Metric')] [Parameter(Mandatory = $true, ParameterSetName = 'Metric')]
[string]$MetricId, [string]$MetricId,
[Parameter(Mandatory = $true, ParameterSetName = 'Metric')] [Parameter(Mandatory = $true, ParameterSetName = 'Metric')]
[VMware.Vim.MetricAlarmOperator]$MetricOperator, [VMware.Vim.MetricAlarmOperator]$MetricOperator,
[Parameter(ParameterSetName = 'Metric')] [Parameter(ParameterSetName = 'Metric')]
[ValidateRange(1, 100)] [ValidateRange(1, 100)]
[int32]$Yellow, [int32]$Yellow,
[Parameter(ParameterSetName = 'Metric')] [Parameter(ParameterSetName = 'Metric')]
[ValidateRange(1, 90)] [ValidateRange(1, 90)]
[int32]$YellowInterval, [int32]$YellowInterval,
[Parameter(ParameterSetName = 'Metric')] [Parameter(ParameterSetName = 'Metric')]
[ValidateRange(1, 100)] [ValidateRange(1, 100)]
[int32]$Red, [int32]$Red,
[Parameter(ParameterSetName = 'Metric')] [Parameter(ParameterSetName = 'Metric')]
[ValidateRange(1, 90)] [ValidateRange(1, 90)]
[int32]$RedInterval, [int32]$RedInterval,
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[ValidateSet('ClusterComputeResource', 'Datacenter', 'Datastore', 'DistributedVirtualSwitch', 'HostSystem', 'Network', 'ResourcePool', 'VirtualMachine')] [ValidateSet('ClusterComputeResource', 'Datacenter', 'Datastore', 'DistributedVirtualSwitch', 'HostSystem', 'Network', 'ResourcePool', 'VirtualMachine')]
[string]$ObjectType [string]$ObjectType
@@ -547,7 +552,7 @@ function New-AlarmTrigger {
$Expression.Operator = $PSBoundParameters['StateOperator'] $Expression.Operator = $PSBoundParameters['StateOperator']
$Expression.Type = $PSBoundParameters['ObjectType'] $Expression.Type = $PSBoundParameters['ObjectType']
$Expression.StatePath = $PSBoundParameters['StateType'] $Expression.StatePath = $PSBoundParameters['StateType']
if ($PSBoundParameters.ContainsKey('RedStateCondition')) { if ($PSBoundParameters.ContainsKey('RedStateCondition')) {
if ($PSBoundParameters['RedStateCondition'] -eq 'intermittentHeartbeat') { if ($PSBoundParameters['RedStateCondition'] -eq 'intermittentHeartbeat') {
$Expression.Red = 'yellow' $Expression.Red = 'yellow'
@@ -557,7 +562,7 @@ function New-AlarmTrigger {
$Expression.Red = $PSBoundParameters['RedStateCondition'] $Expression.Red = $PSBoundParameters['RedStateCondition']
} }
} }
if ($PSBoundParameters.ContainsKey('YellowStateCondition')) { if ($PSBoundParameters.ContainsKey('YellowStateCondition')) {
if ($PSBoundParameters['YellowStateCondition'] -eq 'intermittentHeartbeat') { if ($PSBoundParameters['YellowStateCondition'] -eq 'intermittentHeartbeat') {
$Expression.Yellow = 'yellow' $Expression.Yellow = 'yellow'
@@ -583,13 +588,13 @@ function Get-MetricId {
This cmdlet collects all of the available metrics from vCenter. It will This cmdlet collects all of the available metrics from vCenter. It will
provide the metric name, key, stats level, and summary of the metric. provide the metric name, key, stats level, and summary of the metric.
The information can be used to identify the available metrics on vCenter The information can be used to identify the available metrics on vCenter
as well as gathering the metric key needed for configuring an alarm. as well as gathering the metric key needed for configuring an alarm.
The metric keys are unique across vCenters. If you are connected to The metric keys are unique across vCenters. If you are connected to
more than one vCenter metrics from each vCenter will be generated. A more than one vCenter metrics from each vCenter will be generated. A
vCenter property is available to help determine the correct metric key vCenter property is available to help determine the correct metric key
on a given vCenter. This is extrememly useful when trying to create on a given vCenter. This is extrememly useful when trying to create
a metric based vCenter alarm. a metric based vCenter alarm.
.PARAMETER MetricGroup .PARAMETER MetricGroup
Specifies the name of the metric group you would like to see. Allowed Specifies the name of the metric group you would like to see. Allowed
values are 'CPU', 'Mem', 'Disk', 'Net', and 'Datastore'. values are 'CPU', 'Mem', 'Disk', 'Net', and 'Datastore'.
@@ -618,7 +623,7 @@ function Get-MetricId {
Summary : Memory usage as percentage of total configured or available memory Summary : Memory usage as percentage of total configured or available memory
vCenter : vCenter01 vCenter : vCenter01
..... .....
Collects all of the available memory metrics on the connected vCenter. Collects all of the available memory metrics on the connected vCenter.
#> #>
[CmdletBinding()] [CmdletBinding()]
@@ -626,7 +631,7 @@ function Get-MetricId {
[ValidateSet('CPU', 'Mem', 'Disk', 'Net', 'Datastore')] [ValidateSet('CPU', 'Mem', 'Disk', 'Net', 'Datastore')]
[string]$MetricGroup [string]$MetricGroup
) )
foreach ($Mgr in (Get-View PerformanceManager-PerfMgr)) { foreach ($Mgr in (Get-View PerformanceManager-PerfMgr)) {
$vCenter = $Mgr.Client.ServiceUrl.Split('/')[2] $vCenter = $Mgr.Client.ServiceUrl.Split('/')[2]
if ($PSBoundParameters.ContainsKey('MetricGroup')) { if ($PSBoundParameters.ContainsKey('MetricGroup')) {
@@ -636,7 +641,7 @@ function Get-MetricId {
} else { } else {
$Metrics += $Mgr.PerfCounter $Metrics += $Mgr.PerfCounter
} }
$Metrics | ForEach-Object -Process { $Metrics | ForEach-Object -Process {
[pscustomobject] @{ [pscustomobject] @{
Name = $_.GroupInfo.Key + "." + $_.NameInfo.key + "." + $_.RollupType Name = $_.GroupInfo.Key + "." + $_.NameInfo.key + "." + $_.RollupType
@@ -659,12 +664,12 @@ function Get-EventId {
description, and summary of the event. The information can be used to description, and summary of the event. The information can be used to
identify the available events on vCenter as well as gathering the event identify the available events on vCenter as well as gathering the event
type and event type id (if applicable) required for configuring an alarm. type and event type id (if applicable) required for configuring an alarm.
If the event type is 'EventEx' or 'ExtendedEvent' both the event type If the event type is 'EventEx' or 'ExtendedEvent' both the event type
and event type id will be required to create a new event based vCenter and event type id will be required to create a new event based vCenter
alarm. alarm.
The event types can be unique across vCenters. If you are connected to The event types can be unique across vCenters. If you are connected to
more than one vCenter events from each vCenter will be generated. A more than one vCenter events from each vCenter will be generated. A
vCenter property is available to help determine the correct event type vCenter property is available to help determine the correct event type
on a given vCenter. This is extrememly useful when trying to create on a given vCenter. This is extrememly useful when trying to create
@@ -678,7 +683,7 @@ function Get-EventId {
This cmdlet requires a connection to vCenter to collect event data. This cmdlet requires a connection to vCenter to collect event data.
.EXAMPLE .EXAMPLE
PS C:\> Get-EventId -Category Error PS C:\> Get-EventId -Category Error
EventType : ExtendedEvent EventType : ExtendedEvent
EventTypeId : ad.event.ImportCertFailedEvent EventTypeId : ad.event.ImportCertFailedEvent
Category : error Category : error
@@ -705,7 +710,7 @@ function Get-EventId {
param ( param (
[VMware.Vim.EventCategory]$Category [VMware.Vim.EventCategory]$Category
) )
foreach ($Mgr in (Get-View EventManager)) { foreach ($Mgr in (Get-View EventManager)) {
$vCenter = $Mgr.Client.ServiceUrl.Split('/')[2] $vCenter = $Mgr.Client.ServiceUrl.Split('/')[2]
if ($PSBoundParameters.ContainsKey('Category')) { if ($PSBoundParameters.ContainsKey('Category')) {
@@ -715,7 +720,7 @@ function Get-EventId {
} else { } else {
$Events += $Mgr.Description.EventInfo $Events += $Mgr.Description.EventInfo
} }
$Events | ForEach-Object -Process { $Events | ForEach-Object -Process {
$Hash = [ordered]@{} $Hash = [ordered]@{}
$Hash.Add('EventType', $_.Key) $Hash.Add('EventType', $_.Key)

Some files were not shown because too many files have changed in this diff Show More