WMware – netcat – testing connectivity

To check if a port is open on VM

nc -z 192.168.1.2 80
Connection to 192.168.1.72 80 port [tcp/http] succeeded! 

check if UDP port is open:

 nc -z -u 192.168.1.51 53
Connection to 192.168.1.51 53 port [udp/domain] succeeded! 

Send data between hosts:
Host 1 (192.168.1.222) set to listen mode:

nc -lp 1234

Host 2 send data to host 1

nc 192.168.1.222 1234
test 123

If the port (1234) is open the text (test 123) will be displayed in the console. This trick can be used a simple chat

The same can be used to send for example a log or a text file using this syntax:

nc 192.168.1.222 1234 < /var/log/vmkernel.log

this way content of that file will be displayed on Host 1 (if conditions specified above are met).

PowerShell – Out-Notepad function

There are many out-notepad functions out there but for some reason I found them either too long or too complicated so here is mine, short and sweet:

Function Out-Notepad {
 [CmdletBinding()]
    Param
      (  
        [Parameter(Mandatory=$true,
        ValueFromPipeline=$true,
        Position=0)]
        $StrText
       )
$fso=new-object -com scripting.filesystemobject
$filename=$fso.GetTempName()
$tempfile=Join-Path $env:temp $filename
$strText | Out-File $tempfile
notepad $tempfile
#tidy up
sleep 3
if (Test-Path $tempfile) {del $tempfile}
}

Microsoft DNS server – backup and restore AD integrated zone

1. Backup the existing zone to a zone file. Resulting file will always be placed in C:\Windows\system32\dns – this can’t be controlled:
dnscmd /zoneexport zone.local zone-backup-file.zone

2. To restore the zone, move the zone-backup-file.zone file back into C:\Windows\system32\dns then:
dnscmd /zoneadd zone.local /primary /file zone-backup-file.zone /load

And finally, convert it into an AD integrated zone:
dnscmd /zoneresettype zone.local /dsprimary

Powershell – Graphical Tools Cmdlets

Out-GridView gives a dynamic table view of results in a pipeline with sorting and filtering capabilities and when used with -PassThru can be used interactively within a pipeline to select objects to send back to the pipeline.

PS c:\>Get-ADComputer -Filter * | out-gridview -PassThru | select name,enabled
name enabled
---- -------
PC1 False
PC2 True
PC3 True

Show-Command gives a graphical view of a command including parameter sets, parameters, switches, etc…

Get-Help -ShowWindow works again to give a graphical view of PowerShell help content.