HomeLab – Veeam VBR Documentation with AsBuiltReport

Hello everyone!

As you know, due to the impact of the Covid-19 pandemic, I haven’t had much room to do anything but stay confined to my home 😒. Another reason is that many of my family members have tested positive for the virus. So this situation has been the best excuse for me to get into development. Recently I have received many requests from users and friends to develop a report to document the Backup application made by “Veeam”.

For this reason, I took on the task of developing one more report, yes one more 🤣 and it is related to the documentation of “Veeam Backup & Replication” implementations. Currently only the latest version of Veeam is supported but I will evaluate in the future the possibility of adding support for versions prior to 11. This project is based on the AsBuildReport framework created by “Tim Carman” @tpcarman (Project Page).

The report is in an early stage and under constant development, but I have decided to release it to the public to receive recommendations or rather to encourage other developers to contribute to improve its content. The code of the report is in Github so I leave here the link in order that you can see the status and objective of the project.

Important: The module is now published in the PowerShell Gallery.

Now, to get started, the following requirements must be met:

  • Windows OS (Veeam modules run on Windows only)
  • PowerShell v5.1+
  • AsBuiltReport.Core module >= 1.1.0
  • Veeam.Backup.PowerShell module >= 1.0
  • SQLServer module >+ 21.1

To validate the Powershell version, the variable “$PSVersionTable” can be used from a PowerShell console:

PS C:\Users\jocolon> $PSVersionTable


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


PS C:\Users\jocolon>

To confirm if the required Veeam modules are present, the “Get-Module” cmdlet can be used as shown in the following example:

PS C:\Users\jocolon> Get-Module -ListAvailable -Name @('Veeam.Backup.PowerShell')

    Directory: C:\Program Files\Veeam\Backup and Replication\Console


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.Backup.PowerShell             {Get-VBRComputerFileProxyServe....}


PS C:\Users\jocolon> 

If the command does not return any results, it means that the module is not installed. It is important to point out that the Veeam.Backup.PowerShell modules are available on the Veeam Backup server or on any device where the management console is already installed. Reference:

The remote machine from which you run Veeam PowerShell commands must have the Veeam Backup & Replication Console installed. After you install the Veeam Backup & Replication Console, Veeam PowerShell module will be installed by default

Veeam PowerShell Reference

To install the AsBuiltReport.Veeam.VBR from PowerShell Gallery use the traditional “Install-Module” command:

PS C:\Users\jocolon> Install-Module -Name AsBuiltReport.Veeam.VBR  
                                                                                                                        
Installing package 'AsBuiltReport.Veeam.VBR' [Installing dependent package 'SqlServer']  
  Installing package 'SqlServer' [Downloaded 16.73 MB out of 23.76 MB.]

PS C:\Users\jocolon> 

To confirm if all the dependencies have been installed you can use the “Get-Module” cmdlet.

PS C:\Users\jocolon> Get-Module -ListAvailable -Name @('Veeam.Backup.PowerShell','SQLServer','AsBuiltReport.Veeam.VBR','AsBuiltReport.Core')     
                                                                                                                        

    Directory: C:\Users\jocolon\Documents\WindowsPowerShell\Modules

ModuleType   Version    Name
----------   -------    ----
    Script   1.1.0      AsBuiltReport.Core
    Script   0.3.0      AsBuiltReport.Veeam.VBR
    Script   21.1.18256 SqlServer
    Manifest 1.0        Veeam.Backup.PowerShell  

PS C:\Users\jocolon> 

If for some reason you can not install the report through PowerShell Gallery I leave here the manual installation method. To view the install procedure, simply click on the “+” icon.

Manual module install (Github)

Once the prerequisites are met the installation of the main module “AsBuiltReport.Veeam.VBR” can continue. Since this report has not yet been publicly released in “PowerShell Gallery” I will perform the installation manually. The first step is to download the code from the Github portal here.

Files can be downloaded through the Powershell console:

$Source = "https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/archive/refs/heads/dev.zip"
$Destination = '.\AsBuiltReport.Veeam.VBR.zip'

PS C:\Users\jocolon> Invoke-WebRequest -Uri $Source -OutFile $Destination

 Writing web request
    Writing request stream... (Number of bytes written: 51202)

PS C:\Users\jocolon> ls AsBuiltReport.Veeam.VBR.zip

    Directory: C:\Users\jocolon

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----             1/7/2022 1:58 PM         86404 AsBuiltReport.Veeam.VBR.zip

PS C:\Users\jocolon>

Once the source code is downloaded, you need to unzip the file, use the “Expand-Archive” cmdlet to achieve this goal.

PS C:\Users\jocolon> Expand-Archive -Path ./AsBuiltReport.Veeam.VBR.zip -DestinationPath .

PS C:\Users\jocolon> Rename-Item -Path .\AsBuiltReport.Veeam.VBR-dev -NewName .\AsBuiltReport.Veeam.VBR

PS C:\Users\jocolon> ls AsBuiltReport.Veeam.VBR

    Directory: C:\Users\jocolon\AsBuiltReport.Veeam.VBR-dev

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          1/7/2022   2:08 PM                .github
d-----          1/7/2022   2:08 PM                .vscode
d-----          1/7/2022   2:08 PM                Src
-a----          1/5/2022  10:52 AM           1191 AsBuiltreport.Veeam.VBR.json
-a----          1/5/2022  10:52 AM           3996 AsBuiltReport.Veeam.VBR.psd1
-a----          1/5/2022  10:52 AM            542 AsBuiltReport.Veeam.VBR.psm1
-a----          1/5/2022  10:52 AM          56642 AsBuiltReport.Veeam.VBR.Style.ps1
-a----          1/5/2022  10:52 AM           1871 CHANGELOG.md
-a----          1/5/2022  10:52 AM           1070 LICENSE
-a----          1/5/2022  10:52 AM          11796 README.md

PS C:\Users\jocolon> 

Next it is required to copy the unzipped folder “AsBuiltReport.Veeam.VBR” to a path set in $env:PSModulePath. To do this, you must first identify the folder where the content will be copied.

PS C:\Users\jocolon> $env:PSModulePath.split(";")

C:\Users\jocolon\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\Veeam\Backup and Replication\Console\
C:\Program Files\Veeam\Backup and Replication\Explorers\Exchange\
C:\Program Files\Veeam\Backup and Replication\Explorers\SharePoint\
C:\Program Files\Veeam\Backup and Replication\Explorers\SQL\
C:\Program Files\Veeam\Backup and Replication\Explorers\ActiveDirectory\
C:\Program Files\Veeam\Backup and Replication\Explorers\Oracle\
C:\Program Files\Veeam\Backup and Replication\Explorers\Teams\
c:\Users\jocolon\.vscode\extensions\ms-vscode.powershell-2021.12.0\modules

PS C:\Users\jocolon> Copy-Item -Path .\AsBuiltReport.Veeam.VBR\ -Destination "C:\Users\jocolon\Documents\WindowsPowerShell\Modules\AsBuiltReport.Veeam.VBR" -PassThru -Recurse

PS C:\Users\jocolon>

The last step is to open a PowerShell window and unlock the downloaded files with the “Unblock-File” cmdlet.

PS C:\Users\jocolon> $path = (Get-Module -Name AsBuiltReport.Veeam.VBR -ListAvailable).ModuleBase; Unblock-File -Path $path\*.*

PS C:\Users\jocolon>


PS C:\Users\jocolon> Get-Module -Name AsBuiltReport.Veeam.VBR -ListAvailable


   Directory: C:\Users\jocolon\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.1.0      AsBuiltReport.Veeam.VBR             {Get-AbrVbrBackupServerCertificat....}


PS C:\Users\jocolon> Import-Module AsBuiltReport.Veeam.VBR -force 

An optional requirement is to build the configuration files that allow you to set the organization parameters needed to create the report. This process builds a JSON file used as template so that you do not have to fill in repetitive information when building the reports. To view the configuration procedure, simply click on the “+” icon.

Configuration Files (AsBuiltReport JSON)

The powershell cmdlet New-AsBuiltConfig allows you to build the template that we will use as the basis of the report. This template sets the non-technical parameters of the report.

PS C:\Users\jocolon>  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]: AsBuiltReport
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:\Users\jocolon>

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

{
    "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-XXXX",
                    "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 type of data collected and the “verbose” level.

PS C:\Users\jocolon> New-AsBuiltReportConfig Veeam.VBR -FolderPath C:\Users\jocolon\AsBuiltReport\

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

{
    "Report": {
        "Name": "Veeam VBR As Built Report",
        "Version": "1.0",
        "Status": "Released",
        "ShowCoverPageImage": true,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {

    },
    "InfoLevel": {
		"_comment_": "Please refer to the AsBuiltReport project contributing guide for information about how to define InfoLevels.",
        "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
        "Infrastructure": {
            "Section": 1,
            "BackupServer": 1,
            "Proxy": 1,
            "Settings": 1,
            "BR": 1,
            "Licenses": 1,
            "SOBR": 1,
            "WANAccel": 1,
            "SureBackup": 1

        },
        "Tape": {
            "Section": 1,
            "Server": 1,
            "Library": 1
        }
    },
    "HealthCheck": {
        "Infrastructure": {
            "Proxy": true,
            "Settings": true,
            "BR": true,
            "SOBR": true,
            "Server": true,
            "Status": true

        },
        "Tape": {
            "Status": true
        }

    }
}

The resulting configuration file can be used to specify the level of detail of the report, as well as the report sessions to be enabled.

Finally, the “New-AsBuiltReport” cmdlet is used to build the report. It is important to note that it is required to use the IP address or the FQDN of the Veeam Backup Server as “Target”.

# Store Credential in a Variable
PS C:\Users\jocolon> $Credential = Get-Credential
PowerShell credential request
Enter your credentials.
User: Veeam_Admin
Password for user Veeam_Admin: ***********

# Final Command 
PS C:\Users\jocolon> New-AsBuiltReport -Report Veeam.VBR -Target veeam-vbr.pharmax.local -AsBuiltConfigFilePath C:\Users\jocolon\AsBuiltReport\AsBuiltReport.json -OutputFolderPath C:\Users\jocolon\AsBuiltReport\ -Credential $Credential -Format HTML -ReportConfigFilePath C:\Users\jocolon\AsBuiltReport\AsBuiltReport.Veeam.VBR.json -EnableHealthCheck -Verbose

VERBOSE: Loading As Built Report configuration from 'C:\Users\jocolon\AsBuiltReport\AsBuiltReport.json'.
VERBOSE: Loading module from path 'C:\Users\jocolon\Documents\WindowsPowerShell\Modules\AsBuiltReport.Veeam.VBR\AsBuiltReport.Veeam.VBR.psm1'.
VERBOSE: Loading AsBuiltReport.Veeam.VBR report configuration file from path 'C:\Users\jocolon\AsBuiltReport\AsBuiltReport.Veeam.VBR.json'.
VERBOSE: Setting report filename to 'Veeam VBR As Built Report'.
VERBOSE: [ 15:04:09:872 ] [ Document ] - Document 'Veeam VBR As Built Report' processing started.
VERBOSE: [ 15:04:10:005 ] [ Document ] - Executing report style script from path 'C:\Users\jocolon\Documents\WindowsPowerShell\Modules\AsBuiltReport.Veeam.VBR\AsBuiltReport.Veeam.VBR.Style.ps1'.
VERBOSE: [ 15:04:10:036 ] [ Document ] - Setting global document options.
VERBOSE: [ 15:04:10:056 ] [ Document ] - Enabling section/heading numbering.
VERBOSE: [ 15:04:10:057 ] [ Document ] - Setting default font(s) to 'Arial'.
VERBOSE: [ 15:04:10:061 ] [ Document ] - Setting page top margin to '25.05'mm.
VERBOSE: [ 15:04:10:067 ] [ Document ] - Setting page right margin to '25.05'mm.
VERBOSE: [ 15:04:10:069 ] [ Document ] - Setting page bottom margin to '25.05'mm.
VERBOSE: [ 15:04:10:070 ] [ Document ] - Setting page left margin to '25.05'mm.
VERBOSE: [ 15:04:10:072 ] [ Document ] - Setting page size to 'A4'.
VERBOSE: [ 15:04:10:074 ] [ Document ] - Setting page orientation to 'Portrait'.
VERBOSE: [ 15:04:10:079 ] [ Document ] - Setting page height to '297'mm.
VERBOSE: [ 15:04:10:081 ] [ Document ] - Setting page width to '210'mm.
VERBOSE: [ 15:04:10:083 ] [ Document ] - Setting document style 'Title'.
VERBOSE: [ 15:04:10:085 ] [ Document ] - Setting document style 'Title2'.
VERBOSE: [ 15:04:10:105 ] [ Document ] - Setting document style 'Title3'.
VERBOSE: [ 15:04:10:110 ] [ Document ] - Setting document style 'Heading1'.
VERBOSE: [ 15:04:10:117 ] [ Document ] - Setting document style 'Heading2'.
VERBOSE: [ 15:04:10:121 ] [ Document ] - Setting document style 'Heading3'.
VERBOSE: [ 15:04:10:126 ] [ Document ] - Setting document style 'Heading4'.
VERBOSE: [ 15:04:10:129 ] [ Document ] - Setting document style 'Heading5'.
VERBOSE: [ 15:04:10:134 ] [ Document ] - Setting document style 'Heading6'.
VERBOSE: [ 15:04:10:136 ] [ Document ] - Setting document style 'Normal'.
VERBOSE: [ 15:04:10:159 ] [ Document ] - Setting document style 'Caption'.
VERBOSE: [ 15:04:10:162 ] [ Document ] - Setting document style 'Header'.
VERBOSE: [ 15:04:10:174 ] [ Document ] - Setting document style 'Footer'.
VERBOSE: [ 15:04:10:176 ] [ Document ] - Setting document style 'TOC'.
VERBOSE: [ 15:04:10:179 ] [ Document ] - Setting document style 'TableDefaultHeading'.
VERBOSE: [ 15:04:10:182 ] [ Document ] - Setting document style 'TableDefaultRow'.
VERBOSE: [ 15:04:10:185 ] [ Document ] - Setting document style 'Critical'.
VERBOSE: [ 15:04:10:192 ] [ Document ] - Setting document style 'Warning'.
VERBOSE: [ 15:04:10:216 ] [ Document ] - Setting document style 'Info'.
VERBOSE: [ 15:04:10:238 ] [ Document ] - Setting document style 'OK'.
VERBOSE: [ 15:04:10:264 ] [ Document ] - Setting table style 'TableDefault'.
VERBOSE: [ 15:04:10:281 ] [ Document ] - Setting table style 'Borderless'.
VERBOSE: [ 15:04:10:285 ] [ Document ] - Processing document header started.
VERBOSE: [ 15:04:10:288 ] [ Document ] - Processing paragraph 'Veeam VBR As Built Report - v1.0'.
VERBOSE: [ 15:04:10:295 ] [ Document ] - Processing document header completed.
VERBOSE: [ 15:04:10:298 ] [ Document ] - Processing document footer started.
VERBOSE: [ 15:04:10:302 ] [ Document ] - Processing paragraph 'Page <!# PageNumber #!>'.
VERBOSE: [ 15:04:10:318 ] [ Document ] - Processing document footer completed.
VERBOSE: [ 15:04:10:320 ] [ Document ] - Processing blank line.
VERBOSE: [ 15:04:10:343 ] [ Document ] - Processing image 'Veeam Logo'.
VERBOSE: [ 15:04:10:394 ] [ Document ] - Processing blank line.
VERBOSE: [ 15:04:10:396 ] [ Document ] - Processing paragraph 'Veeam VBR As Built Report'.
VERBOSE: [ 15:04:10:400 ] [ Document ] - Processing blank line.
VERBOSE: [ 15:04:10:419 ] [ Document ] - Processing paragraph 'Zen Pr Solutions'.
VERBOSE: [ 15:04:10:421 ] [ Document ] - Processing blank line.
VERBOSE: [ 15:04:10:423 ] [ Document ] - Processing table 'Cover Page'.
VERBOSE: [ 15:04:10:449 ] [ Document ] - Processing page break.
VERBOSE: [ 15:04:10:453 ] [ Document ] - Processing table of contents 'Table of Contents'.
VERBOSE: [ 15:04:10:465 ] [ Document ] - Processing page break.
VERBOSE: [ 15:04:10:742 ] [ Document ] - Trying to import Veeam B&R modules.
VERBOSE: [ 15:04:10:993 ] [ Document ] - Identifying Veeam Powershell module version.
VERBOSE: [ 15:04:10:995 ] [ Document ] - Using Veeam Powershell module version 11.
VERBOSE: [ 15:04:11:231 ] [ Document ] - Establishing the initial connection to the Backup Server: veeam-vbr.pharmax.local.
VERBOSE: [ 15:04:11:233 ] [ Document ] - Looking for veeam existing server connection.
VERBOSE: [ 15:04:11:335 ] [ Document ] - Existing veeam server connection found
VERBOSE: [ 15:04:11:337 ] [ Document ] - Validating connection to veeam-vbr.pharmax.local
VERBOSE: [ 15:04:11:460 ] [ Document ] - Successfully connected to veeam-vbr.pharmax.local VBR Server.
VERBOSE: [ 15:04:11:462 ] [ Document ] - Processing section 'Implementation Report' started.
VERBOSE: [ 15:04:11:464 ] [ Document ] - Processing paragraph 'The following section provides a sum[..]'.
VERBOSE: [ 15:04:11:471 ] [ Document ] - Processing blank line.
VERBOSE: [ 15:04:11:486 ] [ Document ] - Backup Infrastructure InfoLevel set at 2.
VERBOSE: [ 15:04:11:488 ] [ Document ] - Processing section 'Backup Infrastructure Summary' started.
VERBOSE: [ 15:04:11:508 ] [ Document ] - Discovering Veeam VBR Infrastructure Summary from veeam-vbr.pharmax.local.
Output Truncated!
VERBOSE: [ 15:06:02:777 ] [ Document ] - Discovered Pharmax - Veeam Tape Vault Type Vault.
VERBOSE: [ 15:06:02:979 ] [ Document ] - Processing table 'Tape Vault - VEEAM-VBR'.
VERBOSE: [ 15:06:02:986 ] [ Document ] - Processing section 'Tape Vault Summary' completed.
VERBOSE: [ 15:06:02:989 ] [ Document ] - Processing section 'Tape Infrastructure Summary' completed.
VERBOSE: [ 15:06:02:991 ] [ Document ] - Processing section 'Implementation Report' completed.
VERBOSE: [ 15:06:03:130 ] [ Document ] - Document 'Veeam VBR As Built Report' processing completed.
VERBOSE: [ 15:06:03:141 ] [ Document ] - Total processing time '1.89' minutes.
Veeam VBR As Built Report 'Veeam VBR As Built Report' has been saved to 'C:\Users\jocolon\AsBuiltReport\'.
PS C:\Users\jocolon> 

Here is an example of the resulting report.

I also include several options on how to build the report.

# Generate a Veeam VBR As Built Report for Backup Server '192.168.7.60' 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 Veeam.VBR -Target 192.168.7.60 -Username 'Domain\veeam_admin' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -Timestamp

# Generate a Veeam VBR As Built Report for Backup Server 192.168.7.60 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 Veeam.VBR -Target 192.168.7.60 -Username 'Domain\veeam_admin' -Password 'P@ssw0rd' -Format Text,Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -ReportConfigFilePath 'C:\Users\Jon\AsBuiltReport\AsBuiltReport.Veeam.VBR.json' -Verbose

# Generate a Veeam VBR As Built Report for Backup Server 192.168.7.60 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 Veeam.VBR -Target 192.168.7.60 -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents' -EnableHealthCheck

# Generate a Veeam VBR As Built Report for Backup Server 192.168.7.60 using stored 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 Veeam.VBR -Target 192.168.7.60 -Username 'Domain\veeam_admin' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -SendEmail

Hasta Luego Amigos!

PowerShell – VMware PowerCLI get Datastore Information

Hello,

In this post I will show you how to get the datastore list in a vSphere infrastructure using PowerCLI. Now, first of all we have to establish connection to our vCenter/ESXi to get this information. We can do this using the “Connect-VIServer” command.

PS C:\Users\jocolon> Connect-VIServer -Server 192.168.5.2

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

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


PS C:\Users\jocolon> 

After the connection is established you can use the “Get-Datastore” command.

PS C:\Users\jocolon> Get-Datastore 


Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
SSD-VM-HIGH-CAPACITY-PERF-KN           399.387         894.000
NVME-VFLASH-01                          50.054         238.250
SSD-VM-HIGH-CAPACITY-PERF-MK           505.415         931.250
NVME-VM-HIGH-PERF-01                   275.067         476.750
HDD-VM-MED-PERF-01                   2,165.800       3,726.000
HDD-VM-MED-PERF-02                   2,230.938       3,726.000
esx-00f                                110.801         111.750
SRM_LAB_STORAGE_01                      46.285          49.750
SRM_POL_DEDUP_01                        18.694          50.000
SRM_LAB_STORAGE_02                      47.909          50.000
SRM_PLACEHOLDER_01                      13.345          14.750
SRM_HQ_EDGE_01                          47.659          49.750
HDD-VM-ISO-LOW-PERF                    461.363         931.250


PS C:\Users\jocolon>

This command shows the existing Datastore and the basic information about the used space. With this command we can also filter the search allowing to obtain additional Datastore information. if we add the Datastore name to the “Get-Datastore” command with the “-Name” option. For example if we use the command “Get-Datastore -Name <DatastoreName> | Format-List” the following result is shown.

PS C:\Users\jocolon> Get-Datastore -Name NVME-VFLASH-01 | Format-List  



FileSystemVersion              : 6.82
DatacenterId                   : Datacenter-datacenter-21
Datacenter                     : PHARMAX-VSI-DC
ParentFolderId                 : StoragePod-group-p1396
ParentFolder                   :
DatastoreBrowserPath           : vmstores:\192.168.5.2@443\PHARMAX-VSI-DC\NVME-VFLASH-01
FreeSpaceMB                    : 51255
CapacityMB                     : 243968
Accessible                     : True
Type                           : VMFS
StorageIOControlEnabled        : True
CongestionThresholdMillisecond : 10
State                          : Available
ExtensionData                  : VMware.Vim.Datastore
CapacityGB                     : 238.25
FreeSpaceGB                    : 50.0537109375
Name                           : NVME-VFLASH-01
Id                             : Datastore-datastore-268983
Uid                            : /VIServer=vsphere.local\administrator@192.168.5.2:443/Datastore=Datastore-datastore-268983/



PS C:\Users\jocolon>

Like most Powershell commands, the PowerCLI commands allow the use of “Pipeline”. If we use the “Get-VMHost” command to get the ESXi servers together with the “Get-Datastore” command you can further filter the content of the Datastore connected to the server.

PS C:\Users\jocolon> Get-VMHost -Name esxsvr-00f.pharmax.local | Get-Datastore


Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
esx-00f                                110.801         111.750
HDD-VM-ISO-LOW-PERF                    461.363         931.250
SSD-VM-HIGH-CAPACITY-PERF-MK           505.414         931.250
SSD-VM-HIGH-CAPACITY-PERF-KN           399.321         894.000
HDD-VM-MED-PERF-01                   2,165.800       3,726.000
HDD-VM-MED-PERF-02                   2,230.938       3,726.000
NVME-VM-HIGH-PERF-01                   275.065         476.750
NVME-VFLASH-01                          50.053         238.250


PS C:\Users\jocolon>

Finally, I would like to mention that there are endless possibilities in Powershell when it comes to interlinking cmdlets, allowing you to refine the search for data and even transform the information you want to display. I hope this information has been useful. Hasta luego!

HomeLab – vSphere documentation with vDocumentation

This time I will be showing a tool that I use regularly to quickly identify inventory information in a vsphere infrastructure. This tool is called “vDocumentation” and precisely uses PowerCLI to obtain the inventory information. The creator of this tool “Ariel Sanchez Mora” @arielsanchezmor defines vDocumentation as:

vDocumentation provides a community-created set of PowerCLI scripts that produce infrastructure documentation of vSphere environments in CSV or Excel file format.

Ariel Sánchez Mora Github page

However, to get started, the following requirements must be met:

  • Windows OS platform
  • PowerShell v5.1+ or v7
  • ImportExcel module >= 7+
  • VMware PowerCLI module >= 12.3+

To install this tool we only need to use the “Install-Module” command from a Powershell console.

Install-Module -Name VMware.PowerCLI
Install-Module -Name ImportExcel
Install-Module -Name vDocumentation

Once the modules are installed the installation can be verified using the “Get-Module” command.

PS C:\Users\Administrator> Get-Module -ListAvailable -Name @('VMware.PowerCLI','ImportExcel','vDocumentation')


ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     7.4.1                 ImportExcel                         Desk      {Add-Conditional...}
Script     2.4.7                 vDocumentation                      Desk      {Get-ESXStorage...}
Manifest   12.4.1.18…            VMware.PowerCLI                     Desk      

PS C:\Users\Administrator>

After validating the installation process, use the “Get-Command” command to identify the cmdlets that this tool brings to PowerShell.

PS C:\Users\Administrator> Get-Command -Module vDocumentation


CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-ESXInventory                                   2.4.7      vDocumentation
Function        Get-ESXIODevice                                    2.4.7      vDocumentation
Function        Get-ESXNetworking                                  2.4.7      vDocumentation
Function        Get-ESXPatching                                    2.4.7      vDocumentation
Function        Get-ESXSpeculativeExecution                        2.4.7      vDocumentation
Function        Get-ESXStorage                                     2.4.7      vDocumentation
Function        Get-VMSpeculativeExecution                         2.4.7      vDocumentation
Function        Get-vSANInfo                                       2.4.7      vDocumentation

PS C:\Users\Administrator>

Before using the modules it is required to first establish the connection to the vCenter server or ESXi. To achieve this task we use the command “Connect-VIServer”.

PS C:\Users\Administrator> Connect-VIServer -Server 192.168.5.2 -Username administrator@vsphere.local -Password XXXXXX


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

PS C:\Users\Administrator>

After the connection is established the modules can be used. In this example I will use the command “Get-ESXInventory” to get the inventory information of the ESXi servers connected to the vCenter.

PS C:\Users\Administrator> Get-ESXInventory
        Connected to 192.168.5.2
        Gathering host list...
        Gathering Hardware inventory from esxsvr-00f.pharmax.local ...
        Gathering configuration details from esxsvr-00f.pharmax.local ...
WARNING:  Check Connection State or Host name
WARNING:  Skipped hosts:


 ESXi Hardware Inventory:


Hostname           : esxsvr-00f.pharmax.local
Management IP      : {192.168.5.253, 10.0.0.74}
RAC IP             :
RAC MAC            :
RAC Firmware       :
Product            : VMware ESXi
Version            : 7.0.3 U3
Build              : 18825058
Make               : System manufacturer
Model              : System Product Name
S/N                : System Serial Number
BIOS               : 3802
BIOS Release Date  : 03/15/2018
CPU Model          : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
CPU Count          : 1
CPU Core Total     : 4
Speed (MHz)        : 3408
Memory (GB)        : 64
Memory Slots Count : -1
Memory Slots Used  : 0
Power Supplies     : 0
NIC Count          : 3




 ESXi Host Configuration:


Hostname                  : esxsvr-00f.pharmax.local
Make                      : System manufacturer
Model                     : System Product Name
CPU Model                 : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Hyper-Threading           : True
Max EVC Mode              : intel-broadwell
Product                   : VMware ESXi
Version                   : 7.0.3 U3
Build                     : 18825058
Install Type              : Installable
Boot From                 : /vmfs/volumes/755b8362-294638aa-a59f-74ccb58569b3
Device Model              : ATA SAMSUNG MZHPV128
Boot Device               : Local ATA Disk (t10.ATA_____SAMSUNG_MZHPV128HDGM2D00000______________S1X3NYAH200184______)
Runtime Name              : vmhba3:C0:T0:L0
Device Path               : /vmfs/devices/disks/t10.ATA_____SAMSUNG_MZHPV128HDGM2D00000______________S1X3NYAH200184______
Image Profile             : (Updated) ESXi-7.0U3a-18825058-standard
Acceptance Level          : CommunitySupported
Boot Time                 : 12/16/2021 6:40:22 AM
Uptime                    : 0 Day(s), 16 Hour(s), 3 Minute(s)
Install Date              : 5/22/2020 9:36:56 AM
Last Patched              : 2021-10-29
License Version           : vSphere 7 Enterprise Plus with Add-on for Kubernetes
License Key               : 4Y28A-FV213-488Q8-202E6-1P024
Connection State          : Connected
Standalone                : False
Cluster                   : RegionHQ-MGMT
Virtual Datacenter        : PHARMAX-VSI-DC
vCenter                   : 192.168.5.2
NTP                       : NTP Daemon
NTP Running               : True
NTP Startup Policy        : on
NTP Client Enabled        : True
NTP Server                : 192.168.5.1,0.north-america.pool.ntp.org
SSH                       : SSH
SSH Running               : True
SSH Startup Policy        : on
SSH TimeOut               : 0
SSH Server Enabled        : True
ESXi Shell                : ESXi Shell
ESXi Shell Running        : False
ESXi Shell Startup Policy : off
ESXi Shell TimeOut        : 0
Syslog Server             : :
Syslog Client Enabled     : False



PS C:\Users\Administrator>

The next example I will show you is about the “Get-ESXStorage” command. This command allows you to get storage device information connected to the ESXi server.

PS C:\Users\Administrator> Get-ESXStorage
        Connected to 192.168.5.2
        Gathering host list...
        Gathering storage adapter details from esxsvr-00f.pharmax.local ...
        Gathering Datastore details from esxsvr-00f.pharmax.local ...
WARNING:  Check Connection State or Host name
WARNING:  Skipped hosts:

 ESXi Datastores:


Hostname               : esxsvr-00f.pharmax.local
Datastore Name         : esx-00f
Device Name            : Local ATA Disk
Canonical Name         : t10.ATA_____SAMSUNG_MZHPV128HDGM2D00000______________S1X3NYAH200184______
LUN                    : 0
Type                   : VMFS
Datastore Cluster      :
Capacity (GB)          : 111.75
Provisioned Space (GB) : 0.95
Free Space (GB)        : 110.80
Transport              : Block
Mount Point            : /vmfs/volumes/598a435f-a2e283e6-6159-9c5c8ed12a16/
Multipath Policy       :
File System Version    : 5.81

Hostname               : esxsvr-00f.pharmax.local
Datastore Name         : HDD-VM-ISO-LOW-PERF
Device Name            : Local ATA Disk
Canonical Name         : t10.ATA_____WDC_WD10EZEX2D00WN4A0_________________________WD2DWCC6Y2KP8070
LUN                    : 0
Type                   : VMFS
Datastore Cluster      :
Capacity (GB)          : 931.25
Provisioned Space (GB) : 469.89
Free Space (GB)        : 461.36
Transport              : Block
Mount Point            : /vmfs/volumes/598f33a5-24870100-5609-9c5c8ed12a16/
Multipath Policy       :
File System Version    : 6.81

PS C:\Users\Administrator>

The last example I will show you is the “Get-ESXNetworking” command used to retrieve the information of the existing physical and virtual network ports on the server.

PS C:\Users\Administrator> Get-ESXNetworking
        Connected to 192.168.5.2
        Gathering host list...
        Gathering physical adapter details from esxsvr-00f.pharmax.local ...
        Gathering VMkernel adapter details from esxsvr-00f.pharmax.local ...
        Gathering virtual vSwitches details from esxsvr-00f.pharmax.local ...
WARNING:  Check Connection State or Host name
WARNING:  Skipped hosts:


 ESXi Physical Adapters:


Hostname           : esxsvr-00f.pharmax.local
Name               : vmnic1
Slot Description   : PCIEX16_3
Device             : Emulex Corporation HP NC552SFP Dual Port 10GbE Server Adapter
Duplex             : Full
Link               : Up
MAC                : 10:60:4b:93:20:68
MTU                : 9000
Speed              : 10000
vSwitch            : PHARMAX-DVS
vSwitch MTU        : 9000
Discovery Protocol : CDP
Device ID          : MikroTik
Device IP          : 0.0.0.0
Port               : bonding1/sfp-sfpplus1





 ESXi VMkernel Adapters:


Hostname         : esxsvr-00f.pharmax.local
Name             : vmk1
MAC              : 00:50:56:6e:c1:24
MTU              : 9000
IP               : 192.168.5.253
Subnet Mask      : 255.255.255.0
TCP/IP Stack     : defaultTcpipStack
Default Gateway  : 192.168.5.254
DNS              : 192.168.5.1,192.168.1.1
PortGroup Name   : DVS-ESXi-MANAGEMENT
VLAN ID          :
Enabled Services : Management
vSwitch          : PHARMAX-DVS
vSwitch MTU      : 9000
Active adapters  :
Standby adapters :
Unused adapters  :

Hostname         : esxsvr-00f.pharmax.local
Name             : vmk0
MAC              : 00:50:56:6f:e2:03
MTU              : 1500
IP               : 10.0.0.74
Subnet Mask      : 255.255.255.0
TCP/IP Stack     : defaultTcpipStack
Default Gateway  : 192.168.5.254
DNS              : 192.168.5.1,192.168.1.1
PortGroup Name   : Management Network
VLAN ID          : 0
Enabled Services : Management
vSwitch          : vSwitch0
vSwitch MTU      : 1500
Active adapters  : vmnic0
Standby adapters :
Unused adapters  :


 ESXi Virtual Switches:


Hostname                                        : esxsvr-00f.pharmax.local
Type                                            : Standard
Version                                         :
Name                                            : Pharmax-VL
Uplink/ConnectedAdapters                        :
PortGroup                                       : Pharmax-VL DVS-Esxi-VM-Network
VLAN ID                                         : 7
Active adapters                                 :
Standby adapters                                :
Unused adapters                                 :
Security Promiscuous/MacChanges/ForgedTransmits : Reject/Reject/Reject

Hostname                                        : esxsvr-00f.pharmax.local
Type                                            : Standard
Version                                         :
Name                                            : Virtual Lab - Cert
Uplink/ConnectedAdapters                        :
PortGroup                                       : Virtual Lab - Cert DVS-ESXi-MANAGEMENT-EPH
VLAN ID                                         : 5
Active adapters                                 :
Standby adapters                                :
Unused adapters                                 :
Security Promiscuous/MacChanges/ForgedTransmits : Accept/Accept/Accept

Hostname                                        : esxsvr-00f.pharmax.local
Type                                            : Standard
Version                                         :
Name                                            : Virtual Lab - Cert
Uplink/ConnectedAdapters                        :
PortGroup                                       : Virtual Lab - Cert DVS-Esxi-VM-Network
VLAN ID                                         : 7
Active adapters                                 :
Standby adapters                                :
Unused adapters                                 :
Security Promiscuous/MacChanges/ForgedTransmits : Accept/Accept/Accept


PS C:\Users\Administrator>

I hope you have found this reporting tool useful. See you later!

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 – Active Directory Documentation using AsBuiltReport

Hello to all!

Earlier I wrote about the NetApp.Ontap report that I helped develop through the AsBuildReport project created by “Tim Carman” @tpcarman (Here the link). Well this time I will be talking about another report that I have been working on during these last months related to building documentation about the “Active Directory” (AD) infrastructure. For many years I have done several implementations and/or consultancies related to this service and I have always had the intention of creating a condensed report on how this service infrastructure was designed, which for statistical purposes runs in more than 95% of the world’s companies.

Although I have to admit that there are a number of experts who have created several similar reports, a unique feature of this report is that it uses AsBuildReport as the basis for generating the programming necessary to set up the report structure. So I as a programmer can concentrate on the technology I want to document and not on adding code to generate the formatting in Word or HTML.

This 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.

This report can only be run on Windows 10+ or Windows Server 2012+. Additionally PowerShell version 5.1 or PowerShell 7+ is required and the following modules are also required in order to generate the report:

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

PS C:\Users\jocolon> $PSVersionTable

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


PS C:\Users\jocolon>

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

PS C:\Users\jocolon> Get-Module -ListAvailable -Name @('ActiveDirectory','GroupPolicy','PSPKI')

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.7.2      PSPKI                               {Set-CertificateExtension, Get-CertificationAuthorityDbSch...

    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0.1.0    ActiveDirectory                     {Add-ADCentralAccessPolicyMember...
Manifest   1.0.0.0    GroupPolicy                         {Backup-GPO, Block-GPInheritance...

PS C:\Users\jocolon>

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

Installation of the PSPKI module:
PS C:\WINDOWS\system32> Install-Module -Name PSPKI                                                                                                                                                                                                                                                                                Installing package 'PSPKI'                                                                                                                                                                                                                                                        Copying unzipped package to 'C:\Users\jocolon\AppData\Local\Temp\2052046370\PSPKI'                                                                                                                                                                                             [oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo]    
PS C:\WINDOWS\system32>                                                                                                                                                                                                                                                                                 

To install the “ActiveDirectory” and “GroupPolicy” modules use the command “Add-WindowsCapability” for Windows 10 or the command “Install-WindowsFeature” for Windows Server 2012+.

Installation of ActiveDirectory and GroupPolicy module:
PS C:\WINDOWS\system32> Add-WindowsCapability -online -Name 'Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0'                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Path          :
Online        : True
RestartNeeded : False

PS C:\WINDOWS\system32> Add-WindowsCapability -online -Name 'Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0'

Path          :
Online        : True
RestartNeeded : False

PS C:\WINDOWS\system32>

Once we have installed the prerequisites we can proceed with the installation of the main module “AsBuiltReport.Microsoft.AD”.

PS C:\WINDOWS\system32> Install-Module -Name AsBuiltReport.Microsoft.AD

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"): Y

    Directory: C:\Program Files\WindowsPowerShell\Modules

PS C:\WINDOWS\system32>

To validate if the module was properly installed you can use the “Get-Module” command.

PS C:\WINDOWS\system32> Get-Module -ListAvailable -Name AsBuiltReport.Microsoft.AD


    Directory: C:\Users\jocolon\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.4.0      AsBuiltReport.Microsoft.AD          Invoke-AsBuiltReport.Microsoft.AD


PS C:\WINDOWS\system32>

Note: As you can see, the module “0.4.0” version was installed.

An optional requirement is to build a configuration file that allows you to set the organization’s parameters that are used to generate the report. This process will generate a JSON file that 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.

Configuration files (AsBuiltReport JSON)

The powershell cmdlet New-AsBuiltConfig allows you to generate the template that we will use 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 ONTAP 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 level and type of information collected “verbose level”.

PS C:\WINDOWS\system32> New-AsBuiltReportConfig Microsoft.AD -FolderPath C:\Users\jocolon\AsBuiltReport\

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

{
    "Report": {
        "Name": "Microsoft AD As Built Report",
        "Version": "1.0",
        "Status": "Released",
        "ShowCoverPageImage": true,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {

    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
        "Forest": 1,
        "Domain": 1,
        "DHCP": 1,
        "DNS": 1,
        "CA": 0,
        "Security": 0
    },
    "HealthCheck": {
        "Domain": {
            "GMSA": true,
            "GPO": true
        },
        "DomainController": {
            "Diagnostic": true,
            "Services": true
        },
        "Site": {
            "Replication": true
        },
        "DNS": {
            "Aging": true
        },
        "DHCP": {
            "Summary": true,
            "Credential": true,
            "Statistics": true,
            "BP": true
        }
    }
}

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

Then we can generate the report using the command “New-AsBuiltReport -Report Microsoft.AD -Target DC_FQDN”. It is important to emphasize that it is required that the computer where the report is generated is added to the AD domain to be documented. It is also required to use the “fully qualified domain name “(FQDN) of the server with the “Domain Controller” role within the AD “Forest”.

PS C:\Users\jocolon>  New-AsBuiltReport -Report Microsoft.AD -Target server-dc-01v.zenpr.local -Format HTML -AsBuiltConfigFilePath C:\Users\jocolon\AsBuiltReport\AsBuiltReport.json -OutputFolderPath C:\Users\jocolon\AsBuiltReport\ -ReportConfigFilePath '.\AsBuiltReport\AsBuiltReport.Microsoft.AD.json' -Credential $cred -EnableHealthCheck               

Please wait while the Microsoft AD As Built Report is being generated.
WARNING: [ 20:03:36:175 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Group Managed Service Accounts Information - ZENPR.LOCAL'.
WARNING: [ 20:03:52:062 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'AD Domain Controller Hardware Information - ZENPR.LOCAL'.
WARNING: [ 20:04:12:144 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Site Replication Information - ZENPR.LOCAL'.
WARNING: [ 20:04:12:412 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Site Replication Failure Information - ZENPR.LOCAL'.
WARNING: [ 20:05:53:997 ] [ Document ] - Error: Collecting Active Directory Group Policy Objects with Startup/Shutdown Script for domain ACAD.ZENPR.LOCAL.
WARNING: [ 20:06:21:709 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:21:853 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'IPv4 Scope Failover Cofiguration Information - SERVER-DC-01V'.
WARNING: [ 20:06:22:399 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:22:440 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:22:525 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:22:555 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:22:589 ] [ Document ] - Cannot bind argument to parameter 'Rows' because it is an empty collection.
WARNING: [ 20:06:22:897 ] [ Document ] - Error: Retreiving DHCP Server IPv4 Scope Failover Setting from ACADE-DC-01V.
Microsoft AD As Built Report 'Microsoft AD As Built Report' has been saved to 'C:\Users\jocolon\AsBuiltReport\'.
PS C:\Users\jocolon>

Here is an example of the resulting Active Directory documentation.

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

# Generate a Microsoft Active Directory As Built Report for Domain Controller Server 'admin-dc-01v.contoso.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 Microsoft.AD -Target 'admin-dc-01v.contoso.local' -Username 'administrator@contoso.local' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -Timestamp

# Generate a Microsoft Active Directory As Built Report for Domain Controller Server 'admin-dc-01v.contoso.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 Microsoft.AD -Target 'admin-dc-01v.contoso.local' -Username 'administrator@contoso.local' -Password 'P@ssw0rd' -Format Text,Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -ReportConfigFilePath 'C:\Users\Jon\AsBuiltReport\AsBuiltReport.Microsoft.AD.json' -Verbose

# Generate a Microsoft Active Directory As Built Report for Domain Controller Server 'admin-dc-01v.contoso.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 Microsoft.AD -Target 'admin-dc-01v.contoso.local' -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents' -EnableHealthCheck

# Generate a Microsoft Active Directory As Built Report for Domain Controller Server 'admin-dc-01v.contoso.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 Microsoft.AD -Target 'admin-dc-01v.contoso.local' -Username 'administrator@contoso.local' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -SendEmail

See you later folks!

HomeLab – Automated NetApp Ontap Documentation with AsBuiltReport

Hello everyone!

This time I come to talk about a project that I have been working on for a few months. If you remember some time ago I wrote about the AsBuildReport tool specifically the module to document VMware vSphere based infrastructures see the post here. Well today I come to show you a module that I help to develop with the purpose of documenting NetApp storage devices specifically on the ONTAP operating system.

This report is in an initial state and in active development, but I decided to release it publicly in order 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:

I should make it clear that this report is not designed to replace or compete in any way with the NetAppDocs tool. I noticed many requests on the NetApp forum from various users who have the need to generate an updated report of their storage infrastructure. It is for this reason that I took the initiative to create a report available free of charge for NetApp customers and/or users. One advantage of using the AsBuiltReport project, is that it allows you to create the report in multiple formats (Word, HTML or Text) and it is also possible to automate the sending of the report via email.

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

  • Multi-platform Windows, Linux o MAC
  • PowerShell v5.1+ ó v7
  • “NetApp PowerShell Toolkit” >= 9.9.1.2106 powershell module
  • AsBuiltReport.Core >= 1.1.0 powershell module

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

PS /home/rebelinux> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Linux 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +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>

The report was created specifically for the version of “NetApp PowerShell Toolkit” >= 9.9.1.2106. To validate what version you have or if it has been installed you can use the Get-Module command as shown in the following example:

Note: Additionally I validate the version of “AsBuiltReport.Core” which is an additional dependency to be able to generate the report.

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

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

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.0                 AsBuiltReport.Core                  Desk      {New-AsBuiltReport, New-AsBuiltConfig}
Manifest   9.9.1.2106            NetApp.ONTAP                        Desk      Add-NaHelpInfoUri

PS /home/rebelinux>

If no result is produced it means that none of the modules are installed. The Install-Module command is used to install these dependencies:

PS /home/rebelinux> Install-Module -Name @('AsBuiltReport.Core','Netapp.Ontap')
Installing 2 modules.
Installing Module 'NetApp.ONTAP' (2 of 2).
[ooooooooooooooooooooooooooooooooooooooooooooooooooo]
Installing package 'NetApp.ONTAP'
Downloaded 1.47 MB out of 14.60 MB.
[oooooooooo                                         ]
PS /home/rebelinux>

Then proceed to install the ONTAP report using the following command:

PS /home/rebelinux> Install-Module -Name AsBuiltReport.NetApp.ONTAP
Installing 1 modules.
Installing Module 'AsBuiltReport.NetApp.ONTAP' (1 of 1).
[ooooooooooooooooooooooooooooooooooooooooooooooooooo]
Installing package 'AsBuiltReport.NetApp.ONTAP'
Downloaded 0.2 MB out of 0.88 MB.
[oooooooooo                                         ]
PS /home/rebelinux>

To validate if the installation was successful we can use the Get-Module command.

PS /home/rebelinux> Get-Module -ListAvailable "AsBuiltReport.NetApp.ONTAP" 


    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     0.4.0                 AsBuiltReport.NetApp.ONTAP          Desk      Invoke-AsBuiltReport.NetApp.ONTAP

PS /home/rebelinux>

Note: As you can see, the module 0.4.0 version was installed.

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

Configuration files (AsBuiltReport JSON)

The powershell cmdlet New-AsBuiltConfig allows you to build the 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 ONTAP 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.

PS C:\WINDOWS\system32> New-AsBuiltReportConfig NetApp.ONTAP -FolderPath C:\Users\jocolon\AsBuiltReport\

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

{
    "Report": {
        "Name": "NetApp ONTAP As Built Report",
        "Version": "0.3.0",
        "Status": "Released",
        "ShowCoverPageImage": false,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {

    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Enabled",
        "Cluster": 1,
        "Node": 1,
        "Storage": 1,
        "License": 1,
        "Network": 1,
        "Vserver": 1,
        "Replication": 1,
        "Efficiency": 1,
        "Security": 1,
        "System": 1
    },
    "HealthCheck": {
        "Cluster": {
            "Summary": true,
            "HA": true,
            "AutoSupport": true
        },
        "Node": {
            "HW": true,
            "ServiceProcessor": true
        },
        "Storage": {
            "Aggr": true,
            "DiskStatus": true,
            "ShelfStatus": true,
            "Efficiency": true,
            "FabricPool": true
        },
        "Network": {
            "Port": true,
            "Interface": true
        },
        "License": {
            "RiskSummary": true,
            "ServiceProcessor": true
        },
        "Vserver": {
            "Status": true,
            "Iscsi": true,
            "FCP": true,
            "NFS": true,
            "Quota": true,
            "CIFS": true,
            "Snapshot": true
        },
        "Replication": {
            "Status": true,
            "ClusterPeer": true,
            "VserverPeer": true,
            "Relationship": true,
            "History": true,
            "Mediator": true
        },
        "System": {
            "NTP": true,
            "DNS": true,
            "EMS": true,
            "Backup": true
        },
        "Security": {
            "Users": true,
            "KMS": true
    }
    }
}

Then we can build the report using the command “New-AsBuiltReport -Report NetApp.ONTAP -Target IP/FQDN”.

PS /home/rebelinux> New-AsBuiltReport -Report NetApp.ONTAP -AsBuiltConfigFilePath /home/rebelinux/script/AsBuiltReport.json -OutputFolderPath /home/rebelinux/script -Target 192.168.7.60 -Format HTML  -EnableHealthCheck -Credential $cred -ReportConfigFilePath /home/rebelinux/script/AsBuiltReport.NetApp.ONTAP.json               

WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: [ 13:17:34:209 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver Lun Information - PHARMAX-HQ'.
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: [ 13:17:36:487 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver Igroup Information - PHARMAX-HQ'.
WARNING: Encountered Error No 81 on volume NTAPSOL_LUN_1. Reason: Volume is offline
WARNING: [ 13:17:37:516 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver NFS Service Options Summary - PHARMAX-HQ'.
WARNING: [ 13:17:49:537 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver CIFS Service Information - PHARMAX-HQ'.
WARNING: [ 13:17:50:264 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver CIFS Service Security Information - PHARMAX-HQ'.
WARNING: [ 13:17:51:834 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Vserver CIFS Service Options Summary - PHARMAX-HQ'.
WARNING: [ 13:17:55:913 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Replication - SnapMirror relationship Information - PHARMAX-HQ'.
WARNING: [ 13:17:56:662 ] [ Document ] - List table captions are only supported on tables with a single row. Removing caption from table 'Replication - SnapMirror Destination (List-Destinations) Information - PHARMAX-HQ'.
NetApp ONTAP As Built Report 'NetApp ONTAP As Built Report' has been saved to '/home/rebelinux/script'.
PS /home/rebelinux> 

Here is an example of the resulting report.

Additionally I include several command line examples of how to generate the report. I hope you like it!

# Generate a NetApp ONTAP As Built Report for Cluster array '192.168.7.60' 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 NetApp.ONTAP -Target 192.168.7.60 -Username 'admin' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -Timestamp

# Generate a NetApp ONTAP As Built Report for Cluster array 192.168.7.60 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 NetApp.ONTAP -Target 192.168.7.60 -Username 'admin' -Password 'P@ssw0rd' -Format Text,Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -ReportConfigFilePath 'C:\Users\Jon\AsBuiltReport\AsBuiltReport.NetApp.ONTAP.json' -Verbose

# Generate a NetApp ONTAP As Built Report for Cluster array 192.168.7.60 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 NetApp.ONTAP -Target 192.168.7.60 -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents' -EnableHealthCheck

# Generate a NetApp ONTAP As Built Report for Cluster array 192.168.7.60 using stored 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 NetApp.ONTAP -Target 192.168.7.60 -Username 'admin' -Password 'P@ssw0rd' -Format Html,Word -OutputFolderPath 'C:\Users\Jon\Documents' -SendEmail

See you later Friends!

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!!!!

Veeam – Powershell get Backup Repository Information

Hello everyone,

These last days I have been performing several support services related to Veeam Backup & Replication where I have had the opportunity to use more Veeam Powershell modules. So in this opportunity I will be showing you in a basic way how to get information related to the repositories connected to the Backup server. As always it is necessary to establish a connection to the Backup server using the “Connect-VBRServer” command.

PS C:\Users\jocolon> Connect-VBRServer -Server veeam-vbr.pharmax.local -Credential (Get-Credential)

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
User: pharmax\administrator
Password for user pharmax\administrator: ********

PS C:\Users\jocolon> 

After connecting to the server you can use the “Get-VBRBackupRepository” command to identify the repositories connected to the Backup server.

PS C:\Users\jocolon> Get-VBRBackupRepository                                           

Name                      Type         Host            FriendlyPath    Description
----                      ----         ----            ------------    -----------
VEEAM-DD                  DDBoost      VEEAM-VBR.ph... ddboost://VE... Created by PHARMAX\administrator
ONTAP Snapshot            SanSnapsh... VEEAM-VBR.ph... ONTAP Storage   Primary storage snapshot only
VEEAM-HPE-StoreOnce-VSA   HPStoreOn... VEEAM-VBR.ph... storeonce://... Created by PHARMAX\administrator
Linux - Hardened Repos... LinuxLocal   veeam-lnx-px... /backup_data... Created by PHARMAX\jocolon

PS C:\Users\jocolon>

As you can see the result of the cmdlet seems a bit incomplete as it does not show some important information such as the used space. In order to obtain this information I provide you with a basic example that allows you to obtain more relevant information.

$OutObj = @()
if ((Get-VBRServerSession).Server) {
    try {
        [Array]$BackupRepos = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"}
        [Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
        if ($ScaleOuts) {
            foreach ($ScaleOut in $ScaleOuts) {
                $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
                foreach ($Extent in $Extents) {
                    $BackupRepos = $BackupRepos + $Extent.repository
                }
            }
        }
        foreach ($BackupRepo in $BackupRepos) {
            $PercentFree = 0
            if (@($($BackupRepo.GetContainer().CachedTotalSpace.InGigabytes),$($BackupRepo.GetContainer().CachedFreeSpace.InGigabytes)) -ne 0) {
                $UsedSpace = ($($BackupRepo.GetContainer().CachedTotalSpace.InGigabytes-$($BackupRepo.GetContainer().CachedFreeSpace.InGigabytes)))
                if ($UsedSpace -ne 0) {
                    $PercentFree = ($UsedSpace/$($BackupRepo.GetContainer().CachedTotalSpace.InGigabytes)).tostring("P")
                }
            }
            $inObj = [ordered] @{
                'Name' = $BackupRepo.Name
                'Total Space' = "$($BackupRepo.GetContainer().CachedTotalSpace.InGigabytes)Gb"
                'Free Space' = "$($BackupRepo.GetContainer().CachedFreeSpace.InGigabytes)Gb"
                'Percent Used' = $PercentFree
                'Status' = Switch ($BackupRepo.IsUnavailable) {
                    'False' {'Available'}
                    'True' {'Unavailable'}
                    default {$BackupRepo.IsUnavailable}
                }
            }
            $OutObj += [pscustomobject]$inobj
        }
        $OutObj | Format-Table -Wrap -AutoSize
    }
    catch {
        Write-Output $_.Exception.Message
    }
}

In the following example I show you the output of the resulting code to get the information about the repositories connected to the Veeam Backup server.

Name                                  Total Space Free Space Percent Used Status     
----                                  ----------- ---------- ------------ ------
VEEAM-DD                              351Gb       292Gb      16.81%       Available
VEEAM-HPE-StoreOnce-VSA               0Gb         0Gb        0            Unavailable
Linux - Hardened Repository           199Gb       198Gb      0.50%        Available
E - Backup Repository                 499Gb       461Gb      7.62%        Available
F - Backup Repository                 99Gb        99Gb       0            Available
E - Backup Repository - VEEAM-VBR-02V 99Gb        5Gb        94.95%       Available
F - Backup Repository - VEEAM-VBR-02V 99Gb        98Gb       1.01%        Available

I hope you enjoyed this post and find it useful in your professional journey.

Hasta Luego Amigos!