VMware

HomeLab – VMware SRM Documentation with AsBuiltReport

Hello everyone!

These last weeks I have been working on improving my coding skills taking into account that now the trend is “Software Defined Everything”. This time I have been spending time on PowerShell creating several reports through the AsBuildReport project created by “Tim Carman” @tpcarman (Link Here).

The report I helped finish this time is related to documenting VMware Site Recovery Manager installations. The report was initially created by “Matt Allford” @mattallford and I took on the task of trying to finish the work that had already been started.

According to VMware’s documentation portal:

Site Recovery Manager (SRM) is the leading disaster recovery management solution designed to minimize downtime in the event of a disaster. It provides policy-based management and automated coordination, and enables testing of centralized recovery plans without disruption. It is designed for virtual machines and is scalable to manage all applications in a vSphere environment.

VMware Documentation

The report is in an initial state and in constant development, but I decided to release it publicly to receive recommendations or rather to encourage other developers to contribute to improve its content. The development website of the report is in Github I leave the link so you can see the scope and objective of the project.

Now, to get started we need to meet the following requirements:

  • Multi-platform Windows, Linux or MAC
  • PowerShell v5.1+ ó v7
  • AsBuiltReport.Core Module >= 1.1.0
  • VMware PowerCLI Module >= 12.3+

This report uses PowerShell version 5.+ or PSCore 7, to validate the version we can use the $PSVersionTable variable from the PowerShell console:

PS /home/rebelinux> $PSVersionTable


Name                           Value
----                           -----
PSVersion                      7.2.0
PSEdition                      Core
GitCommitId                    7.2.0
OS                             Linux 5.15.4-arch1-1 #1 SMP PREEMPT Sun, 21 Nov 2021 21:34:33 +0000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /home/rebelinux> 

To validate if we have the required modules we can use the “Get-Module” command as shown in the following example:

PS /home/rebelinux> Get-Module -ListAvailable -Name @('VMware.PowerCLI','AsBuiltReport.Core')


    Directory: /home/rebelinux/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.0                 AsBuiltReport.Core                  Desk      {New-AsBuiltReport...}
Manifest   12.4.1.18…            VMware.PowerCLI                     Desk      

PS /home/rebelinux>

If the command does not produce any result it means that the modules are not installed. To install the dependency use the “Install-Module” command:

PS /home/rebelinux>  Install-Module -Name @('VMware.PowerCLI','AsBuiltReport.Core') 
                                                                                                                                                                                                                                                                              Installing package 'VMware.PowerCLI'   
                                                                                                                                                                                                                                                     Copying unzipped package to '..\2052046370\VMware.PowerCLI'  
                                                                                                                                                                                           [oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo]   
 
PS /home/rebelinux> 

Once the prerequisites are met continue with the installation of the main module “AsBuiltReport.VMware.SRM”. Since this report has not yet been publicly released in “PowerShell Gallery” you need to manually perform the installation. The first step is to download the code from Github portal here.

Once the code is downloaded the file needs to be unzipped, for this you can use the command “Expand-Archive”.

PS /home/rebelinux/Downloads> Expand-Archive -Path ./AsBuiltReport.VMware.SRM.zip -DestinationPath .

PS /home/rebelinux/Downloads> ls AsBuiltReport.VMware.SRM

AsBuiltReport.VMware.SRM.json  AsBuiltReport.VMware.SRM.psm1       CHANGELOG.md  README.md  Src
AsBuiltReport.VMware.SRM.psd1  AsBuiltReport.VMware.SRM.Style.ps1  LICENSE       Samples
PS /home/rebelinux/Downloads> 

Then it is necessary to copy the unzipped folder “AsBuiltReport.VMware.SRM” to a path set in $env:PSModulePath. The last step to follow if on “Windows OS” is to open a PowerShell window and unlock the downloaded files using the “Unblock-File” command.

$path = (Get-Module -Name AsBuiltReport.VMware.SRM -ListAvailable).ModuleBase; Unblock-File -Path $path\*.psd1; Unblock-File -Path $path\Src\Public\*.ps1; Unblock-File -Path $path\Src\Private\*.ps1

An optional requirement is to generate configuration files that allow you to set the organization parameters that are used to generate the report. This process generates JSON files that are used as templates so that you do not have to fill in repetitive information when generating reports. To view the configuration procedure, simply click on the “+” icon.

Archivos de configuración (AsBuiltReport JSON)

The powershell cmdlet New-AsBuiltConfig allows you to generate the template that is used as the basis of the report. This template sets the non-technical parameters of the report.

PS /home/rebelinux>  New-AsBuiltConfig

---------------------------------------------
 <        As Built Report Information      >
---------------------------------------------
Enter the name of the Author for this As Built Report [jocolon]: Jonathan Colon
---------------------------------------------
 <           Company Information           >
---------------------------------------------
Would you like to enter Company information for the As Built Report? (y/n): y
Enter the Full Company Name: Zen PR Solutions
Enter the Company Short Name: ZENPR
Enter the Company Contact: Jonathan Colon
Enter the Company Email Address: jcolonf@zenprsolutions.com
Enter the Company Phone: XXX-XXX-XXXX
Enter the Company Address: Puerto Rico
---------------------------------------------
 <            Email Configuration          >
---------------------------------------------
Would you like to enter SMTP configuration? (y/n): n
----------------------------------------------
 <       As Built Report Configuration      >
----------------------------------------------
Would you like to save the As Built Report configuration file? (y/n): y
Enter a name for the As Built Report configuration file [AsBuiltReport]: HomeLab SRM Report
Enter the path to save the As Built Report configuration file [/home/rebelinux/AsBuiltReport]:

Name                           Value
----                           -----
Email                          {Port, Credentials, Server, To...}
Company                        {FullName, Contact, Phone, Email...}
UserFolder                     {Path}
Report                         {Author}


PS /home/rebelinux>

Once the process is done, a JSON file will be created with the following content:

{
    "Email":  {
                  "Port":  null,
                  "Credentials":  null,
                  "Server":  null,
                  "To":  null,
                  "From":  null,
                  "UseSSL":  null,
                  "Body":  null
              },
    "Company":  {
                    "FullName":  "Zen PR Solutions",
                    "Contact":  "Jonathan Colon",
                    "Phone":  "787-203-2790",
                    "Email":  "jcolonf@zenprsolutions.com",
                    "ShortName":  "ZENPR",
                    "Address":  "Puerto Rico"
                },
    "UserFolder":  {
                       "Path":  "/home/rebelinux/AsBuiltReport"
                   },
    "Report":  {
                   "Author":  "Jonathan Colon"
               }
}

The New-AsBuiltReportConfig command allows you to set the technical parameters of the report such as the verbose level and type of information.

PS /home/rebelinux/ New-AsBuiltReportConfig VMware.SRM -FolderPath /home/rebelinux/AsBuiltReport/

Once the process is completed, a JSON file will be created with the following content:

{
    "Report": {
        "Name": "VMware SRM As Built Report",
        "Version": "1.0",
        "Status": "Released",
        "ShowCoverPageImage": true,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {
        "ShowDefinitionInfo": false
    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
        "Summary": 1,
        "Protected": 1,
        "Recovery": 1,
        "ProtectionGroup": 1,
        "RecoveryPlan": 1,
        "InventoryMapping": 1
    },
    "HealthCheck": {
        "InventoryMapping": {
            "Status": true
        },
        "Protected": {
            "Status": true
        },
        "Recovery": {
            "Status": true
        }

    }
}

This configuration file can be used to specify the level of detail of the report as well as which report sessions are to be enabled.

Then you can generate the report using the command “New-AsBuiltReport -Report VMware.SRM -Target vCenter_FQDN_or_IP”. It is important to emphasize that it is required to use the “vCenter” server address as “Target”.

PS /home/rebelinux/> New-AsBuiltReport -Report VMware.SRM -AsBuiltConfigFilePath /home/rebelinux/script/AsBuiltReport.json -OutputFolderPath /home/rebelinux/script -Target 192.168.5.2 -Format HTML -Verbose -EnableHealthCheck -Credential $cred -ReportConfigFilePath /home/rebelinux/script/AsBuiltReport.VMware.SRM.json

VERBOSE: Loading As Built Report configuration from '/home/rebelinux/script/AsBuiltReport.json'.
VERBOSE: Loading module from path '/home/rebelinux/.local/share/powershell/Modules/AsBuiltReport.VMware.SRM/AsBuiltReport.VMware.SRM.psm1'.
VERBOSE: Loading AsBuiltReport.VMware.SRM report configuration file from path '/home/rebelinux/script/AsBuiltReport.VMware.SRM.json'.
VERBOSE: Setting report filename to 'VMware SRM As Built Report'.
VERBOSE: [ 12:49:41:970 ] [ Document ] - Document 'VMware SRM As Built Report' processing started.
VERBOSE: [ 12:49:42:016 ] [ Document ] - Executing report style script from path '/home/rebelinux/.local/share/powershell/Modules/AsBuiltReport.VMware.SRM\AsBuiltReport.VMware.SRM.Style.ps1'.
VERBOSE: [ 12:49:42:103 ] [ Document ] - Processing paragraph 'VMware SRM As Built Report'.
VERBOSE: [ 12:49:42:105 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:49:42:110 ] [ Document ] - Processing paragraph 'Zen PR Solutions'.
VERBOSE: [ 12:49:42:111 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:49:42:112 ] [ Document ] - Processing table 'Cover Page'.
VERBOSE: [ 12:49:42:114 ] [ Document ] - Processing page break.
VERBOSE: [ 12:49:42:115 ] [ Document ] - Processing table of contents 'Table of Contents'.
VERBOSE: [ 12:49:42:116 ] [ Document ] - Processing page break.
VERBOSE: [ 12:49:43:531 ] [ Document ] - Connected to protected site vCenter: 192.168.5.2
VERBOSE: [ 12:50:30:517 ] [ Document ] - Connected to vcenter-03v.zenpr.local
VERBOSE: [ 12:50:31:820 ] [ Document ] - Connected to protected site SRM: srmhq-01v.zenpr.local
VERBOSE: [ 12:50:31:821 ] [ Document ] - Processing section 'VMware Site Recovery Manager - SRMHQ-01V.' started.
VERBOSE: [ 12:50:31:823 ] [ Document ] - Processing paragraph 'VMware Site Recovery Manager is a bu[..]'.
VERBOSE: [ 12:50:31:833 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:31:835 ] [ Document ] - Summary InfoLevel set at 1.
VERBOSE: [ 12:50:36:372 ] [ Document ] - Processing table 'Placeholder Datastore Mappings - SRM-HQ'.
VERBOSE: [ 12:50:36:375 ] [ Document ] - Processing section 'Placeholder Datastore Mappings' completed.
VERBOSE: [ 12:50:36:376 ] [ Document ] - Processing section 'Inventory Mapping Summary' completed.
VERBOSE: [ 12:50:36:377 ] [ Document ] - Protected Site InfoLevel set at 1.
VERBOSE: [ 12:50:36:377 ] [ Document ] - Collecting SRM Protected Site information.
VERBOSE: [ 12:50:36:387 ] [ Document ] - Processing section 'Protected Site' started.
VERBOSE: [ 12:50:36:395 ] [ Document ] - Processing paragraph 'In a typical Site Recovery Manager i[..]'.
VERBOSE: [ 12:50:36:396 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:397 ] [ Document ] - Processing paragraph 'The following section provides a sum[..]'.
VERBOSE: [ 12:50:36:398 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:398 ] [ Document ] - Discovered Protected Site SRM-HQ.
VERBOSE: [ 12:50:36:480 ] [ Document ] - Processing table 'Protected Site Information - SRM-HQ'.
VERBOSE: [ 12:50:36:483 ] [ Document ] - Processing section 'Protected Site' completed.
VERBOSE: [ 12:50:36:483 ] [ Document ] - Recovery Site InfoLevel set at 1.
VERBOSE: [ 12:50:36:484 ] [ Document ] - Collecting SRM Recovery Site information.
VERBOSE: [ 12:50:36:535 ] [ Document ] - Processing section 'Recovery Site' started.
VERBOSE: [ 12:50:36:536 ] [ Document ] - Processing paragraph 'In a typical Site Recovery Manager i[..]'.
VERBOSE: [ 12:50:36:537 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:538 ] [ Document ] - Processing paragraph 'The following section provides a sum[..]'.
VERBOSE: [ 12:50:36:539 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:539 ] [ Document ] - Discovered Recovery Site SRM-EDGE.
VERBOSE: [ 12:50:36:551 ] [ Document ] - Processing table 'Recovery Site Information - SRM-EDGE'.
VERBOSE: [ 12:50:36:554 ] [ Document ] - Processing section 'Recovery Site' completed.
VERBOSE: [ 12:50:36:555 ] [ Document ] - Protection Group Site InfoLevel set at 2.
VERBOSE: [ 12:50:36:555 ] [ Document ] - Collecting SRM Protection Group information.
VERBOSE: [ 12:50:36:561 ] [ Document ] - Processing section 'Protection Groups Summary' started.
VERBOSE: [ 12:50:36:563 ] [ Document ] - Processing paragraph 'In Site Recovery Manager, protection[..]'.
VERBOSE: [ 12:50:36:566 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:567 ] [ Document ] - Processing paragraph 'The following section provides a sum[..]'.
VERBOSE: [ 12:50:36:570 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:673 ] [ Document ] - Discovered Protection Group ZENPR-DB-PG.
VERBOSE: [ 12:50:36:735 ] [ Document ] - Discovered Protection Group ZENPR-MON-PG.
VERBOSE: [ 12:50:36:789 ] [ Document ] - Discovered Protection Group ZENPR-WEB-PG.
VERBOSE: [ 12:50:36:841 ] [ Document ] - Discovered Protection Group ZENPR-APP-PG.
VERBOSE: [ 12:50:36:855 ] [ Document ] - Processing table 'Protection Group Information - ZENPR-APP-PG'.
VERBOSE: [ 12:50:36:858 ] [ Document ] - Processing section 'Protection Groups' started.
VERBOSE: [ 12:50:36:873 ] [ Document ] - Processing paragraph 'The following section provides detai[..]'.
VERBOSE: [ 12:50:36:874 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:36:892 ] [ Document ] - Processing section 'VMRS Type Protection Groups' started.
VERBOSE: [ 12:50:38:635 ] [ Document ] - Processing table 'VRMS Protection Group - ZENPR-APP-PG'.
WARNING: [ 12:50:38:639 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'VRMS Protection Group - ZENPR-APP-PG'.
VERBOSE: [ 12:50:38:639 ] [ Document ] - Processing section 'VMRS Type Protection Groups' completed.
VERBOSE: [ 12:50:38:640 ] [ Document ] - Processing section 'SAN Type Protection Groups' started.
VERBOSE: [ 12:50:39:145 ] [ Document ] - Processing table 'SAN Protection Group - ZENPR-APP-PG'.
VERBOSE: [ 12:50:39:147 ] [ Document ] - Processing section 'SAN Type Protection Groups' completed.
VERBOSE: [ 12:50:39:154 ] [ Document ] - Processing section 'Virtual Machine Protection Properties Summary' started.
VERBOSE: [ 12:50:39:167 ] [ Document ] - Processing paragraph 'The following section provides detai[..]'.
VERBOSE: [ 12:50:39:168 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:39:234 ] [ Document ] - Processing section 'ZENPR-DB-PG Protection Properties (PlaceHolder)' started.
VERBOSE: [ 12:50:39:804 ] [ Document ] - Processing table 'VM Recovery PlaceHolder - ZENPR-DB-PG'.
VERBOSE: [ 12:50:39:811 ] [ Document ] - Processing section 'ZENPR-DB-PG Protection Properties (PlaceHolder)' completed.
VERBOSE: [ 12:50:39:855 ] [ Document ] - Processing section 'ZENPR-MON-PG Protection Properties (PlaceHolder)' started.
VERBOSE: [ 12:50:40:156 ] [ Document ] - Processing table 'VM Recovery PlaceHolder - ZENPR-MON-PG'.
VERBOSE: [ 12:50:40:158 ] [ Document ] - Processing section 'ZENPR-MON-PG Protection Properties (PlaceHolder)' completed.
VERBOSE: [ 12:50:40:204 ] [ Document ] - Processing section 'ZENPR-WEB-PG Protection Properties (PlaceHolder)' started.
VERBOSE: [ 12:50:40:554 ] [ Document ] - Processing table 'VM Recovery PlaceHolder - ZENPR-WEB-PG'.
VERBOSE: [ 12:50:40:556 ] [ Document ] - Processing section 'ZENPR-WEB-PG Protection Properties (PlaceHolder)' completed.
VERBOSE: [ 12:50:41:181 ] [ Document ] - Processing table 'Recovery Plan Config - ZENPR-MON-RG'.
VERBOSE: [ 12:50:41:198 ] [ Document ] - Processing section 'Virtual Machine Recovery Settings Summary' started.
VERBOSE: [ 12:50:41:245 ] [ Document ] - Processing paragraph 'The following section provides detai[..]'.
VERBOSE: [ 12:50:41:246 ] [ Document ] - Processing blank line.
VERBOSE: [ 12:50:41:257 ] [ Document ] - Processing section 'ZENPR-DB-RG VM Recovery Settings' started.
VERBOSE: [ 12:50:41:349 ] [ Document ] - Discovered VM Setting Linux-DB-01V.
VERBOSE: [ 12:50:41:571 ] [ Document ] - Discovered VM Setting Linux-DB-02V.
VERBOSE: [ 12:50:41:616 ] [ Document ] - Processing table 'Virtual Machine Recovery Settings - ZENPR-DB-RG'.
VERBOSE: [ 12:50:41:619 ] [ Document ] - Processing section 'ZENPR-DB-RG VM Recovery Settings' completed.
VERBOSE: [ 12:50:41:649 ] [ Document ] - Processing section 'ZENPR-APP-RG VM Recovery Settings' started.
VERBOSE: [ 12:50:41:696 ] [ Document ] - Discovered VM Setting Linux-APP-01V.
VERBOSE: [ 12:50:41:706 ] [ Document ] - Processing table 'Virtual Machine Recovery Settings - ZENPR-APP-RG'.
VERBOSE: [ 12:50:41:709 ] [ Document ] - Processing section 'ZENPR-APP-RG VM Recovery Settings' completed.
VERBOSE: [ 12:50:41:721 ] [ Document ] - Processing section 'ZENPR-WEB-RG VM Recovery Settings' started.
VERBOSE: [ 12:50:41:766 ] [ Document ] - Discovered VM Setting Linux-WEB-01V.
VERBOSE: [ 12:50:41:777 ] [ Document ] - Processing table 'Virtual Machine Recovery Settings - ZENPR-WEB-RG'.
VERBOSE: [ 12:50:41:779 ] [ Document ] - Processing section 'ZENPR-WEB-RG VM Recovery Settings' completed.
VERBOSE: [ 12:50:41:791 ] [ Document ] - Processing section 'ZENPR-MON-RG VM Recovery Settings' started.
VERBOSE: [ 12:50:41:840 ] [ Document ] - Discovered VM Setting Linux-Mon-01v.
VERBOSE: [ 12:50:41:853 ] [ Document ] - Processing table 'Virtual Machine Recovery Settings - ZENPR-MON-RG'.
VERBOSE: [ 12:50:41:856 ] [ Document ] - Processing section 'ZENPR-MON-RG VM Recovery Settings' completed.
VERBOSE: [ 12:50:41:858 ] [ Document ] - Processing section 'Virtual Machine Recovery Settings Summary' completed.
VERBOSE: [ 12:50:41:860 ] [ Document ] - Processing section 'Recovery Plans Summary' completed.
VERBOSE: [ 12:50:41:862 ] [ Document ] - Processing section 'VMware Site Recovery Manager - SRMHQ-01V.' completed.
VERBOSE: [ 12:50:41:893 ] [ Document ] - Document 'VMware SRM As Built Report' processing completed.
VERBOSE: [ 12:50:41:897 ] [ Document ] - Total processing time '59.93' seconds.
VMware SRM As Built Report 'VMware SRM As Built Report' has been saved to '/home/rebelinux/script'.
PS /home/rebelinux/>

Here is an example of the generated report.

Additionally, I include several examples of how to invoke the report.

# Generate a VMware SRM As Built Report for vCenter Server 'vcenter.zenpr.local' using specified credentials. Export report to HTML & DOCX formats. Use default report style. Append timestamp to report filename. Save reports to 'C:\Users\Jon\Documents'

PS C:\> New-AsBuiltReport -Report VMware.SRM -Target 'vcenter.zenpr.local' -Username 'administrator@vsphere.local' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -Timestamp

# Generate a VMware SRM As Built Report for vCenter Server 'vcenter.zenpr.local' using specified credentials and report configuration file. Export report to Text, HTML & DOCX formats. Use default report style. Save reports to 'C:\Users\Jon\Documents'. Display verbose messages to the console.

PS C:\> New-AsBuiltReport -Report VMware.SRM -Target 'vcenter.zenpr.local' -Username 'administrator@vsphere.local' -Password 'P@ssw0rd' -Format Text,Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -ReportConfigFilePath 'C:\Users\Jon\AsBuiltReport\AsBuiltReport.VMware.SRM.json' -Verbose

# Generate a VMware SRM As Built Report for vCenter Server 'vcenter.zenpr.local' using stored credentials. Export report to HTML & Text formats. Use default report style. Highlight environment issues within the report. Save reports to 'C:\Users\Jon\Documents'.

PS C:\> $Creds = Get-Credential
PS C:\> New-AsBuiltReport -Report VMware.SRM -Target 'vcenter.zenpr.local' -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents' -EnableHealthCheck

# Generate a VMware SRM As Built Report for vCenter Server 'vcenter.zenpr.local' using specified credentials. Export report to HTML & DOCX formats. Use default report style. Reports are saved to the user profile folder by default. Attach and send reports via e-mail.

PS C:\> New-AsBuiltReport -Report VMware.SRM -Target 'vcenter.zenpr.local' -Username 'administrator@vsphere.local' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -SendEmail

Hasta Luego Amigos!

PowerShell – VMware PowerCLI initial vCenter Connection

Hi all,

In the previous post I showed you how to install VMware PowerCLI and a basic introduction of the purpose of this management tool. In this post I will show you how to do the initial connection to the vCenter using the PowerCLI tool. It is important to mention that PowerCLI can be used to connect to both vCenter and vSphere “ESXi” server independently but in this post I will be showing examples only referring to the vCenter server.

To start, we need to establish the initial connection to our vCenter server. PowerCLI provides the “Connect-VIServer” command for this purpose but there are also other commands to manage and even validate existing connections. The following example shows how to deploy the vCenter connect/disconnect commands.

PS /home/rebelinux> Get-Command *VIserver*


CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Get-VIServer                                       12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Connect-VIServer                                   12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Disconnect-VIServer                                12.4.0.18… VMware.VimAutomation.Core

PS /home/rebelinux>

By using the “Connect-VIServer” command we establish the initial connection to the vCenter with the IP address “192.168.5.2” on my HomeLab.

PS /home/rebelinux> Connect-VIServer -Server 192.168.5.2 -Credential (Get-Credential)

PowerShell credential request
Enter your credentials.
User: administrator@vsphere.local
Password for user administrator@vsphere.local: ********

Name                           Port  User
----                           ----  ----
192.168.5.2                    443   VSPHERE.LOCAL\Administrator

PS /home/rebelinux> 

On this example you can see that a connection to vCenter was made by using the (Get-Credential) option to request the credentials on the console. In the same way we could create a variable with preset credentials. In this example I show you how to do it.

PS /home/rebelinux> $Credenciales = Get-Credential

PowerShell credential request
Enter your credentials.
User: administrator@vsphere.local
Password for user administrator@vsphere.local: ********
PS /home/rebelinux> Connect-VIServer -Server 192.168.5.2 -Credential $Credenciales   


Name                           Port  User
----                           ----  ----
192.168.5.2                    443   VSPHERE.LOCAL\Administrator

PS /home/rebelinux> 

In the previous example the credentials are saved in a variable with the name $Credentials and then this variable is used as “Input” in the “Connect-VIServer” command using the (-Credential $Credentials) option. Once the initial connection is made you can use the variable $defaultVIServer to validate the existing connection. It is important to mention that the session found in the $defaultVIServer variable will be used by default when using the cmdlet if the “-Server” option is not specified.

PS /home/rebelinux> $defaultVIServer


Name                           Port  User
----                           ----  ----
192.168.5.2                    443   VSPHERE.LOCAL\Administrator

PS /home/rebelinux> 

By using the $defaultVIServers variable we can see all the connections previously made. As you can see in the following example multiple connections are shown where the session with the IP address “192.168.5.253” belongs to an ESXi server.

PS /home/rebelinux> $defaultVIServers                                                  


Name                           Port  User
----                           ----  ----
192.168.5.253                  443   root
192.168.5.2                    443   VSPHERE.LOCAL\Administrator

PS /home/rebelinux> 

After making the connection to our vCenter we can use any cmdlet included in PowerCLI. On the following example all VM managed by the vCenter are listed using the “Get-VM” cmdlet.

PS /home/rebelinux> Get-VM 


Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
Horizon-OPM-01V      PoweredOff 4        16.000
FreeNAS              PoweredOff 2        8.000
Horizon-CS-01V       PoweredOff 2        5.000
vcenter-01v          PoweredOn  2        12.000
Horizon-APV-01V      PoweredOff 2        4.000
cluster1-03          PoweredOff 2        8.000
Horizon-CAP-01V      PoweredOff 2        4.000
horizon-tp-01v       PoweredOff 2        4.000
cluster1-04          PoweredOff 2        8.000
Horizon-LNX-01T      PoweredOff 1        2.000
Horizon-IDM-01V      PoweredOff 2        6.000
Horizon-SQL-01V      PoweredOff 2        4.000
Horizon-IDM-01V      PoweredOff 2        6.000
Horizon-RDS-01T      PoweredOff 2        4.000
Horizon-RDS-01T      PoweredOff 2        4.000
Horizon-OPM-01V      PoweredOff 4        16.000
Horizon-UAG-02V      PoweredOff 2        4.000
Horizon-UAG-01V      PoweredOff 2        4.000
horizon-tp-01v       PoweredOff 2        4.000
Management-PC        PoweredOff 2        8.000
csr-pharmax-hq       PoweredOff 1        4.000
GNS3 Server          PoweredOff 4        20.000
Server-DC-01V        PoweredOn  2        4.000
csr-pharmax-dr       PoweredOff 1        4.000

PS /home/rebelinux

If there are connections to multiple vCenter sessions all VMs of all connected vCenters will be shown. To filter the result to only a specific vCenter you can use the “-Server” option when executing the cmdlet.

PS /home/rebelinux> Get-VMHost -Server 192.168.5.2


Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB Version
----                 --------------- ---------- ------ ----------- -----------   -------------   ------------- -------
esxsvr-00f.pharmax.… Connected       PoweredOn       4         348       13628          17.792          63.865   7.0.3
comp-01a.pharmax.lo… NotResponding   Unknown         2           0        6816           0.000           7.995        
comp-02a.pharmax.lo… NotResponding   Unknown         2           0        6816           0.000           7.995        

PS /home/rebelinux> 

Once finished interacting with the vCenter session you can use the “Disconnect-VIServer” cmdlet to disconnect the session.

PS /home/rebelinux> Disconnect-VIServer -Server 192.168.5.2

Confirm
Are you sure you want to perform this action?
Performing the operation "Disconnect VIServer" on target "User: VSPHERE.LOCAL\Administrator, Server: 192.168.5.2, Port: 443".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Yes"): Y
PS /home/rebelinux> 

Finally, by using the $defaultVIServers variable you can validate if the session was disconnected successfully.

PS /home/rebelinux> $defaultVIServers                      


Name                           Port  User
----                           ----  ----
192.168.5.253                  443   root

PS /home/rebelinux> 

See you later Amigos!

PowerShell – VMware PowerCLI Introduction

Hi all,

In this post we will see how to install and use the PowerCLI tool. Recently on the VMware Blog portal they conducted a survey on the top 10 most used VMware administrators’ tools. A curious fact is that the PowerCLI tool achieved the first place on the list for the year 2021. It is for this reason that I took the initiative to create a series of introduction articles on how to perform basic tasks using PowerCLI.

VMware describes PowerCLI as:

VMware PowerCLI is a command-line and scripting tool built on Windows PowerShell, and provides more than 800 cmdlets for managing and automating VMware vSphere, VMware Cloud Director, vRealize Operations Manager, vSAN, VMware NSX-T Data Center, VMware Cloud Services, VMware Cloud on AWS, VMware HCX, VMware Site Recovery Manager, and VMware Horizon environments.

VMware {Code}

As you can see PowerCLI is directly integrated into the VMware ecosystem and is the main tool for automation and development. With this tool you can create simple scripts as well as schedule or automate tasks in large physical and virtual datacenters.

To start using PowerCLI it is required to install the tool, to achieve this goal you can install it from a PowerShell console. In my case, I will be using ‘PowerShell Core’ on linux but it can be installed in the same way on Windows or Macos. To access PowerShell from Linux we use the “pwsh” command from a console or “shell”.

[rebelinux@xxxxx ~]$ pwsh
PowerShell 7.1.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/rebelinux>

Once you have access to the “pwsh” console you can use the “Install-Module” command to install the tool. The following example shows the result:


PS /home/rebelinux> Install-Module -Name VMware.PowerCLI                                                                                                                                                                                                                                             Installing package 'VMware.PowerCLI'
Installing dependent package 'VMware.Vim' 
Installing package 'VMware.Vim'
Downloaded 13.78 MB out of 15.25 MB.  
[ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo]
PS /home/rebelinux>                                                                                                                        

To validate which version of PowerCLI you have installed you can use the “Get-Module” command:

PS /home/rebelinux> Get-Module -ListAvailable VMware.PowerCLI

    Directory: /home/rebelinux/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   12.4.1.18VMware.PowerCLI                     Desk      

PS /home/rebelinux> 

Once PowerCLI is installed the administration modules can be used. To identify which commands or the so-called PowerShell cmdlets are available we can use the “Get-command” command.

PS /home/rebelinux> Get-Command -Module VMware* get-vm*     

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-VM                                             12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VmcClusterEdrsPolicy                           12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcOrganization                                12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcSddc                                        12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcSddcCluster                                 12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcSddcNetworkService                          12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcSddcSiteRecovery                            12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcSddcSiteRecoveryInstance                    12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VmcService                                     12.4.0.18… VMware.VimAutomation.Vmc
Cmdlet          Get-VMGuest                                        12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMGuestDisk                                    12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHost                                         12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostAccount                                  12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostAdvancedConfiguration                    12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostAttributes                               7.0.2.178… VMware.DeployAutomation
Cmdlet          Get-VMHostAuthentication                           12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostAvailableTimeZone                        12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostDiagnosticPartition                      12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostDisk                                     12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostDiskPartition                            12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostFirewallDefaultPolicy                    12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostFirewallException                        12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostFirmware                                 12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostHardware                                 12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostHba                                      12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostImageProfile                             7.0.2.178… VMware.DeployAutomation
Cmdlet          Get-VMHostMatchingRules                            7.0.2.178… VMware.DeployAutomation
Cmdlet          Get-VMHostModule                                   12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostNetwork                                  12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostNetworkAdapter                           12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostNetworkStack                             12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostNtpServer                                12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostPatch                                    12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostPciDevice                                12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfile                                  12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfileImageCacheConfiguration           12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfileRequiredInput                     12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfileStorageDeviceConfiguration        12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfileUserConfiguration                 12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostProfileVmPortGroupConfiguration          12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostRoute                                    12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostService                                  12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostSnmp                                     12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostStartPolicy                              12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostStorage                                  12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMHostSysLogServer                             12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMQuestion                                     12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMResourceConfiguration                        12.4.0.18… VMware.VimAutomation.Core
Cmdlet          Get-VMStartPolicy                                  12.4.0.18… VMware.VimAutomation.Core

PS /home/rebelinux>

In the specific case of the previous example a filter was applied to the command to show only the cmdlet starting with “get-vm*”. In the next article I will be showing you how to make the initial connection to vCenter or to a standalone ESXi server.

See you soon!

HomeLab – vDiagram Draw your Virtual Infrastructure

Hello everyone

Taking as a reference the Top 10 VMware Admin Tools” list, this time I am going to show you how to use the vDiagram tool that has the #6 position in the list of the most used tools by VMware infrastructure administrators. In essence this Powershell script captures and draws a VMware vSphere infrastructure using Microsoft Visio. Originally this tool was created by Alan Renouf @alanrenouf and currently the project is maintained by Tony Gonzalez @vDiagram_Tony.

To use this tool, the following requirements must be met:

  1. Powershell >= 5.1
  2. PowerCLI module (“Install-Module -Name VMware.PowerCLI”)
  3. Microsoft Visio 2013+

Once all the requirements are fulfilled, proceed to download the Powershell code. To download the application, click on the following link:

https://github.com/Tony-SouthFLVMUG/vDiagram2.0

Once the package is downloaded proceed to unpack the contents.

PS C:\> Expand-Archive -LiteralPath .\vDiagram2.0-master.zip -DestinationPath .
PS C:\> ls vD*


    Directory: C:\Users\jocolon\Downloads


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/26/2021  11:15 AM                vDiagram2.0-master
-a----         7/21/2021   9:37 AM       12470234 vDiagram2.0-master.zip


PS C:\>

Move to the unzipped folder and validate the content with the “ls” or “dir” command.

PS C:\> cd .\vDiagram2.0-master\
PS C:\vDiagram2.0-master> ls


    Directory: C:\vDiagram2.0-master


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2/15/2021   5:29 PM                archived
-a----         2/15/2021   5:29 PM             66 .gitattributes
-a----         2/15/2021   5:29 PM           5771 README.md
-a----         2/15/2021   5:29 PM         109288 vDiagram.ico
-a----         2/15/2021   5:29 PM         673926 vDiagram_2.0.11.ps1
-a----         2/15/2021   5:29 PM         985128 vDiagram_2.0.11.vssx
-a----         2/15/2021   5:29 PM         116398 vDiagram_Scheduled_Task_2.0.11.ps1
-a----         2/15/2021   5:29 PM         254037 vDiagram_Standard.png


PS C:\vDiagram2.0-master>

Use the “Unblock-File” command that allows us to execute files that have been downloaded from the Internet.

PS C:\vDiagram2.0-master> Unblock-File .\vDiagram_2.0.11.ps1
PS C:\vDiagram2.0-master>

In this step with the “$PSVersionTable” command confirm the Powershell version locally installed. Reviewing the requirements section above you can see that in order to use the vDiagram tool you need to have a Powershell version 5.1.x or higher. In the example below you can see that my computer has version “5.1.19041.1151”.

PS C:\vDiagram2.0-master> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1151
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1151
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\vDiagram2.0-master>

Additionally you must validate the PowerCLI module. With the “Get-Module” command you can validate the PowerCLI installed version.

PS C:\vDiagram2.0-master> Get-Module -ListAvailable -Name 'VMware.PowerCLI' | Sort-Object -Property Version -Descending | Select-Object -First 1


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   12.3.0.... VMware.PowerCLI


PS C:\vDiagram2.0-master> 

After all requirements are met you can run the script by calling file “.\vDiagram_2.0.11.ps1”.

PS C:\vDiagram2.0-master> 

PS C:\vDiagram2.0-master> .\vDiagram_2.0.11.ps1
[08/24/2021 10:45:16] VMware PowerCLI Module(s) 12.3.0.17860403 11.5.0.14912921  found on this machine.

Once the program finishes running you can see in the “Prerequisites” tab a summary of all the dependencies and their status. In the below example all dependencies are shown in green color, which indicates that they are installed.

Following the steps as shown in the “Directions” tab, it is necessary to enter the IP/FQDN address of the vCenter and the credentials. It is important to mention that a read only account is the only needed privileges needed to connect and extract the required information.

Once the vCenter information is filled in, proceed to validate the connection by pressing the “Connect to vCenter” button. As you can see in the below image the button changes to green indicating that there was a successful connection to vCenter with the provided credentials.

The next step would be to select the “Capture CSVs for Visio” tab and specify the folder where the reports will be saved. In the below example I used the <Desktop/Output> folder.

It is important to mention that for each selected value a file will be created with the information of the respective element.

Then proceed to Click on “Collect CSV Data” to start the data collection process.

Once the data collection process ends, select the “Draw Visio” tab and configure the “Select CSV Input Folder” option.

Next, the folder where the previously collected data was stored is selected. In the following example it would be the <Desktop/Output> folder that I used in the “Capture CSVs for Visio” section.

It is now important to verify that all the information needed to build the diagram has been provided by clicking on the “CSV Validation Complete” button.

In the following step it is required to specify a folder where the diagram will be saved once it has been generated. To do so, click on “Select Visio output folder” and then select the folder to be used for this purpose. In the following example I have selected <Desktop/Output>.

In the “Visio Output Folder” area select the multiple options available to generate the diagram. Once you have selected the “Output” folder you can generate the diagram by clicking on the “Draw Visio” button.

At this step click “OK” in the notification about the diagram creation.

To view the generated diagram of our virtual infrastructure, click on the “Open Visio Diagram” button.

Finally, here are some sample images of the diagrams generated using my “HomeLab” virtual infrastructure as an example.

Summary

IIn this lab a tool called vDiagram is demonstrated, which allows us to make a logical representation of how the components of our virtual infrastructure are related. The good thing about this tool is that it is available for free. I hope you liked this lab. If you have any doubts or questions about this lab, leave them in the comments. Hasta Luego!!!!

VMware Skyline Health Diagnostics Deployment

Hello everyone

This time I come to show you the integration of “VMware Skyline Health Diagnostics” (VSHD) with VMware vCenter. I will also show you how to run the diagnostics to know how is the health of your Virtual infrastructure. VSHD is a self-diagnostic platform that allows to detect and solve problems in both vSphere and vSAN product line.

This tool provides recommendations in the form of Knowledge Base articles or links to troubleshooting procedures. vSphere administrators can use this tool to troubleshoot issues before contacting VMware Global Support.

© 2021 VMware

Benefits:

  • Based on symptoms, according to VMware VSHD automatically provides links to articles with steps to resolve the problem.
  • Self-service improves the time to get recommendations to assist in problem resolution.
  • Rapid repair to help recover the infrastructure from a failure and ensure that the business operates with less disruption.

To start we must access the following link where we can download the OVA file that allows us to manage the creation of the virtual machine where the VSHD services run.

https://my.vmware.com/group/vmware/get-download?downloadGroup=SKYLINE_HD_VSPHERE

Once authenticated on the VMware portal you will be redirected to the area where you can download the file OVA.

Below is the process of creating the VM using the OVA template that you downloaded. To see the content, just click on the “+” icon.

Installing VSHD through VMware vCenter

Start by using the “Deploy OVF Template” wizard where you upload the installation file by pressing “UPLOAD FILES”.

Set a name and select the folder in which the VM object will be created.

Select the “Compute Cluster” and press “NEXT”.

Confirm the information and press “NEXT”.

Accept the Licensing Agreement and press “NEXT”.

Select the storage location where the VM will be created and press “NEXT”.

Select the network to be used by the VM and press “NEXT”.

At this stage the unique properties of the VM such as the hostname, the password of the administration accounts and the IP address information are defined.

After the information has been validated, click “FINISH” to complete the process.

The installation process can be monitored from the “Recent Tasks” tab.

An optional requirement is the association of a DNS name to the IP used in the installation process. In the following screen we can see how to register a DNS name “FQDN” using Powershell from a Windows console

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> Add-DnsServerResourceRecordA -Name vmware-shd -IPv4Address 192.168.5.70 -ZoneName zenprsolutions.local -CreatePtr -AllowUpdateAny

PS C:\Users\Administrator> Get-DnsServerResourceRecord -Name vmware-shd -ZoneName zenprsolutions.local

HostName                  RecordType Type       Timestamp            TimeToLive      RecordData
--------                  ---------- ----       ---------            ----------      ----------
vmware-shd                A          1          0                    01:00:00        192.168.5.70


PS C:\Users\Administrator>

Once the OVA file installation process is complete, you can proceed to power on the VM that will be used for the VSHD service.

When we turn on the VM we can see the DNS name information and the IP address that we previously configured.

With the IP address we can access the administration portal of the application using the following credentials:

  • Username: shd-admin
  • Password: <previously established>

The next step is to add the vCenter/ESXi information and corresponding credentials.

We can validate that the information entered is correct by pressing the “CHECK CONNECTION” button.

After validating the information and credentials, you proceed to run the diagnostic by pressing “RUN DIAGNOSTIC”.

In this screen we select the ESXi and vCenter servers you wish to scan and what type of plug-in to run during the collection of diagnostic information.

Optionally you can set up a “Tag” that can be used for an easy search of the diagnostics. Then you can click on “FINISH”.

In this next image we can see the progress of the diagnostic information gathering.

Additionally from the vCenter management console you can see a task related to the gathering process.

Once the process has finished you can view the status of the task by clicking on the “SHOW SUMMARY” button.

In this screen we can see that the tasks were executed without problems.

By pressing the “SHOW REPORT” button you can view the resulting reports.

To view the report press the eye icon as shown in the following image.

Here I show you several examples of the resulting report where you can pinpoint some of the problems with the infrastructure used as an example.

Summary

In this lab, I installed and configured the “VMware Skyline Health Diagnostics” (VSHD) which allows vSphere administrators to use this tool to troubleshoot issues before contacting VMware support. One nice thing about this tool is that it is freely available. I hope you liked this lab. If you have any doubts or questions about this lab, leave them in the comments. Regards.

HomeLab: Using vCheck for vSphere Infrastructure Health Accessment

In this opportunity I come to show you how to download and use the vCheck tool that is used to validate the health status of the VMware vSphere infrastructure. This tool is developed by Alan Renouf as a mechanism to identify possible failures or misconfiguration in the vSphere implementation. To learn more about this tool I will use the vCheck documentation as a reference:

This script picks on the key known issues and potential issues scripted as plugins for various technologies written as Powershell scripts and reports it all in one place so all you do in the morning is check your email.

vCheck Github Page

In this area I present to you what is checked when using vCheck. To view the content, just click on the “+” icon.

What is checked in the vSphere version?

  • General Details
  • Number of Hosts
  • Number of VMs
  • Number of Templates
  • Number of Clusters
  • Number of Datastores
  • Number of Active VMs
  • Number of Inactive VMs
  • Number of DRS Migrations for the last days
  • Snapshots over x Days old
  • Datastores with less than x% free space
  • VMs created over the last x days
  • VMs removed over the last x days
  • VMs with No Tools
  • VMs with CD-Roms connected
  • VMs with Floppy Drives Connected
  • VMs with CPU ready over x%
  • VMs with over x amount of vCPUs
  • List of DRS Migrations
  • Hosts in Maintenance Mode
  • Hosts in disconnected state
  • NTP Server check for a given NTP Name
  • NTP Service check
  • vmkernel warning messages ov the last x days
  • VC Error Events over the last x days
  • VC Windows Event Log Errors for the last x days with VMware in the details
  • VC VMware Service details
  • VMs stored on datastores attached to only one host
  • VM active alerts
  • Cluster Active Alerts
  • If HA Cluster is set to use host datastore for swapfile, check the host has a swapfile location set
  • Host active Alerts
  • Dead SCSI Luns
  • VMs with over x amount of vCPUs
  • vSphere check: Slot Sizes
  • vSphere check: Outdated VM Hardware (Less than V7)
  • VMs in Inconsistent folders (the name of the folder is not the same as the name)
  • VMs with high CPU usage
  • Guest disk size check
  • Host over committing memory check
  • VM Swap and Ballooning
  • ESXi hosts without Lockdown enabled
  • ESXi hosts with unsupported mode enabled
  • General Capacity information based on CPU/MEM usage of the VMs
  • vSwitch free ports
  • Disk over commit check
  • Host configuration issues
  • VCB Garbage (left snapshots)
  • HA VM restarts and resets
  • Inaccessible VMs

It is important to mention that vCheck has support for other products as shown in the following image:

Source: Virtu-Al.Net

To get started you need to download the tool from the Github portal where it is continuously developed. To download vCheck directly click on the following link “Download”. Once the script is downloaded, it is necessary to unzip it.

The first time vCheck is run it will start the configuration process, this configuration allows you to create a template with the information that will be used for all future runs of the program. To modify these parameters again you can use the <-config> option as follows:

[blabla@blabla ~]$ pwsh #Powershell core on Linux :)
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/blabla/vCheck> ./vCheck.ps1 -config

In this area I demonstrate the vCheck configuration process. To see the configuration process, just click on the “+” icon.

Configuration process example

PS /home/blabla/vCheck> ./vCheck.ps1 -config
WARNING: 
GlobalVariables
# Report header [vCheck]: 
# Would you like the report displayed in the local browser once completed ? [$true]: 
# Display the report even if it is empty? [$true]: 
# Use the following item to define if an email report should be sent once completed [$false]: 
# Please Specify the SMTP server address (and optional port) [servername(:port)] [mysmtpserver.mydomain.local]: 
# Would you like to use SSL to send email? [$false]: 
# Please specify the email address who will send the vCheck report [me@mydomain.local]: 
# Please specify the email address(es) who will receive the vCheck report (separate multiple addresses with comma) [me@mydomain.local]: 
# Please specify the email address(es) who will be CCd to receive the vCheck report (separate multiple addresses with comma) []: 
# Please specify an email subject [$Server vCheck Report]: 
# Send the report by e-mail even if it is empty? [$true]: 
# If you would prefer the HTML file as an attachment then enable the following: [$false]: 
# Set the style template to use. [Clarity]: 
# Do you want to include plugin details in the report? [$true]: 
# List Enabled plugins first in Plugin Report? [$true]: 
# Set the following setting to $true to see how long each Plugin takes to run as part of the report [$true]: 
# Report on plugins that take longer than the following amount of seconds [30]: 
WARNING: 
Connection settings for vCenter
# Please Specify the address (and optional port) of the vCenter server to connect to [servername(:port)] [vcsa.local.lab]: vcenter-01v.pharmax.local
WARNING: 
General Information
# Set the number of days of DRS Migrations to report and count on [1]: 
# Set the number of days of Storage DRS Migrations to report and count on [1]: 
WARNING: 
Checking VI Events
# Set the number of days of VC Events to check for errors [1]: 
WARNING: 
Windows vCenter Error Event Logs
# Set the number of days of VC Events to check for errors [1]: 
# Set the number of days of VC Event Logs to check for warnings and errors [1]: 
WARNING: 
Windows vCenter Error Event Logs
# Set the number of days of VC Events to check for errors [1]: 
# Set the number of days of VC Event Logs to check for warnings and errors [1]: 
WARNING: 
vCenter Sessions Age
# Enter maximum vCenter session length in hours [48]: 
# Enter minimum vCenter session length in minutes (IdleMinutes) [10]: 
# Do not report on usernames that are defined here (regex) [DOMAIN\\user1|DOMAIN\\user2]: 
WARNING: 
vCenter License Report
# Display Eval licenses? [$true]: 
WARNING: 
HA configuration issues
# HA Configuration Issues, do not report on any Clusters that are defined here [Example_Cluster_*|Test_Cluster_*]: 
# HA should be set to ... [$true]: 
# HA host monitoring should be set to ... [$true]: 
# HA Admission Control should be set to ... [$true]: 
WARNING: 
HA VMs restarted
# HA VM restart day(s) number [5]: 
WARNING: 
DRS & SDRS Migrations
# Set the number of days of DRS Migrations to report and count on [1]: 
# Set the number of days of Storage DRS Migrations to report and count on [1]: 
WARNING: 
Cluster Slot Sizes
# Minimum number of slots available in a cluster [10]: 
WARNING: 
Datastore Consistency
# Do not report on any Datastores that are defined here (Datastore Consistency Plugin) [local*|datastore*]: 
WARNING: 
Clusters with DRS disabled
# Clusters with DRS Disabled, do not report on any Clusters that are defined here [VM1_*|VM2_*]: 
WARNING: 
QuickStats Capacity Planning
# Max CPU usage for non HA cluster [0.6]: 
# Max MEM usage for non HA cluster [0.6]: 
WARNING: 
s/vMotion Information
# Set the number of days to go back and check for s/vMotions [5]: 
# Include vMotions in report [$true;]: 
# Include Storage vMotions in report [$true;]: 
WARNING: 
DRS Rules
# Display VM affinity rules? [$true]: 
# Display VM anti-affinity rules? [$true]: 
# Display HOSTaffinity rules? [$true]: 
# Set DRS Rule name exception (regex) [ExcludeMe]: 
WARNING: 
Hosts Overcommit state
# Return results in GB or MB? [GB]: 
WARNING: 
Active Directory Authentication
# Show "OK" results? [$false]: 
# Expected Domain name [mydomain.local]: 
# Expected Admin Group [ESX Admins]: 
WARNING: 
NTP Name and Service
# The NTP server which should be set on your hosts (comma-separated) [pool.ntp.org,pool2.ntp.org]: 
WARNING: 
VMKernel Warnings
# Disabling displaying Google/KB links in order to have wider message column [$true]: 
WARNING: 
Syslog Name
# The Syslog server(s) which should be set on your hosts (comma-separated) [udp://syslogserver]: 
WARNING: 
Disk Max Total Latency
# Disk Max Total Latency Settings in Milliseconds [50]: 
# Disk Max Total Latency range to inspect (1-24) Hours [24]: 
WARNING: 
Lost Access to Volume
# Set the number of days of Lost Action Volume to report and count on [1]: 
WARNING: 
Check LUNS have the recommended number of paths
# Set the Recommended number of paths per LUN [2]: 
WARNING: 
ESXi Inode Exhaustion
# Set the ESXi filesystem free Inode threshold in percent [40]: 
WARNING: 
Host Profile Compliance
# Show detailed information in report [$true]: 
# Show compliant servers [$false]: 
WARNING: 
Hosts with Upcoming Certificate Expiration
# How many days to warn before cert expiration (Default 60) [60]: 
WARNING: 
Host Multipath Policy
# The Multipath Policy (PSP Plugin) your hosts should be configured to use [VMW_PSP_RR]: 
WARNING: 
Host Power Management Policy
# Which power management policy should your hosts use? For Balanced enter "dynamic" (this is the ESXi default policy), for High Performance enter "static", for Low power enter "low". [dynamic]: 
WARNING: 
Datastore Information
# Set the warning threshold for Datastore % Free Space [15]: 
# Do not report on any Datastores that are defined here (Datastore Free Space Plugin) [local]: 
WARNING: 
Number of VMs per Datastore
# Max number of VMs per Datastore [5]: 
# Exclude these datastores from report [ExcludeMe]: 
WARNING: 
Datastore OverAllocation
# Datastore OverAllocation % [50]: 
# Exclude these datastores from report []: 
WARNING: 
Datastores with Storage IO Control Disabled
# Do not report on any Datastores that are defined here (Storage IO Control disabled Plugin) [local]: 
WARNING: 
sDRS VM Behavior not Default
# Exclude these VMs from report []: 
WARNING: 
VSAN Datastore Capacity
# Set the warning threshold for VSAN Datastore % Free Space [15]: 
WARNING: 
VSAN Configuration Maximum Disk Group Per Host Report
# Percentage threshold to warn? [80]: 
WARNING: 
VSAN Configuration Maximum Magnetic Disks Per Disk Group Report
# Percentage threshold to warn? [50]: 
WARNING: 
VSAN Configuration Maximum Total Magnetic Disks In All Disk Groups Per Host Report
# Percentage threshold to warn? [50]: 
WARNING: 
VSAN Configuration Maximum Components Per Host Report
# Percentage threshold to warn? [50]: 
WARNING: 
VSAN Configuration Maximum Hosts Per VSAN Cluster Report
# Percentage threshold to warn? [45]: 
WARNING: 
VSAN Configuration Maximum VMs Per Host Report
# Percentage threshold to warn? [50]: 
WARNING: 
VSAN Configuration Maximum VMs Per VSAN Cluster Report
# Percentage threshold to warn? [50]: 
WARNING: 
Checking Standard vSwitch Ports Free
# vSwitch Port Left [5]: 
WARNING: 
Checking Distributed vSwitch Port Groups for Ports Free
# Distributed vSwitch PortGroup Ports Left [10]: 
WARNING: 
vSwitch Security
# Warn for AllowPromiscuous enabled? [$true]: 
# Warn for ForgedTransmits enabled? [$true]: 
# Warn for MacChanges enabled? [$true]: 
WARNING: 
Snapshot Information
# Set the warning threshold for snapshots in days old [14]: 
# Set snapshot name exception (regex) [ExcludeMe]: 
# Set snapshot description exception (regex) [ExcludeMe]: 
# Set snapshot creator exception (regex) [ExcludeMe]: 
WARNING: 
Map disk region event
    # Set the number of days to show Map disk region event for [5]: 
WARNING: 
Created or cloned VMs
# Set the number of days to show VMs created for [5]: 
WARNING: 
Removed VMs
# Set the number of days to show VMs removed for [5]: 
WARNING: 
VMs with over CPU Count
# Define the maximum amount of vCPUs your VMs are allowed [2]: 
WARNING: 
VMs restarted due to Guest OS Error
# HA VM reset day(s) number due to Guest OS error [5]: 
WARNING: 
Guests with less than X MB free
# VM Disk space left, set the amount you would like to report on MBFree [1024]: 
# VM Disk space left, set the amount you would like to report on MBDiskMinSize [1024]: 
WARNING: 
Checking VM Hardware Version
# Hardware Version to check for at least [8]: 
# Adding filter for dsvas, vShield appliances or any other vms that will remain on a lower HW version [vShield*|dsva*]: 
WARNING: 
VMs in inconsistent folders
# Specify which Datastore(s) to filter from report [local]: 
WARNING: 
No VM Tools
# Do not report on any VMs who are defined here (regex) []: 
WARNING: 
VM Tools Issues
# VM Tools Issues, do not report on any VMs who are defined here []: 
WARNING: 
Removable Media Connected
# VMs with removable media not to report on []: 
WARNING: 
Single Storage VMs
# Local Stored VMs, do not report on any VMs who are defined here [Template_*|VDI*]: 
# Local Datastores, do not report on any VMs within these datastores [Local|datastore1]: 
WARNING: 
VM CPU %RDY
# CPU ready on VMs should not exceed [10.0]: 
WARNING: 
VM CPU Usage
# VM Not to go over the following amount of CPU [75]: 
# VM CPU not allowed to go over the previous amount for how many days? [1]: 
WARNING: 
Backup Garbage
# Names used in backup product snapshots. Defaults include VCB, Veeam, NetBackup, and Commvault [VCB|Consolidate|veeam|NBU_SNAPSHOT|GX_BACKUP]: 
WARNING: 
Find VMs with thick or thin provisioned vmdk
# Report on disk formats that are not "thin" or "thick", which format is not allowed? [thick]: 
# Specify Datastores to filter from report [local]: 
WARNING: 
Virtual machines with incorrect OS configuration
# VMs with incorrect OS Configuration, do not report on any VMs who are defined here [VM1_*|VM2_*]: 
WARNING: 
Virtual machines with less hard disks than partitions
# Do not report on any VMs who are defined here (regex) [VM1_*|VM2_*]: 
WARNING: 
Powered Off VMs
# VMs not to report on [Windows7*]: 
#VmPathName not to report on [-backup-]: 
# Report VMs powered off over this many days [7]: 
WARNING: 
Unwanted virtual hardware found
# Find unwanted virtual hardware [VirtualUSBController|VirtualParallelPort|VirtualSerialPort]: 
WARNING: 
Mis-named virtual machines
# Misnamed VMs, do not report on any VMs who are defined here [VM1_*|VM2_*]: 
WARNING: 
VM Network State
# Only show NICs that are set to Connect at Startup [$true]: 
WARNING: 
Reset VMs
# Set the number of days to show reset VMs [1]: 
WARNING: 
Snapshot activity
# Set the number of days to show Snapshots for [5]: 
# User exception for Snapshot removed [s-veeam]: 
WARNING: 
VMs with CPU or Memory Reservations Configured
# Do not report on any VMs who are defined here []: 
WARNING: 
VM Logging
# The number of logs to keep for each VM [10]: 
# The size logs can reach before rotating to a new log (bytes) [1000000]: 
WARNING: 
VM Tools Not Up to Date
# Do not report on any VMs who are defined here (regex) []: 
# Maximum number of VMs shown [30]: 
WARNING: 
NonPersistent Disks
# Exclude all virtual machines from report [^DV-|^MLB-]: 
WARNING: 
VMs Memory/CPU Hot Add configuration
# Should CPU hot plug be enabled [$true]: 
# Should Memory hot add be enabled [$true]: 
WARNING: 
VM - Display all VMs with CBT unexpected status
# Should CBT be enabled (true/false) [$false]: 
WARNING: 
Site Recovery Manager - RPO Violation Report
# SRM RPO Violations: Set the number of minutes an RPO has exceeded to report on [240]: 
# SRM RPO Violations: Only look for RPO events on VMs with these names: (regex) []: 
# SRM RPO Violations: Report on unresolved RPO violations only? [$true]: 
Specify Credential
Please specify server credential
User: 
User: 
User: 
User: administrator@vsphere.local
Password for user administrator@vsphere.local: ********

After setting up the initial configuration we can start running the main script of the tool using the <vCheck.ps1 -Outputpath> command. The “Outputpath” option allows us to set where the report will be saved. When you run the command it will ask you for the vCenter login credentials. In my case I used the default administrator account but it is recommended to use an account with read-only privileges.

PS /home/blabla/vCheck> ./vCheck.ps1 -Outputpath vcheck-reports/                                   

Specify Credential
Please specify server credential
User: administrator@vsphere.local #vCenter credentials
Password for user administrator@vsphere.local: ********

In this area I show you the example of the vCheck collection process. To see the result of the process, just click on the “+” icon.

vCheck Report Processing

Begin Plugin Processing                                                                                                                                                                                                                                                                             [21:54:30] ..start calculating Connection settings for vCenter by Alan Renouf v1.20 [1 of 116]                                                                                                                                                                                                      [21:54:52] ..finished calculating Connection settings for vCenter by Alan Renouf v1.20 [1 of 116]                                                                                                                                                                                                   [21:54:52] ..start calculating General Information by Alan Renouf, Frederic Martin v1.3 [2 of 116]                                                                                                                                                                                                  [21:55:04] ..finished calculating General Information by Alan Renouf, Frederic Martin v1.3 [2 of 116]                                                                                                                                                                                               [21:55:04] ..start calculating Checking VI Events by Alan Renouf v1.2 [3 of 116]                                                                                                                                                                                                                    [21:55:05] ..finished calculating Checking VI Events by Alan Renouf v1.2 [3 of 116]                                                                                                                                                                                                                 [21:55:05] ..start calculating VC Services by Alan Renouf v1.1 [4 of 116]                                                                                                                                                                                                                           [21:55:05] ..finished calculating VC Services by Alan Renouf v1.1 [4 of 116]                                                                                                                                                                                                                        [21:55:05] ..start calculating Windows vCenter Error Event Logs by Alan Renouf v1.2 [5 of 116]                                                                                                                                                                                                      [21:55:05] ..finished calculating Windows vCenter Error Event Logs by Alan Renouf v1.2 [5 of 116]                                                                                                                                                                                                   [21:55:05] ..start calculating Windows vCenter Error Event Logs by Alan Renouf v1.2 [6 of 116]                                                                                                                                                                                                      [21:55:05] ..finished calculating Windows vCenter Error Event Logs by Alan Renouf v1.2 [6 of 116]                                                                                                                                                                                                   [21:55:05] ..start calculating Windows vCenter Warning Event Logs by Alan Renouf v1.2 [7 of 116]                                                                                                                                                                                                    [21:55:05] ..finished calculating Windows vCenter Warning Event Logs by Alan Renouf v1.2 [7 of 116]                                                                                                                                                                                                 [21:55:05] ..start calculating vCenter Sessions Age by Rudolf Kleijwegt v1.2 [8 of 116]                                                                                                                                                                                                             [21:55:05] ..finished calculating vCenter Sessions Age by Rudolf Kleijwegt v1.2 [8 of 116]                                                                                                                                                                                                          [21:55:05] ..start calculating vCenter License Report by Justin Mercier, Bill Wall v1.2 [9 of 116]                                                                                                                                                                                                  [21:55:05] ..finished calculating vCenter License Report by Justin Mercier, Bill Wall v1.2 [9 of 116]                                                                                                                                                                                               [21:55:05] ..start calculating HA configuration issues by John Sneddon v1.1 [10 of 116]                                                                                                                                                                                                             [21:55:06] ..finished calculating HA configuration issues by John Sneddon v1.1 [10 of 116]                                                                                                                                                                                                          [21:55:06] ..start calculating HA VMs restarted by Alan Renouf v1.3 [11 of 116]                                                                                                                                                                                                                     [21:55:06] ..finished calculating HA VMs restarted by Alan Renouf v1.3 [11 of 116]                                                                                                                                                                                                                  [21:55:06] ..start calculating DRS & SDRS Migrations by Alan Renouf, Jonathan Medd v1.3 [12 of 116]                                                                                                                                                                                                 [21:55:06] ..finished calculating DRS & SDRS Migrations by Alan Renouf, Jonathan Medd v1.3 [12 of 116]                                                                                                                                                                                              [21:55:06] ..start calculating Cluster Slot Sizes by Alan Renouf v1.2 [13 of 116]                                                                                                                                                                                                                   [21:55:06] ..finished calculating Cluster Slot Sizes by Alan Renouf v1.2 [13 of 116]                                                                                                                                                                                                                [21:55:06] ..start calculating Cluster Configuration Issues by Alan Renouf v1.1 [14 of 116]                                                                                                                                                                                                         [21:55:06] ..finished calculating Cluster Configuration Issues by Alan Renouf v1.1 [14 of 116]                                                                                                                                                                                                      [21:55:06] ..start calculating Datastore Consistency by Robert Sexstone v1.6 [15 of 116]                                                                                                                                                                                                            [21:55:07] ..finished calculating Datastore Consistency by Robert Sexstone v1.6 [15 of 116]                                                                                                                                                                                                         [21:55:07] ..start calculating Clusters with DRS disabled by Robert van den Nieuwendijk v1.3 [16 of 116]                                                                                                                                                                                            [21:55:07] ..finished calculating Clusters with DRS disabled by Robert van den Nieuwendijk v1.3 [16 of 116]                                                                                                                                                                                         [21:55:07] ..start calculating Cluster Node version by Raphael Schitz, Frederic Martin v1.1 [17 of 116]                                                                                                                                                                                             [21:55:07] ..finished calculating Cluster Node version by Raphael Schitz, Frederic Martin v1.1 [17 of 116]                                                                                                                                                                                          [21:55:07] ..start calculating QuickStats Capacity Planning by Raphael Schitz, Frederic Martin v1.7 [18 of 116]                                                                                                                                                                                     [21:55:07] ..finished calculating QuickStats Capacity Planning by Raphael Schitz, Frederic Martin v1.7 [18 of 116]                                                                                                                                                                                  [21:55:07] ..start calculating s/vMotion Information by Alan Renouf v1.2 [19 of 116]                                                                                                                                                                                                                [21:55:08] ..finished calculating s/vMotion Information by Alan Renouf v1.2 [19 of 116]                                                                                                                                                                                                             [21:55:08] ..start calculating More RAM than free space on Datastore by Olivier TABUT, Bob Cote v1.2 [20 of 116]                                                                                                                                                                                    [21:55:08] ..finished calculating More RAM than free space on Datastore by Olivier TABUT, Bob Cote v1.2 [20 of 116]                                                                                                                                                                                 [21:55:08] ..start calculating DRS Rules by John Sneddon v1.2 [21 of 116]                                                                                                                                                                                                                           WARNING: Retrieving VM group to VMHost group DRS rules with Get-DrsRule is obsolete. Use Get-DrsVMHostRule cmdlet instead                                                                                                                                                                           [21:55:08] ..finished calculating DRS Rules by John Sneddon v1.2 [21 of 116]                                                                                                                                                                                                                        [21:55:08] ..start calculating Clusters Without Host Profile attached by John Sneddon v1.0 [22 of 116]                                                                                                                                                                                              [21:55:08] ..finished calculating Clusters Without Host Profile attached by John Sneddon v1.0 [22 of 116]                                                                                                                                                                                           [21:55:08] ..start calculating Hosts Overcommit state by Alan Renouf v1.4 [23 of 116]                                                                                                                                                                                                               [21:55:09] ..finished calculating Hosts Overcommit state by Alan Renouf v1.4 [23 of 116]                                                                                                                                                                                                            [21:55:09] ..start calculating Hosts Dead LUN Path by Alan Renouf, Frederic Martin v1.2 [24 of 116]                                                                                                                                                                                                 [21:55:09] ..finished calculating Hosts Dead LUN Path by Alan Renouf, Frederic Martin v1.2 [24 of 116]                                                                                                                                                                                              [21:55:09] ..start calculating Host Swapfile datastores by Alan Renouf v1.2 [25 of 116]                                                                                                                                                                                                             [21:55:09] ..finished calculating Host Swapfile datastores by Alan Renouf v1.2 [25 of 116]                                                                                                                                                                                                          [21:55:09] ..start calculating ESXi with Technical Support mode or ESXi Shell enabled by Alan Renouf v1.3 [26 of 116]                                                                                                                                                                               [21:55:09] ..finished calculating ESXi with Technical Support mode or ESXi Shell enabled by Alan Renouf v1.3 [26 of 116]                                                                                                                                                                            [21:55:09] ..start calculating ESXi hosts which do not have Lockdown mode enabled by Alan Renouf v1.1 [27 of 116]                                                                                                                                                                                   [21:55:09] ..finished calculating ESXi hosts which do not have Lockdown mode enabled by Alan Renouf v1.1 [27 of 116]                                                                                                                                                                                [21:55:09] ..start calculating Active Directory Authentication by Bill Wall, Dan Barr v1.2 [28 of 116]                                                                                                                                                                                              [21:55:10] ..finished calculating Active Directory Authentication by Bill Wall, Dan Barr v1.2 [28 of 116]                                                                                                                                                                                           [21:55:10] ..start calculating NTP Name and Service by Alan Renouf, Dan Barr v1.3 [29 of 116]                                                                                                                                                                                                       [21:55:10] ..finished calculating NTP Name and Service by Alan Renouf, Dan Barr v1.3 [29 of 116]                                                                                                                                                                                                    [21:55:10] ..start calculating Host Configuration Issues by Alan Renouf, Dan Barr v1.2 [30 of 116]                                                                                                                                                                                                  [21:55:10] ..finished calculating Host Configuration Issues by Alan Renouf, Dan Barr v1.2 [30 of 116]                                                                                                                                                                                               [21:55:10] ..start calculating Host Alarms by Alan Renouf, John Sneddon v1.3 [31 of 116]
[22:33:17] ..Displaying HTML results

Once the command finishes, an< .html> file will be created with the result of the report. vCheck has the feature of being able to schedule the report to be sent by e-mail on a recurring basis.. So, you can have a weekly report of how is the health of your virtual infrastructure.

Here are several examples of report generated with vCheck

I hope you liked this tool. If you have any questions or comments about this post, leave them in comments. Regards.

HomeLab – Automated VMware Infrastructure Documentation

In this blog I will be talking about how to automate the creation of documentation reports of our virtual infrastructure. There are several commercial solutions to generate this type of report but I will be talking about “As Built Report” a free tool that uses powershell as a base to build the reports.

The “As Built Report” tool uses the VMware.PowerCLI modules that we explained previously in our blog. If you want to know more about PowerCLI follow this link here. An important fact about “As Built Report” is that it is not only used to generate reports on VMware but also supports the following products:

  • VMware vSphere, NSX & SRM
  • Cisco UCS Manager
  • Nutanix Prism Element
  • Pure Storage FlashArray
  • Rubrik
  • Zerto
  • Dell/EMC VxRail
  • Cohesity DataPlatform
  • etc…

First of all to use this tool we need to validate the requirements that in general consist of the following:

  • Windows PowerShell 5.1 o later
  • VMware.PowerCLI

To install the “As Built Report” powershell module use the command <Install-Module> followed by the module name AsBuiltReport.

PS /home/blabla> Install-Module -Name AsBuiltReport

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A
PS /home/blabla>   

An optional requirement is to build a configuration file that allows you to set the organization parameters that are used to generate the report. This process generates a JSON file which is used as a template so that you do not have to fill in repetitive information when generating reports. To view the configuration procedure, simply click on the “+” icon.

AsBuiltReport JSON Configuration File

The powershell cmdlet New-AsBuiltConfig allows you to generate a template that will be used as the basis of the report. This template sets the non-technical parameters of the report.

PS C:\WINDOWS\system32> New-AsBuiltConfig

---------------------------------------------
 <        As Built Report Information      >
---------------------------------------------
Enter the name of the Author for this As Built Report [jocolon]: Jonathan Colon
---------------------------------------------
 <           Company Information           >
---------------------------------------------
Would you like to enter Company information for the As Built Report? (y/n): y
Enter the Full Company Name: Zen PR Solutions
Enter the Company Short Name: ZENPR
Enter the Company Contact: Jonathan Colon
Enter the Company Email Address: jcolonf@zenprsolutions.com
Enter the Company Phone: XXX-XXX-XXXX
Enter the Company Address: Puerto Rico
---------------------------------------------
 <            Email Configuration          >
---------------------------------------------
Would you like to enter SMTP configuration? (y/n): n
----------------------------------------------
 <       As Built Report Configuration      >
----------------------------------------------
Would you like to save the As Built Report configuration file? (y/n): y
Enter a name for the As Built Report configuration file [AsBuiltReport]: HomeLab VMware Report
Enter the path to save the As Built Report configuration file [C:\Users\jocolon\AsBuiltReport]:

Name                           Value
----                           -----
Email                          {Port, Credentials, Server, To...}
Company                        {FullName, Contact, Phone, Email...}
UserFolder                     {Path}
Report                         {Author}


PS C:\WINDOWS\system32>

Once the process is completed, a JSON file will be created with the following content:

{
    "Email":  {
                  "Port":  null,
                  "Credentials":  null,
                  "Server":  null,
                  "To":  null,
                  "From":  null,
                  "UseSSL":  null,
                  "Body":  null
              },
    "Company":  {
                    "FullName":  "Zen PR Solutions",
                    "Contact":  "Jonathan Colon",
                    "Phone":  "787-203-2790",
                    "Email":  "jcolonf@zenprsolutions.com",
                    "ShortName":  "ZENPR",
                    "Address":  "Puerto Rico"
                },
    "UserFolder":  {
                       "Path":  "C:\\Users\\jocolon\\AsBuiltReport"
                   },
    "Report":  {
                   "Author":  "Jonathan Colon"
               }
}

The New-AsBuiltReportConfig command allows you to set the technical parameters of the report such as the verbose level and type of information collected.

PS C:\WINDOWS\system32> New-AsBuiltReportConfig VMware.vSphere -FolderPath C:\Users\jocolon\AsBuiltReport\ -Filename ReportConfig

Once the process is completed, a JSON file will be created with the following content:

{
    "Report": {
        "Name": "VMware vSphere As Built Report",
        "Version": "1.0",
        "Status": "Released"
    },
    "Options": {
        "ShowLicenseKeys": false,
        "ShowVMSnapshots": true
    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Summary, 2 = Informative, 3 = Detailed, 4 = Adv Detailed, 5 = Comprehensive",
        "vCenter": 3,
        "Cluster": 3,
        "ResourcePool": 3,
        "VMHost": 3,
        "Network": 3,
        "vSAN": 3,
        "Datastore": 3,
        "DSCluster": 3,
        "VM": 2,
        "VUM": 3
    },
    "HealthCheck": {
        "vCenter": {
            "Mail": true,
            "Licensing": true
        },
        "Cluster": {
            "HAEnabled": true,
            "HAAdmissionControl": true,
            "HostFailureResponse": true,
            "HostMonitoring": true,
            "DatastoreOnPDL": true,
            "DatastoreOnAPD": true,
            "APDTimeOut": true,
            "vmMonitoring": true,
            "DRSEnabled": true,
            "DRSAutomationLevelFullyAuto": true,
            "PredictiveDRS": false,
            "DRSVMHostRules": true,
            "DRSRules": true,
            "vSANEnabled": false,
            "EVCEnabled": true,
            "VUMCompliance": true
        },
        "VMHost": {
            "ConnectionState": true,
            "HyperThreading": true,
            "ScratchLocation": true,
            "IPv6": true,
            "UpTimeDays": true,
            "Licensing": true,
            "SSH": true,
            "ESXiShell": true,
            "NTP": true,
            "StorageAdapter": true,
            "NetworkAdapter": true,
            "LockdownMode": true,
            "VUMCompliance": true
        },
        "vSAN": {},
        "Datastore": {
            "CapacityUtilization": true
        },
        "DSCluster": {
            "CapacityUtilization": true,
            "SDRSAutomationLevelFullyAuto": true
        },
        "VM": {
            "PowerState": true,
            "ConnectionState": true,
            "CpuHotAdd": true,
            "CpuHotRemove": true,
            "MemoryHotAdd": true,
            "ChangeBlockTracking": true,
            "SpbmPolicyCompliance": true,
            "VMToolsStatus": true,
            "VMSnapshots": true
        }
    }
}

Finally, we generate the report using the <New-AsBuiltReport> command with the vCenter information parameters and referencing the JSON file we have created as templates.

PS C:\WINDOWS\system32> New-AsBuiltReport -Report VMware.vSphere -Target vcenter-01v.zenprsolutions.local -Username administrator@vsphere.local -Password XXXXX -Format Word,Text,HTML -OutputFolderPath 'C:\Users\jocolon\OneDrive\Desktop\' -EnableHealthCheck -AsBuiltConfigFilePath 'HomeLab VMware Report.json' -ReportConfigFilePath 'ReportConfig.json'

VMware vSphere As Built Report 'VMware vSphere As Built Report' has been saved to 'C:\Users\jocolon\OneDrive\Desktop\'.
PS C:\WINDOWS\system32>

Once the process of collecting the information from the vCenter is finished, the command saves the report as specified with the <OutputFolderPath> parameter. The following image shows the generated report in the <Word,Text,HTML> format.

Below I show you some images showing the result of the report collected from the vCenter <vcenter-01v>:

Summary

In this lab we learned how easy it is to create documentation about our virtual infrastructure by using freely available tools. “As Built Report” is a robust tool that facilitates the manual process of creating or updating our documentation.

How To Install and Use VMware PowerCLI on ArchLinux

In this blog I will be showing you how to install the PowerCLI tool specifically on the ArchLinux operating system. Archlinux is an advanced Linux distribution that is characterized by being simple and lightweight. Additionally it offers the user full control in managing and modifying everything related to the system.

Well, to install and use PowerCLI we have to install Powershell first. PowerShell is a cross-platform automation and configuration tool. PowerShell has a large number of commands oriented to system administration. But at the same time, PowerShell is a full-featured programming language that allows writing functional programs. There are many Powershell-based administration tools from different manufacturers such as:

  • VMware PowerCLI
  • Cisco UCS PowerTool
  • NetApp PowerShell Toolkit
  • DELL\EMC Unity-Powershell 
  • Amazon AWS Tools for PowerShell

As you can see Powershell is a tool highly used by infrastructure manufacturers and is offered as a method for automation or rapid deployment of software-based infrastructure. Powershell is my second preferred programming language with Python at the top of my list.

The first thing we have to do is to install Powershell and for this I will use the program “yay” which is a tool in Archlinux to install programs from the unofficial repository “Arch User Repository”. With the command <yay -S powershell-bin> we can install the Powershell program to the system. To see the installation procedure, just click on the “+” icon.

yay -S powershell-bin

[rebelinux@blabla ~]$ yay -S powershell-bin
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur:1]  powershell-bin-7.1.3-1

:: Downloaded PKGBUILD (1/1): powershell-bin
  1 powershell-bin                           (Installed) (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> 
:: (1/1) Parsing SRCINFO: powershell-bin
==> Making package: powershell-bin 7.1.3-1 (Sat 05 Jun 2021 08:08:03 PM AST)
==> Retrieving sources...
  -> Downloading powershell_7.1.3-1.ubuntu.18.04_amd64.deb...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   647  100   647    0     0   1473      0 --:--:-- --:--:-- --:--:--  1473
100 65.1M  100 65.1M    0     0  1182k      0  0:00:56  0:00:56 --:--:-- 1201k
==> Validating source files with sha256sums...
    powershell_7.1.3-1.ubuntu.18.04_amd64.deb ... Passed
==> Making package: powershell-bin 7.1.3-1 (Sat 05 Jun 2021 08:09:00 PM AST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found powershell_7.1.3-1.ubuntu.18.04_amd64.deb
==> Validating source files with sha256sums...
    powershell_7.1.3-1.ubuntu.18.04_amd64.deb ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Extracting powershell_7.1.3-1.ubuntu.18.04_amd64.deb with bsdtar
==> Sources are ready.
==> Making package: powershell-bin 7.1.3-1 (Sat 05 Jun 2021 08:09:01 PM AST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "powershell-bin"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: powershell-bin 7.1.3-1 (Sat 05 Jun 2021 08:09:05 PM AST)
==> Cleaning up...
[sudo] password for rebelinux: 
loading packages...
warning: powershell-bin-7.1.3-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) powershell-bin-7.1.3-1

Total Installed Size:  170.21 MiB
Net Upgrade Size:        0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                                                                  [########################################################################################] 100%
(1/1) checking package integrity                                                                                                                [########################################################################################] 100%
(1/1) loading package files                                                                                                                     [########################################################################################] 100%
(1/1) checking for file conflicts                                                                                                               [########################################################################################] 100%
(1/1) checking available disk space                                                                                                             [########################################################################################] 100%
:: Processing package changes...
(1/1) reinstalling powershell-bin                                                                                                               [########################################################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
[rebelinux@blabla ~]$

There is another more advanced installation method that also allows you to install Powershell from the command line. I leave here the required commands. To see the installation procedure, just click on the “+” icon.

Manual installation of Powershell

git clone https://aur.archlinux.org/powershell-bin.git
cd powershell-bin
makepkg -si

To access the Powershell application the <pwsh> command is used to call the interpreter. From the interpreter we can run Powershell commands that are commonly called “Cmdlets”.

[rebelinux@blabla ~]$ pwsh
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/rebelinux> 

The next step to run PowerCLI is to install its module by using the <Install-Module -name VMware.PowerCLI> command from the Powershell interpreter.

PS /home/blabla> Install-Module -name VMware.PowerCLI  

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A
PS /home/blabla>  

To connect to the vCenter we use the “cmdlet” <Connect-VIServer> specifying the IP address or DNS name of the server.

PS /home/blabla> Connect-VIServer vcenter-01v.zenprsolutions.local -Verbose -Username administrator@vsphere.local -Password XXXXXX

Name                            Port User
----                            ---- ----
vcenter-01v.zenprsolutions.local 443  VSPHERE.LOCAL\Administrator

PS /home/blabla> 

I will use a basic command to do connection testing against vCenter. In this test I will use the <Get-Cluster> command to check the currently created clusters.

PS /home/blabla> Get-Cluster

Name                           HAEnabled  HAFailover DrsEnabled DrsAutomationLevel
                                          Level
----                           ---------  ---------- ---------- ------------------
RegionA01-EDGE                 False      1          True       FullyAutomated
RegionHQ-MGMT                  False      1          True       FullyAutomated
RegionA01-COMP                 True       1          True       FullyAutomated

PS /home/blabla> 

Another basic example is to use the <Get-Datastore> command to validate which datastores currently exist in the virtual DataCenter. In the output of the <Get-Datastore> command you can see the free and used space in the datastores configured in the DataCenter.

PS /home/blabla> Get-Datastore

Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
SSD-VM-HIGH-CAPACITY-PERF-KN           173.708         894.000
NVME-VM-HIGH-PERF-01                     0.017         476.750
SSD-VM-HIGH-CAPACITY-PERF-MK           251.536         931.250
HDD-VM-MED-PERF-02                   2,232.268       3,726.000
HDD-VM-MED-PERF-01                   2,509.246       3,726.000
esx-00f                                110.801         111.750
NVME-VFLASH-01                           0.840         238.250
HDD-VM-ISO-LOW-PERF                    606.936         931.250
NFS_SNAP_OFFLOAD                        29.258          50.000
SRM_PlaceHolder                         97.170          99.750
SERVER_DATASTORE                        92.444          99.750

PS /home/blabla> 

Hasta Luego Amigos!

vSphere 7 Update 2 NFS Array Snapshots Offload Support

The vSphere 7.0 U2 release provides the ability to use native snapshot when using the NFS protocol as the access mechanism. As described on the VMware blog:

NFS Improvements

NFS required a clone to be created first for a newly created VM and the subsequent ones could be offloaded to the array. With the release of vSphere 7.0 U2, we have enabled NFS array snapshots of full, non-cloned VMs to not use redo logs but instead use the snapshot technology of the NFS array in order to provide better snapshot performance. The improvement here will remove the requirement/limitation of creating a clone and enables the first snapshot also to be offloaded to the array.

What’s New in vSphere 7 Update 2 Core Storage

In this blog I explain the configuration needed to test this new feature. To start we should validate the prerequisites to be able to implement this solution. According to the VMware documentation portal the prerequisites are as follows:

  • Verify that the NAS array supports the fast file clone operation with the VAAI NAS program.
  • On your ESXi host, install vendor-specific NAS plug-in that supports the fast file cloning with VAAI.
  • Follow the recommendations of your NAS storage vendor to configure any required settings on both the NAS array and ESXi.

The NFS configuration will be done in NetApp Ontap using the “NetApp NFS Plug-in for VMware VAAI” plugin that recently added native NFS snapshot offload support.

Note: The plug-in can be downloaded from the NetApp support portal at the following link “NetApp Support”.

© 2021 NetApp

Once we are in the NetApp support portal we must download version 2.0 of the plugin as shown in the following image. To install the plugin we need to unzip the downloaded file and rename the file inside the folder named vib20 with the extension .vib to the new name NetAppNasPlugin.vib.

© 2021 NetApp

In the next step I used the NetApp Ontap Tools to install the plugin but it can also be installed using VMware Lifecycle Manager.

To install the plugin go to [ONTAP tools => Settings => NFS VAAI tools] and in the “Existing version:” section press “BROWSE” to select where the “NetAppNasPlugin.vib” file is stored. Once the file is located press “UPLOAD” to load and install the plugin.

In this step we can see how to install the plugin to the ESXi servers by pressing the “INSTALL” button.

The following image shows that the installation of the plugin was successful. An advantage of the new version of the plugin is that no reboot of the ESXi server is required.

After installing the plugin we will proceed to validate that the Ontap Storage has support for VMware vStorage APIs for Array Integration (VAAI) features in the NFS environment. This can be verified with the command <vserver nfs show -fields vstorage>. As you can see the vStorage function is currently disabled in the SVM called NFS. To enable the vStorage function use the <vserver nfs modify -vstorage enabled> command.

OnPrem-HQ::> vserver nfs show -fields vstorage 
vserver vstorage 
------- -------- 
NFS     disabled  

OnPrem-HQ::> vserver nfs modify -vstorage enabled -vserver NFS 

OnPrem-HQ::> vserver nfs show -fields vstorage                 
vserver vstorage 
------- -------- 
NFS     enabled  

OnPrem-HQ::> 

The next requirement to be able to use native snapshot offload is the creation of an advanced setting in the VM configuration called snapshot.alwaysAllowNative. To add this value you have to go to the VM properties then to [VM Options => Advanced => EDIT CONFIGURATION].

The following image shows the value of the <snapshot.alwaysAllowNative> variable that according to VMware documentation must have a value equal to “TRUE”. You can use the following link as reference “VMware Documentation”

Now i start testing to validate that the native snapshot is working in Ontap. First i will create a snapshot with the <snapshot.alwaysAllowNative> function set to FALSE. Then i will make changes to the VM so that i can measure the speed of deleting and applying the snapshot changes to the base disk. In the example shown below the command <New-Snapshot> in PowerCLI was used to create a snapshot of the VM named RocaWeb

PS /home/rebelinux> get-vm -Name RocaWeb | New-Snapshot -Name PRE_Native_Array_Snapshot | Format-Table -Wrap -AutoSize  
                                                                                                                                                                                                                                               Name                      Description PowerState                                                                                                                                                                                               ----                      ----------- ----------                                                                                                                                                                                               PRE_Native_Array_Snapshot             PoweredOff                                                                                                                                                                                                                                                                                                                                                                                                                                              
PS /home/rebelinux> 

In this step a 10GB file was copied to grow the snapshot so that i can measure how fast the changes are applied to the base disk when the snapshot is deleted. In this example the file “RocaWeb_2-000001-delta.vmdk” represents the delta where the snapshot changes are saved. This represents a traditional VMware snapshot.

[root@comp-01a:/vmfs/volumes/55ab62ec-2abeb31b/RocaWeb] ls -alh
total 35180596
drwxr-xr-x    2 root     root        4.0K May 31 23:40 .
drwxr-xr-x    7 root     root        4.0K May 31 19:02 ..
-rw-------    1 root     root      276.0K May 31 23:40 RocaWeb-Snapshot15.vmsn
-rw-------    1 root     root        4.0G May 31 23:40 RocaWeb-a03f2017.vswp
-rw-------    1 root     root      264.5K May 31 23:40 RocaWeb.nvram
-rw-------    1 root     root         394 May 31 23:40 RocaWeb.vmsd
-rwxr-xr-x    1 root     root        3.4K May 31 23:40 RocaWeb.vmx
-rw-------    1 root     root       10.0G May 31 23:51 RocaWeb_2-000001-delta.vmdk #Delta (VMFS Based Snapshot)
-rw-------    1 root     root         301 May 31 23:40 RocaWeb_2-000001.vmdk
-rw-------    1 root     root      500.0G May 31 23:37 RocaWeb_2-flat.vmdk
-rw-------    1 root     root         631 May 31 23:37 RocaWeb_2.vmdk
[root@comp-01a:/vmfs/volumes/55ab62ec-2abeb31b/RocaWeb]

The following image shows the time it took to apply the snapshot changes to the base disk when the snapshot was removed. In summary the operation took 9 minutes in total using traditional VMware snapshot.

Note: Ontap simulator was used for this lab.

In this last example the <New-Snapshot> command was also used to create the snapshot but with the <snapshot.alwaysAllowNative> option set to “TRUE”. In that way i can test the use of Native Snapshot Offload in NFS. Here again, a 10GB file was copied to the VM to grow the snapshot, so i can measure how quickly changes are applied to the base disk when the snapshot is deleted.

PS /home/rebelinux> get-vm -Name RocaWeb | New-Snapshot -Name POST_Native_Array_Snapshot | Format-Table -Wrap -AutoSize
                                                                                                                                                                                                                                               Name                       Description PowerState                                                                                                                                                                                              ----                       ----------- ----------                                                                                                                                                                                              POST_Native_Array_Snapshot             PoweredOff                                                                                                                                                                                                                                                                                                                                                                                                                                             
PS /home/rebelinux> 

Here we can see that there is no “-delta.vmdk” file but there is a file named “RocaWeb_2-000001-flat.vmdk” with the same size of 500GB as the “RocaWeb_2-flat.vmdk” file. This allows us to confirm that the NFS Native Snapshot Offload feature is enabled in Ontap.

[root@comp-01a:/vmfs/volumes/55ab62ec-2abeb31b/RocaWeb] ls -alh
total 49419672
drwxr-xr-x    2 root     root        4.0K Jun  1 00:07 .
drwxr-xr-x    7 root     root        4.0K May 31 19:02 ..
-rw-------    1 root     root      276.0K Jun  1 00:07 RocaWeb-Snapshot16.vmsn
-rw-------    1 root     root        4.0G Jun  1 00:07 RocaWeb-a03f2017.vswp
-rw-------    1 root     root      264.5K Jun  1 00:07 RocaWeb.nvram
-rw-------    1 root     root         393 Jun  1 00:07 RocaWeb.vmsd
-rwxr-xr-x    1 root     root        3.4K Jun  1 00:07 RocaWeb.vmx
-rw-------    1 root     root      500.0G Jun  1 00:09 RocaWeb_2-000001-flat.vmdk #No Delta (Array Based Snapshot OffLoad)
-rw-------    1 root     root         650 Jun  1 00:07 RocaWeb_2-000001.vmdk
-rw-------    1 root     root      500.0G Jun  1 00:03 RocaWeb_2-flat.vmdk
-rw-------    1 root     root         631 Jun  1 00:07 RocaWeb_2.vmdk
[root@comp-01a:/vmfs/volumes/55ab62ec-2abeb31b/RocaWeb] 

The following image shows the time it took to apply the snapshot changes to the base disk when the snapshot was removed using the NFS Native Snapshot Offload. In summary, you can see that applying the snapshot changes to the base disk took no time at all to finish.

Summary

NFS native snapshot offload operations are so fast because ONTAP references metadata when it creates a Snapshot copy, rather than copying data blocks, that why Snapshot copies are so efficient. Doing so eliminates the seek time that other systems incur in locating the blocks to copy, as well as the cost of making the copy itself.

HomeLab – How to enable VMware TPS for greater virtual machine consolidation

In this blog, I will be talking about how you can optimize RAM utilization in your “HomeLab”. The main objective of this tutorial is that you can achieve higher levels of consolidation while running your labs.

“Transparent Page Sharing” (TPS) is a method by which duplicate copies of memory pages are consolidated. In other words, the concept of TPS is somewhat similar to deduplication. This helps the ESXi server to free up repeated memory blocks of a virtual machine allowing for increased levels of consolidation.

Memory Deduplication

If you want to know a little more about TPS, its benefits and risks, you can access the following link “Transparent Page Sharing (TPS) in hardware MMU systems”. Although it is known that the use of TPS can be a security risk, it is my understanding that it may not pose a significant risk in a test environment such as ours. I provide a reference for this information:

In a nutshell, independent research indicates that TPS can be abused to gain unauthorized access to data under certain highly controlled conditions. In line with its “secure by default” security posture, VMware has opted to change the default behavior of TPS and provide customers with a configurable option for selectively and more securely enabling TPS in their environment. 

Disabling TPS in vSphere – Impact on Critical Applications

Note: I show you how to change this value using Powershell because it allows you to make the change to multiple servers at the same time.

To begin we must verify what value is currently configured on the ESXi servers. To accomplish this task i use the <Get-VMHost> command to extract the information of the servers connected to the vCenter. The result is then sent to the <Get-AdvancedSetting -Name Mem.ShareForceSalting> command which allows us to extract the value configured in the “Mem.ShareForceSalting” variable.

PS /home/blabla> Get-VMHost | Get-AdvancedSetting -Name Mem.ShareForceSalting | Select-Object Entity,Name,Value,Type | Format-Table -Wrap -AutoSize

Entity                          Name                  Value   Type
------                          ----                  -----   ----
esxsvr-00f.zenprsolutions.local Mem.ShareForceSalting     2 VMHost
comp-02a.zenprsolutions.local   Mem.ShareForceSalting     2 VMHost
comp-01a.zenprsolutions.local   Mem.ShareForceSalting     2 VMHost

PS /home/blabla> 

In this particular example the ESXi servers are configured with a default value of #2. Using the VMware documentation as a reference this value indicates that the “Inter-VM” TPS feature is disabled.

To activate the TPS “Inter-VM” function you can use the command <Set-AdvancedSetting> with the value of #0. It is worth to mention that this command can be activated with the VMs powered on or without the server being in maintenance.

PS /home/blabla> Get-VMHost -Name esxsvr-00f.zenprsolutions.local | Get-AdvancedSetting -Name Mem.ShareForceSalting | Set-AdvancedSetting -Value 0        

Perform operation?
Modifying advanced setting 'Mem.ShareForceSalting'.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y

Name                 Value                Type                 Description
----                 -----                ----                 -----------
Mem.ShareForceSalting 0                    VMHost               

PS /home/blabla> 

Once again you can validate with the <Get-AdvancedSetting> command if the configured value is the one i specified previously.

PS /home/blabla> Get-VMHost | Get-AdvancedSetting -Name Mem.ShareForceSalting | Select-Object Entity,Name,Value,Type | Format-Table -Wrap -AutoSize

Entity                          Name                  Value   Type
------                          ----                  -----   ----
esxsvr-00f.zenprsolutions.local Mem.ShareForceSalting     0 VMHost
comp-02a.zenprsolutions.local   Mem.ShareForceSalting     2 VMHost
comp-01a.zenprsolutions.local   Mem.ShareForceSalting     2 VMHost

PS /home/blabla> 

For this test i turned on 23 virtual machines (Windows) to bring the server in contention mode so that i can see what benefits the TPS has. This result I show you below represents the memory statistics of the ESXi server obtained with the command <esxtop>. Here you can see the statistics before i configured the “TPS Inter-VM” function with the value #2. The variable that is in bold “PSHARE/MB” represents the value of shared memory that the server currently has, i.e. only TPS is being used in “Intra-VM” mode. This variable has a value of 1400/MB.

2:58:11pm up 50 min, 722 worlds, 23 VMs, 45 vCPUs; MEM overcommit avg: 1.10, 1.10, 0.99
PMEM  /MB: 65398   total: 2139     vmk,60782 other, 2358 free
VMKMEM/MB: 65073 managed:  1265 minfree,  7501 rsvd,  57572 ursvd,  high state
PSHARE/MB:    1648  shared,     248  common:    1400 saving

Now i move on to validate the benefit of having the “TPS Inter-VM” feature enabled. As you can see in the following result of the <esxtop> command there was a substantial saving (32097/MB) of memory. This allowed us to increase the consolidation ratios of our “HomeLab”.

3:36:46pm up  1:29, 1024 worlds, 23 VMs, 45 vCPUs; MEM overcommit avg: 1.05, 1.05, 0.95
PMEM  /MB: 65398   total: 2262     vmk,60078 other, 3057 free
VMKMEM/MB: 65073 managed:  1265 minfree,  9092 rsvd,  55980 ursvd, clear state
PSHARE/MB:   33038  shared,     941  common:   32097 saving

Hasta Luego Amigos!