Skip to main content

Formatting Output of PowerCLI

Size value is too long when I grab snapshot size of a VM. It's something like the screenshots below.





中文版

It makes the column too wide when I try run some reports. There is a simple way to keep only 2 decimals.
$a=Get-Snapshot -VM XXXX

$a | select Description,VM,@{Name="SizeGB";Expression={"{0:N2}" -f $_.SizeGB}}

If you want keep no decimals just replace the "2" with "0".

Popular posts from this blog

Connect-NsxtServer shows "Unable to connect to the remote server"

When you run Connect-NsxtServer in the PowerCLI, it may show "Unable to connect to the remote server".  Because the error message is a little bit confusing with other login issues. It's not easy to troubleshoot. The actual reason is the NSX-T uses a self-signed certificate, and the PowerCLI cannot accept the certificate automatically. The fix is super easy. You need to set the PowerCLI to ignore the invalid certificate with the following command: Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction:Ignore -Confirm:$false

Setup Terraform and Ansible for Windows provisionon CentOS

Provisioning Windows machines with Terraform is easy. Configuring Windows machines with Ansible is also not complex. However, it's a little bit challenging to combine them. The following steps are some ideas about handling a Windows machine from provisioning to post configuration without modifying the winrm configuration on the guest operating system. Install required repos for yum. yum -y install https://repo.ius.io/ius-release-el7.rpm yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm yum -y install epel-release yum -y install yum-utils yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo Install  Terraform . sudo yum -y install terraform Install  Ansible . sudo yum -y install ansible Install  Kerberos . yum -y install gcc python-devel krb5-devel krb5-libs krb5-workstation

vSphere Web Client stuck on the loading screen

It’s been a while since my last post. I got an exciting issue a few days ago. I was trying to log in to a vCenter Server in Chrome. I can see the login screen and enter the credential. However, I was not able to get into the main page. vSphere Web Client was stuck on the “loading.” The reason is the Chrome version was 50. It’s incompatible with the vSphere Web Client version. Here are the vSphere Client requirements for your convenience.