Delete Old Files

Batch script to delete X days old file from specified location. Where is X is number of days.

@echo off
REM Remove files backup older than X days
Echo Deleting Bak file….
forfiles /p “Folder Path” /s /m *.bak /c “cmd /c Del @path” /d -X
Exit

Note:
Folder Path= Replace with target folder.
Replace X with no of days (Eg :3 for 3 days old)

Thanks,
WintelAdmin

VB Script to collect Windows server hardware details on multiple machines.

VB Script to collect Windows server hardware details. Script will Collect Serial Number, Make, Model, OS, CPU, RAM, Drive details on multiple servers remotely.

Copy below contents and save as filename.vbs and create a machines.txt will all server names one per line.

 

***********************************************************************************************************************

Option Explicit

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

Const PATH_TO_INPUT = “Machines.txt”
Const PATH_TO_OUTPUT = “MachineInventory.csv”

Dim fso
Set fso = WScript.CreateObject(“Scripting.FileSystemObject”)

Dim shl
Set shl = WScript.CreateObject(“WScript.Shell”)

Dim input
Set input = fso.OpenTextFile(PATH_TO_INPUT)

Dim output
Set output = fso.CreateTextFile(PATH_TO_OUTPUT, True)

output.WriteLine “Hostname,Serial Number,Make,Model,BIOS Version,Operating System,CPU,Memory (MB),Disk Drives”

Dim wmiService
Dim wmiResults

Dim hostname
Dim make
Dim model
Dim biosversion
Dim operatingSystem
Dim serialNumber
Dim cpu
Dim memory
Dim drives

Dim line
Dim exec
Dim pingResults
While Not input.AtEndOfStream
line = input.ReadLine
hostname = “”
make = “”
model = “”
biosversion = “”
operatingSystem = “”
serialNumber = “”
cpu = “”
memory = “”
drives = “”

Set exec = shl.Exec(“ping -n 2 -w 1000 ” & line)
pingResults = LCase(exec.StdOut.ReadAll)

If InStr(pingResults, “reply from”) Then
WScript.Echo “Reply From: ” & line
On Error Resume Next

Set wmiService = GetObject(“winmgmts:\\” & line & “\root\CIMV2”)

If Not Err.Number = 0 Then
output.WriteLine line & “,Error: ” & Err.Description
WScript.Echo line & “,Error: ” & Err.Description
On Error GoTo 0
Else
On Error GoTo 0
hostname = line

Set wmiResults = wmiService.ExecQuery(“SELECT * FROM Win32_BIOS”, “WQL”, wbemFlagReturnImmediately + wbemFlagForwardOnly)

Dim item
For Each item In wmiResults
serialNumber = Trim(item.SerialNumber)
biosversion = Trim(item.SMBIOSBIOSVersion)
Next

Set wmiResults = wmiService.ExecQuery(“SELECT * FROM Win32_ComputerSystem”, “WQL”, wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each item In wmiResults
make = Trim(item.Manufacturer)
model = Trim(item.Model)
Next

Set wmiResults = wmiService.ExecQuery(“SELECT * FROM Win32_OperatingSystem”, “WQL”, wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each item In wmiResults
operatingSystem = Trim(item.Name)
operatingSystem = Split(operatingSystem, “|”)(0)
memory = Round(Trim(item.TotalVisibleMemorySize) / 1024, 2)
Next

Set wmiResults = wmiService.ExecQuery(“SELECT * FROM Win32_Processor”, “WQL”, wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each item In wmiResults
cpu = Trim(item.Name)
Next

Set wmiResults = wmiService.ExecQuery(“SELECT * FROM Win32_LogicalDisk WHERE DriveType=3”, “WQL”, wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each item In wmiResults
drives = drives & Trim(item.DeviceID) & ” ” & Round(Trim(item.Size) / (1024^2), 2) & “;”
Next

output.WriteLine hostname & “,” & serialNumber & “,” & make & “,” & model & “,” & biosversion & “,” & operatingSystem & “,” & cpu & “,” & memory & “,” & drives
WScript.Echo hostname & “,” & serialNumber & “,” & make & “,” & model & “,” & biosversion & “,” & operatingSystem & “,” & cpu & “,” & memory & “,” & drives
End If
Else
output.WriteLine line & “,No Response”
WScript.Echo line & “,No Response”
End If
Wend

output.Close
input.Close

Set wmiService = Nothing
Set wmiresults = Nothing

***********************************************************************************************************************

 

Thanks,

WintelAdmin

 

VMware Error 0x0000005D

When you try to install Windows Operating System, you would come across an error code 0x0000005D. This is purely an issue related to the virtual machine profile. Please validate if you have selected a correct profile. if not please choose the correct profile and restart the installation process.

In my case, was trying to deploy Windows 2003 std edition for a legacy application using SCCM 2012. Had no clue with the error code 0x0000005D, though I have set Windows 2003 Std 32 Bit in profile. Later realized that the SCCM is using the latest version and then selected the corresponding 64bit profle like Windows Server 2003 Enterprise x64 Edition – from the drop-down list. Voila it fixed my issue.

VM profile is available at below path.

VM->Edit Settings->Options->General Options->Version

Regards,
WintelAdmin

Outbound Emails blocked on Windows Server.

Recently, came across an issue where the outbound SMTP mail where getting blocked. When checked the server and firewall settings everything looked very normal. Finally, the issue was with McAfee. McAfee access protection has a feature to block the out going e-mails. Hence, below listed steps where performed to fix the issue.

1. Click Start, Programs, McAfee, VirusScan Console.
2. Right-click Access Protection and select Properties.
3. Click the Access Protection tab.
4. Under Categories on the left, select Anti-virus Standard Protection.
5. In the right pane, select Prevent mass mailing worms from sending mail.
6. Click on , block tab relevant to “Prevent mass mailing worms from sending mail to remove tick mark.
6. In the Processes to exclude section, type the process name, then click OK to close the Rule details window.
7. Click Apply then close the Access Protection Properties window.

Thanks,
WintelAdmin

Fix RDP on Windows 2003 without reboot.

A very common issue on a daily life of a Windows server administrator is that the users complaining about RDP issue. If the issue is with Windows 2008, that’s fine as we can restart the remote desktop services to fix the issue. But the same issue on Windows 2003 is bit annoying.

However, I have found a solution which works perfect.

The fix: (remotely using command prompt)

tasklist /s \\servername /svc /fi “imagename eq svchost.exe” (locate PID for TermService)
taskkill /s \\servername /pid xxxx (may need /f to force, UAC might give problems as well)
sc \\servername start TermService

The Fix: (local, using command prompt)

tasklist /svc /fi “imagename eq svchost.exe” (locate PID for TermService)
taskkill /pid xxxx (may need /f to force, UAC might give problems as well)
sc \\servername start TermService

Detailed Information:

Open a command prompt
Type in: tasklist /svc /fi “imagename eq svchost.exe”
This will list the different instances of svchost.exe and the associated service and PID
Locate TermService and note the PID for it
Open Task Manager and go to the Processes tab. Then click View > Select Columns and check PID, then click OK
Locate the svchost.exe process with the PID noted in step 4, right click it, select End Process
Open services.msc
Start the Terminal Services service

Thanks,
WintelAdmin

VM Tools Update Failure [solved]

During VM Tools update, if you find any issues like unable to remove older version of VMware Tools or error 1714, you can remove old version manually from the registry to resolve the issue:

1. Open the Windows Registry using regedit.
2. Browse to HKLM\Software\Microsoft\Windows\CurrentVersion\uninstall.
Search for the branch with a key named DisplayName and has a value of VMware Tools.
Delete the branch associated with that entry. Do not delete the entire uninstall branch.
3. Browse to HKLM\Software\Classes\Installer\Products.
Search for the branch with the key named ProductName and has a value of VMware Tools.
Delete the branch associated with that entry.
4. Browse to HKEY_CLASSES_ROOT\Installer\Products.
Search for the branch with the key named ProductName and has a value of VMware Tools.
Delete the branch associated with that entry.
5. Browse to HKLM\Software\VMware.
Delete the branch called VMware Tools.
6. Ensure the folder located in %ProgramFiles%VMwareVMware Tools is deleted.
7. Install the new version of VMware Tools.

NOTE: Take the backup of the registry before performing the above steps.

Thanks,
WintelAdmin

How to change the TCP port for IIS in Windows 2008?

We have an application team who has an web-based application configured to run on port 80. This application runs on JBoss. Due to someother dependency they had to install IIS on this server. However, their application was not listening to port 80 in JBoss. When checked port 80 was been used by the default website in IIS. We later unbinded the port 80 from IIS, fixed the issue.

1. Open IIS Manager
2. Select web site.
3. Click on “Bindings” under Action pane.
4. Click edit to change the port (we changed 80 as 8000)
5. Click OK to apply changes.

Thanks,
WintelAdmin

Physical to VM Conversion working slow using VMware converter.


Recently, I was doing a hot P2V of Windows 2003 server from HP Hardware to a virtual machine. It was bad experience that the data transfer was slow of about 64 KB/s showing 7 days remaining.

Many times, the task was cancelled and re-initiated, however with no success. tried disabling McAfee and backup services.

Later, I found an VMware KB article on disabling the SSL which fixed my issue with the data transfer of about 7-8 MB/s.

Please follow the below steps to disable SSL:-

1 – Locate “converter-worker.xml” on a machine on which the VMware Converter is installed and open in a text editor.
2 – Locate the tag pair<useSsl></useSsl>. It is located inside the<nfc>tag and has a value oftrue.
3 – Change the SSL Key <useSsl> true </useSsl> to false (“<useSsl>false</useSsl>”).
4 – Save and close the file.
5 – Restart “VMware vCenter Converter Standalone Worker” service.

Tips:
“converter-worker.xml” This file is location in the following locations
Windows Vista, Windows 7, Windows 2008 %ALLUSERSPROFILE%\VMware\VMware vCenter Converter Standalone
Windows XP, Windows 2003, Windows 2000 %ALLUSERSPROFILE%\Application Data\VMware\VMware vCenter Converter Standalone

Thanks,

WintelAdmin

Source:  kb.vmware.com/kb/2020517. Thanks to VMware Knowledge Base.

 

\\Netstat – A Great Tool.

Netstat is sometimes very handy while troubleshoot and there are many people who are not aware of output shown. Netstat displays a listing of network connections that and their status. Let me try to explain in detail.

C:\>netstat -ano
Active Connections
Proto                 Local Address                    Foreign Address                 State                       PID
TCP                      0.0.0.0:445                       0.0.0.0:0                             LISTENING                 4
TCP                      10.204.4.xx:1065              0.0.0.0:0                             LISTENING                132
TCP                      10.204.4.xx:1083              12.120.5.14:80                   TIME_WAIT        0
TCP                      10.204.4.xx:337                 72.14.207.99:443            CLOSE_WAIT      737
TCP                      10.204.4.xx:997                 72.14.205.83:443            CLOSE_WAIT      737
TCP                      127.0.0.1:337                   0.0.0.0:0                                  LISTENING          737
TCP                      127.0.0.1:478                    127.0.0.1:881                         ESTABLISHED    737
TCP                      127.0.0.1:881                   127.0.0.1:881                         ESTABLISHED    737

Local address column tends to be bit complex in nature, computer always has at least two (and sometimes more) IP addresses that it will answer to. The above example shows that the computer will answer to 10.204.4.xx and 127.0.0.1 (loop back address). The three addresses shown have different and special meanings.

127.0.0.1:port#         – programs listening on this address will accept connections originating from only the local computer.
10.204.4.xx:port#  – programs listening on this address will accept connections originating from computers on the network/internet.
0.0.0.0:port#            – programs listening on this address will accept connections from anywhere, local or remote, sent to any of the addresses the computer will answer to (in this case 127.0.0.1 and 10.204.4.xx).

The State column refers to the state of the TCP connection. You won’t see this for UDP connections because the don’t have state like TCP does. Here is the list of options available.

LISTEN                    – represents waiting for a connection request from any remote TCP and port.
SYN-SENT              – represents waiting for a matching connection request after having sent a connection request.
SYN-RECEIVED – represents waiting for a confirming connection request acknowledgment after having both received and sent a connection request.
ESTABLISHED   – represents an open connection, data received can be delivered to the user. The normal state for the data transfer phase of the connection.
FIN-WAIT-1          – represents waiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent.
FIN-WAIT-2         – represents waiting for a connection termination request from the remote TCP.
CLOSE-WAIT       – represents waiting for a connection termination request from the local user.
CLOSING                – represents waiting for a connection termination request acknowledgment from the remote TCP.
LAST-ACK             – represents waiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request).
TIME-WAIT        – represents waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request.
CLOSED                  – represents no connection state at all.

Thanks,
WintelAdmin.com