PowerCLi: remove orphaned VM’s from vCenter inventory

For instructions on how to connect to VMware PowerCLI, Follow the post here:

Run the below to get the list of orphaned VM

$allVMs=Get-VM
foreach ($vm in $allVMs) {
 if ($vm.ExtensionData.Runtime.ConnectionState -eq "orphaned") {$vm.name}
}

Run the below to remove orphaned VM

foreach ($vm in $allVMs) {
 if ($vm.ExtensionData.Runtime.ConnectionState -eq "orphaned") {$vm | Remove-VM}
}

PowerCli- Script to reconfigure the default alarm email address on the vCenter server.

Using the GUI to set up email alerts for the default alarm might be time-consuming. In this post I will show you how to use VMware PowerCLi to automate re-configuring the existing, Default alarms with the notification email address.

You will need VMware PowerCLi to run through this. if you dont have this installed already, follow the instructions found here.

Use The below script to change the enable Default email action to the email address specified in the $newEmail=” field

$newEmail = 'ntitta@ikigo.net'
foreach ($alarm in Get-AlarmDefinition){
    $action = Get-AlarmAction -AlarmDefinition $alarm
    $mail = $action | where {$_.ActionType -eq 'SendEmail'}
	New-AlarmAction -AlarmDefinition $alarm -Email -To $newEmail -Subject $mail.Subject -Confirm:$false
}

Add a user to VCSA

add user

adduser username
usermod -aG sudo username

allow user to ssh to the appliance

edit /etc/ssh/sshd_conf and add the user account here

change default shell to bash for ssh to work.

chsh -s /usr/local/bin/bash username  

Installing RealTek Nic on Esxi (Esxi white box)

Desktop hardware’s are normally include Realtek nic which do now work in a base install of Esxi. In this article, The below post will walk you through steps to get Realtek nic working

Determine the nic hardware by running the below command:

root@Ryzen:~] lspci -v | grep "Class 0200" -B 1
0000:03:00.0 Network controller Ethernet controller: Realtek Semiconductor Co., Ltd. Onboard Ethernet
         Class 0200: 10ec:8168
--
0000:07:00.0 Network controller Ethernet controller: QLogic Corporation QLogic NetXtreme II BCM5709 1000Base-T [vmnic2]
         Class 0200: 14e4:1639
--
0000:07:00.1 Network controller Ethernet controller: QLogic Corporation QLogic NetXtreme II BCM5709 1000Base-T [vmnic3]
         Class 0200: 14e4:1639
--
0000:08:00.0 Network controller Ethernet controller: QLogic Corporation QLogic NetXtreme II BCM5709 1000Base-T [vmnic0]
         Class 0200: 14e4:1639
--
0000:08:00.1 Network controller Ethernet controller: QLogic Corporation QLogic NetXtreme II BCM5709 1000Base-T [vmnic1]
         Class 0200: 14e4:1639

Run the below command to switch the acceptance level to community support (the VIB can only be installed in community support)

[root@Ryzen:~] esxcli software acceptance set --level=CommunitySupported
Host acceptance level changed to 'CommunitySupported'.

Allow http traffic from the shell by making changes to the firewall

[root@Ryzen:~] esxcli network firewall ruleset set -e true -r httpClient


Use the below command to download and install the VIB

[root@Ryzen:~] esxcli software vib install -d https://vibsdepot.v-front.de -n net55-r8168
Installation Result
   Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.
   Reboot Required: true
   VIBs Installed: Realtek_bootbank_net55-r8168_8.045a-napi
   VIBs Removed:
   VIBs Skipped:

Reboot the host and you should now have a working Realtek NIC!