Category Archives: Windows

Removing patches or hotfixes from windows server remotely

Below is the powershell script you can use to remove patches/hotfixes from servers remotely :

if($args[0] -eq $null)
{
$servernamefile = “c:\serverlist.txt”;
$hotfixidfile= “c:\hotfixlist.txt”;
}
else
{
$servernamefile = $args[0];
$hotfixidfile = $args[1];
}

$info1 = get-content $servernamefile;
$info2 = get-content $hotfixidfile;

foreach ($hotfixid in $info2)
{

foreach ($computername in $info1)
{
$KBhotfix=”KB”+$hotfixid;
if ((get-hotfix -id $KBhotfix -computername $computername))
{
Write-Host $hotfixid ‘ found on’ $computername ‘, removing it……’;
wmic /node:$computername process call create “powershell wusa /uninstall /kb:$hotfixid /quiet /forcerestart”;
}

else
{
Write-Host $hotfixid ‘ not found on’ $computername ‘.’;
}
}

Start-Sleep -s 600;
}

Advertisements

Finding SCCM client health of windows servers

Below is powershell script you can use to find healthcheck of SCCM clients on servers remotely-

$comp = get-content serverlist.txt

$strFileResults = “sccmclientstatus.txt”

$strOffLinePCs = “offlineservers.txt”

$skipped = @()

$comp | foreach {

$Global:currentpc = $_

if (Test-Connection $currentpc -Quiet -Count 1)
{
$status = get-service -ComputerName $currentpc | where-object { $_.Name -eq “CcmExec”} |
ForEach-Object { $_.status}

$strLine = $currentpc + “,” + $status

$strLine | Out-File $strFileResults -append

Write-Host $currentpc”,”$status

}
else
{
$skipped += $currentpc
}

}

$skipped | Out-File $strOffLinePCs

How to test SMTP functionality ( Telnet ) in a Windows server

First of all , you should have telnet installed in your server/system from add/remove features of windows control panel to test smtp functionality. You can do like below to test it through command prompt-

telnet yourmaildomain.ext 25

helo yourmaildomain.ext

mail from: sendermail@domain.ext

rcpt to: receievermail@domain.ext

data

subject : your subject followed by twice enter key

Your body of email followed by .

quit

HResult 0x2, Level 16, State 1 Named Pipes Provider: Could not open aconnection to SQL Server [2]. Sqlcmd: Error: Microsoft SQL ServerNative Client 10.0 : A network-related or in stance-specific error hasoccurred while establishing a connection to SQL Server . Server is notfound or not accessible. Sqlcmd: Error: Microsoft SQL Server NativeClient 10.0 : Login timeout expired.

After installing new  SQL server 2008 R2 in Windows Server and connection to sql using “sqlcmd.exe” in command prompt gave below error-
HResult 0x2, Level 16, State 1 Named Pipes Provider: Could not open a connection to SQL Server [2]. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in stance-specific error has occurred while establishing a connection to SQL Server . Server is not found or not accessible. Check if instance name is correct and i f SQL Server is configured to allow remote connections. For more information see  SQL Server Books Online.. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

To fix this problem , change the Named pipe value from below \\.\pipe\MSSQL$SQLEXPRESS\sql\query to

\\.\pipe\sql\query using SQL Server Configuration Manager.

HTTP Error 500.21 – Internal Server ErrorHandler "PageHandlerFactory-Integrated" has a badmodule "ManagedPipelineHandler" in its module list

After installing new IIS and copying new ASP.NET code at /wwwroot folder of inetpub and browsing  the index.aspx file from IIS it resulted in below error-

“HTTP Error 500.21 – Internal Server Error Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list”

The issue is that ASP.NET is not registered in new IIS & it needs to be registered like below-

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i