Monday, November 26, 2018

How to get network statistics on a VM nic from SSH.


If you need to get the network statistics via SSH on a VM nic, run the commands below.

  1. 'esxcli network vm list' to get VM ID.
  2. 'esxcli network vm port list -w <VM ID>' to get port ID number.
  3. 'esxcli network port stats get -p <port ID number>' to get network statistics.
Output:
Packet statistics for port 50332931
   Packets received: 293182742829
   Packets sent: 90336672427
   Bytes received: 305397539251
   Bytes sent: 11805570153
   Broadcast packets received: 135893129
   Broadcast packets sent: 813717
   Multicast packets received: 386654045
   Multicast packets sent: 334554
   Unicast packets received: 292660195655
   Unicast packets sent: 90335524156
   Receive packets dropped: 0
   Transmit packets dropped: 0


Thursday, November 15, 2018

Get Active Directory User's password expiration date.


Most corporation that uses Microsoft's Active Directory has set some password policies for tighter security.  One of them is probably 'Password Expiration' to force users to change their passwords every x amount of days.  I was in a situation where I needed to find a user account password expiration and the first thing that come to my mind is to use Powershell.  Upon Googling on how to do it with Powershell, I found that it is very cumbersome to do it.  You run a get-aduser command and it will output the accountexpires attribute but its not in datetime format.  You'd have to convert it, which didn't work for me.  Then I find that you can use the basic net user command like below.

c:\net user <username> /domain

That's all.


Friday, November 9, 2018

How to reinventory/register a vm from the CLI.


To re-inventory/register a vm from the CLI, do the following from an ssh prompt.

  • vim-cmd vmsvc/getallvms | grep -i <VM Name>  to get the VM ID.
  • vim-cmd vmsvc/reload <VM ID>

Tested on ESX 5.0.x - 5.5.x

Thursday, November 8, 2018

Run a program as admin from command line.


Ever run into a situation where you need to run a program as admin and Windows is not allowing you because you're in a screenshare with someone and UAC is prompting you but not let you type in your administrator credentials?  Give the following a try!

  1. Open a command prompt.
  2. Type in the following command.  
    • runas /user:Administrator cmd
    • type in your Administrator password
  3. Another command prompt will open up but this time, its run under the Adminstrator account.
  4. Navigate to the executable file you want to run, if its not in the environment path and type in the name and hit enter.
  • Note:  for some reason, you can't open the control panel by running control.exe from this.  If anyone knows why, please let me know.