Output server IP details to text file

Reading Time: < 1 minute

The below script will allow you to output ip details for multiple servers on a network.

You will need powershell v2 installed and the PsExec executable

Copy & paste the following into Powershell amending the paths as required.

$inputfile = ‘C:\serverslist.txt’  #this is the file containing the list of server host names, one per line

$outputfolder = ‘C:\outputfolder\’  #this is the folder where the output text files will be stored

set-alias psexec ‘C:\PsExec.exe’ #this is the path to the free Sysinternals PsExec tool, available from http://technet.microsoft.com/en-us/sysinternals/bb897553

$servers=Get-Content $inputfile #get list of server hostnames

$serverscount = $servers.count;$i=0 #set values for progress counter

foreach ($server in $servers) {  #loop systematically through each server in the intput file

$i++  #increment progress counter   

Write-Progress -Activity “Checking servers for IPconfig and static route info” -Status “Querying:” -percentcomplete ((($i-1) / $serverscount)*100) -CurrentOperation “$server ($i of $serverscount)”  #display progress to the end user

$serverUNC = “\\” + $server  #PsExec requires server names to have \\ in front of them

$ipconfigoutput = & PsExec $serverUNC ipconfig /all #Connect to remote server using PsExec and run ipconfig /all

$routeprintoutput = & PsExec $serverUNC route print #Connect to remote server user PsExec and run route print

$outputfilename = $outputfolder+$server+”.txt”  #generate file name based on server name

($ipconfigoutput + $routeprintoutput) | out-file $outputfilename #output data to text file


Thanks to Nadeem Ahmed for providing this script

Please follow and like us:

Run batch file only if service exists

Reading Time: < 1 minute

REM – Check for an existing installation of ________________________
REM – For 32 Bit Windows
if exist “C:\Program Files (x86)\app name\software.exe” goto EOF
REM – For 64 Bit Windows
if exist “C:\Program Files\app name\software.exe” goto EOF
REM Deploy SOftware
Your script goes here
REM — End of the script

Note: You may need to reenter the speech marks after copying the script to a notepad file

Please follow and like us:

How to check if a particular patch is installed

Reading Time: < 1 minute

To check if a particular update is installed on your machine, you could browse to the control panel or check the Windows directory.

If you wish to carry out this task via script, the script can be found below. Just replace the patch in the highlighted area.

Set objSession = CreateObject(“Microsoft.Update.Session”)
Set objSearcher = objSession.CreateUpdateSearcher
Set objResults = objSearcher.Search(“Type=’Software'”)
Set colUpdates = objResults.Updates

For i = 0 to colUpdates.Count – 1
    If colUpdates.Item(i).Title = _
        “Security Update for Windows XP (KB89000)” Then
        If colUpdates.Item(i).IsInstalled <> 0 Then
            Wscript.Echo “This update is installed.”
            Wscript.Echo “This update is not installed.”
        End If
    End If

Wscript.Echo “This update is not installed.”

Please follow and like us: