In this blog I will be showing you how to install the PowerCLI tool specifically on the ArchLinux operating system. Archlinux is an advanced Linux distribution that is characterized by being simple and lightweight. Additionally it offers the user full control in managing and modifying everything related to the system.
Well, to install and use PowerCLI we have to install Powershell first. PowerShell is a cross-platform automation and configuration tool. PowerShell has a large number of commands oriented to system administration. But at the same time, PowerShell is a full-featured programming language that allows writing functional programs. There are many Powershell-based administration tools from different manufacturers such as:
- VMware PowerCLI
- Cisco UCS PowerTool
- NetApp PowerShell Toolkit
- DELL\EMC Unity-Powershell
- Amazon AWS Tools for PowerShell
As you can see Powershell is a tool highly used by infrastructure manufacturers and is offered as a method for automation or rapid deployment of software-based infrastructure. Powershell is my second preferred programming language with Python at the top of my list.
The first thing we have to do is to install Powershell and for this I will use the program “yay” which is a tool in Archlinux to install programs from the unofficial repository “Arch User Repository”. With the command <yay -S powershell-bin> we can install the Powershell program to the system. To see the installation procedure, just click on the “+” icon.
There is another more advanced installation method that also allows you to install Powershell from the command line. I leave here the required commands. To see the installation procedure, just click on the “+” icon.
To access the Powershell application the <pwsh> command is used to call the interpreter. From the interpreter we can run Powershell commands that are commonly called “Cmdlets”.
[rebelinux@blabla ~]$ pwsh PowerShell 7.1.3 Copyright (c) Microsoft Corporation. https://aka.ms/powershell Type 'help' to get help. PS /home/rebelinux>
The next step to run PowerCLI is to install its module by using the <Install-Module -name VMware.PowerCLI> command from the Powershell interpreter.
PS /home/blabla> Install-Module -name VMware.PowerCLI Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A PS /home/blabla>
To connect to the vCenter we use the “cmdlet” <Connect-VIServer> specifying the IP address or DNS name of the server.
PS /home/blabla> Connect-VIServer vcenter-01v.zenprsolutions.local -Verbose -Username email@example.com -Password XXXXXX Name Port User ---- ---- ---- vcenter-01v.zenprsolutions.local 443 VSPHERE.LOCAL\Administrator PS /home/blabla>
I will use a basic command to do connection testing against vCenter. In this test I will use the <Get-Cluster> command to check the currently created clusters.
PS /home/blabla> Get-Cluster Name HAEnabled HAFailover DrsEnabled DrsAutomationLevel Level ---- --------- ---------- ---------- ------------------ RegionA01-EDGE False 1 True FullyAutomated RegionHQ-MGMT False 1 True FullyAutomated RegionA01-COMP True 1 True FullyAutomated PS /home/blabla>
Another basic example is to use the <Get-Datastore> command to validate which datastores currently exist in the virtual DataCenter. In the output of the <Get-Datastore> command you can see the free and used space in the datastores configured in the DataCenter.
PS /home/blabla> Get-Datastore Name FreeSpaceGB CapacityGB ---- ----------- ---------- SSD-VM-HIGH-CAPACITY-PERF-KN 173.708 894.000 NVME-VM-HIGH-PERF-01 0.017 476.750 SSD-VM-HIGH-CAPACITY-PERF-MK 251.536 931.250 HDD-VM-MED-PERF-02 2,232.268 3,726.000 HDD-VM-MED-PERF-01 2,509.246 3,726.000 esx-00f 110.801 111.750 NVME-VFLASH-01 0.840 238.250 HDD-VM-ISO-LOW-PERF 606.936 931.250 NFS_SNAP_OFFLOAD 29.258 50.000 SRM_PlaceHolder 97.170 99.750 SERVER_DATASTORE 92.444 99.750 PS /home/blabla>