Thursday, December 22, 2011

(Powershell Script) Ping list of IPs or hostnames

My first script :-

Below script uses WMI's Win32_PingStatus under the hood. It returns, by default, four "result" objects, each of which contains various properties, including a StatusCode, which will be 0 for successful pings Statuscode binary value of 11010 means that ping failed 

Copy below code and create .PS1 extension file
*************************************************************************
 # create a file with name "ips.txt" (containing ips and hostnames) put it under folder “c:\host”
$list = get-content "ips.txt"
foreach ($ip in $list)
{$result = Get-WmiObject Win32_PingStatus -filter "address='$IP'"
if ($result.statuscode -eq 0)
{
write-host "$IP Server is up"
}
else
{
Write-host "$IP Server is down"
}
}
*************************************************************************
Powershell Ping multiple IP addresses
Capture ping Latency or drops results with powershell - Part1
Capture multiple IP Latency or drops results with powershell Test-Connection - Part 2
Schedule PowerShell (.PS1 file) script in Windows Task Scheduler - Part 3

Wednesday, December 21, 2011

WMI won't repair

I received one ticket depicting for below issue for one of our server, I was not able to install patches through SCCM. "Can't connect to namespace in WBEMTest or WMI Control in Computer Mgmt (Properties state invalid namespace) - Please get WMI working so SCCM client can install"

After lots of of troubleshoot Logged a case with Microsoft and they gave me below suggestion. and Wmi started working again.

Re-register all the WMI DLLs and MOF files and rebuild the repository.

for /f %s in ('dir /b *.dll') do regsvr32 /s %s
for /f %s in ('dir /b *.mof *.mfl') do mofcomp %s
regsvr32 %windir%\system32\tscfgwmi.dll
wmiprvse /regserver
winmgmt /regserver




Thursday, December 15, 2011

Reset the remote console (DRAC/ILO/RSA)

Useful link: Find iLo, Drac, IMM/RSA, CIMC IP and MacAddress on esxi (vCenter)

We all are aware that the remote console (DRAC/ILO/RSA) can be accessed by using putty  or cmd as an interface to connect to port 22 and 23. Here is the guideline for those who might not be aware of this feature. This comes to the rescue when the remote console is responding to PING but the web interface is the not working and we are not able to RDP to the server to troubleshoot the issue. We can perform everything that can be done through the web interface i.e. remote console reset, server power reset, remote console configuration etc.

Here are the sample commands to reset/restart the remote console -

HP servers

cmd>Telnet 0.0.0.0 23/22
Login with the remote console userID/Password.

</>hpiLO-> cd /map1
status=0
status_tag=COMMAND COMPLETED

</map1>hpiLO-> reset
status=0
status_tag=COMMAND COMPLETED
Resetting iLO.

CLI session stopped.

Dell Servers

cmd> Telnet xx.xx.xx.xx 23/22
Login with the remote console userID/Password.

>Racadm racreset

IBM Servers
cmd> Telnet xx.xx.xx.xx 23/22
Login with the remote console userID/Password.

>resetsp
---------------------------------------------------------------------------

Note: Port 23 and 22 should be opened in order to use these commands. This can be verified from remote console web interface properties under remote console or network settings.