All posts by iiidefix

Get public IP using DNS

show public IP


dig txt +short
nslookup -type=txt


dig +short


dig +short

other usage

dig txt
nslookup -type=txt

returns txt record of DNS request to authoritative source address
edns0-client-subnet if available, showing original DNS request source address

dig txt @ +short
nslookup -type=txt

vSphere Clipboard Copy and Paste

To enable Copy and Paste option for a specific virtual machine:

Note: VMware Tools must be installed for the Copy and Paste option to work.

  1. Log in to a vCenter Server system using the vSphere Client and power off the virtual machine.
  2. Select the virtual machine and click the Summary tab.
  3. Click Edit Settings.
  4. Navigate to Options > Advanced > General and click Configuration Parameters.
  5. Click Add Row.
  6. Type these values in the Name and Value columns: FALSE FALSE


To configure CDP for a Standard vSwitch:

Log in as root to the Service Console (via SSH, remote console, or physical console if connecting to ESX) or to management vmkernel port (if connecting to ESXi).

Verify the current CDP setting for the desired virtual switch (vSwitch1, in this example):

# esxcfg-vswitch -b vSwitch1

You see an output similar to:


The output of listen indicates CDP is configured to read CDP information from the physical switch if available.
This is the default setting for ESX/ESXi 3.5, 4.x, and 5.x.

Set the CDP status for a given virtual switch. Possible values here are down, listen, advertise or both.

  • Listen mode – The ESXi/ESX host detects and displays information about the associated Cisco switch port, but information about the vSwitch is not available to the Cisco switch administrator.
  • Advertise mode – The ESXi/ESX host makes information about the vSwitch available to the Cisco switch administrator, but does not detect and displays information about the Cisco switch.
  • Both mode – The ESXi/ESX host detects and displays information about the associated Cisco switch and makes information about the vSwitch available to the Cisco switch administrator.
# esxcfg-vswitch -B both vSwitch1

Verify the new setting:

# esxcfg-vswitch -b vSwitch1

You see an output similar to:


Enable CDP with PowerShell

$esxcli = Get-EsxCli -VMHost $myhost

To configure CDP on a vNetwork Distributed Switches (vDS):

  1. Connect to vCenter Server using the vSphere Client.
  2. In the vCenter Server home page, click Networking.
  3. Right-click the vDS and click Edit Settings.
  4. Select Advanced under Properties.
  5. Using the checkbox and the dropdown, change the CDP settings.

bat messagebox / jscript embedded in bat

@if (@x)==(@y) @end /***** jscript comment ******
	@echo off

	cscript //E:JScript //nologo "%~f0" "%~nx0" %*
	exit /b 0
@if (@x)==(@y) @end ******  end comment *********/

Value	Button
0	OK
1	OK, Cancel
2	Abort, Ignore, Retry
3	Yes, No, Cancel
4	Yes, No
5	Retry, Cancel

Value	Icon
0	No Icon
16	Critical
32	Question
48	Exclamation
64	Information

var icon = 64;
var button = 0;
var title = "Sample Title";
var message = "Sample Message";
var timeout = 30;

var pressed_message = "button pressed";
var timeout_message = "timedout";

function runPopup(){
	var wshShell = WScript.CreateObject("WScript.Shell");
	var btn = wshShell.Popup(message, timeout, title, button + icon + 0x10000);

Value	Return Code
1	OK
2	Cancel
3	Abort
4	Retry
5	Ignore
6	Yes
7	No
-1	None, message box was dismissed automatically (timeout)
	switch(btn) {
		// button pressed.
		case 1:

		// Timed out.
		case -1:


vbs http download

Dim Hostname, fso, CurrentDirectory
Set wshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

CurrentDirectory = fso.GetAbsolutePathName(".")

Hostname = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

WScript.Echo "HOSTNAME: " & Hostname

HTTPDownload "" & Hostname & ".txt", CurrentDirectory

Sub HTTPDownload(myURL, myPath)
	' Standard housekeeping
	Dim i, objFile, objFSO, objHTTP, strFile
	Const ForReading = 1, ForWriting = 2, ForAppending = 8

	' Create a File System Object
	Set objFSO = CreateObject("Scripting.FileSystemObject")

	' Check if the specified target file or folder exists,
	' and build the fully qualified path of the target file
	If objFSO.FolderExists(myPath) Then
		strFile = objFSO.BuildPath(myPath, Mid(myURL, InStrRev(myURL, "/") + 1))
	ElseIf objFSO.FolderExists(Left(myPath, InStrRev(myPath, "\") - 1)) Then
		strFile = myPath
		WScript.Echo "ERROR: Target folder not found."
		Exit Sub
	End If

	' Create or open the target file
	Set objFile = objFSO.OpenTextFile(strFile, ForWriting, True)

	' Create an HTTP object
	Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

	' Download the specified URL
	objHTTP.Open "GET", myURL, False

	' Write the downloaded byte stream to the target file
	For i = 1 To LenB(objHTTP.ResponseBody)
		objFile.Write Chr(AscB(MidB(objHTTP.ResponseBody, i, 1)))

	' Close the target file
End Sub