November 30, 2011

Script to monitor specific service on multiple Windows Servers

Hi,

Please find the script for service monitoring on multiple windows servers and do let me know your feedback.

how to run?
-create a separate folder name it anything
-create a txt file name as compname.txt (in case of me, I have used this name under script)
-Input all servers name inside the compname.txt file
-copy and paste the script in notepad and save it as .vbs
-double click on the .vbs file
-log file with current date and time will be automatically generated and you can see the service status inside.


'script to monitor specific service on multiple Windows Servers
'script created by Atul Mishra
'pls check the automatically generated log file for service status
Dim sDate
Dim strTime
Dim strDate
Dim strState
Dim strDataIn           'Input list from text file
Dim aryData                     'Array to hold input stream
Dim iCounter            'Iterative loop counter
dim strOUT                      'Output file
Dim oWshShell           'Windows shell script 
Dim objFSO                      'Scripting File System 
Dim objFile                     'Open text file
Dim strFilePath         'Path to current directory
Dim strServiceName      'Name of service to be checked
 
Set oWshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFilePath = objFSO.GetAbsolutePathName(".")
 
'Get Service Name
strServiceName = InputBox("Enter name of service...", "Service name input")
 
'Read file into a variable
strDataIn = f_r(strFilePath & "\compname.txt")

'Split into an array
aryData = Split(strDataIn,vbCrLf) 
oWshShell.Popup Ubound(aryData) + 1 & " Hosts/Addresses in list." & Chr(13) & "Scan is underway.",2,"Notice",64
sDate = Date
strTime = Now
StrDate = DatePart("m",sDate) & "." & DatePart("d",sDate) & "." & Hour(strTime) & "." & Minute(strTime)
set strOUT = objFSO.CreateTextFile(strFilePath & "\SERVICEResults." & strDate & ".log")
strOUT.WriteLine strServiceName & " query results:"
strOUT.WriteBlankLines (2)
For iCounter = 0 to Ubound(aryData)
 aryData(iCounter) = Trim(aryData(iCounter)) ' clean "white space"
If GetService(aryData(iCounter), strServiceName) then
        strOUT.Write aryData(iCounter) & ",Installed : " & strState & vbcrlf
Else
        strOUT.Write aryData(iCounter) & ",Service not present" & vbcrlf
End if
Next
strOUT.Close 
set strOUT = nothing
set objFSO = nothing
oWshShell.Popup "Scan processing complete.",5,"Notice",64
WScript.quit
   
'Given the path to a file,  this function will return entire contents
Function f_r(FilePath)
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
  f_r = FSO.OpenTextFile(FilePath,1).ReadAll
End Function
'Returns True or False based on the status of the specified Service
Function GetService(strComputer, strSrvce)
On Error Resume Next
Dim objWMIService
Dim colListOfServices
Dim objService
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
    ("Select DisplayName,State from Win32_Service Where Name = '" & strSrvce & "'")
If Err.Number <> 0 Then
  GetService = "False"
  Err.Clear
Else
For Each objService in colListOfServices
  GetService  = "True"
  strState  = objService.State
Next
End If
End Function

Please let me know your views.
Cheers!

Script to fix WSUS client issue automatically

Hi Everyone,

Please find the script to make your infrastructure environment 100% patch compliant and do let me know the feedback. It will help admins to fix WSUS client issue and can help them to automate the fix and reduce no of tickets :)

Here we go,

'script will use wmi to do the following on a local computer
'Created by Atul Mishra
' Supported OS - Win XP, Win7, Win 2003 server, Win 2008 server
'1. Stop the Automatic Updates Service
'2. Delete the %WINDIR%\softwaredistribution folder
'3. Delete the HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate keys and subkeys.
'4. Start the Automatic updates Service
'5. Send a wuauclt.exe /resetauthorization /detectnow command to sysem
'6. Initiate software update scan cycle actions
dim objFSO, objShell, objTempFile, objTS
dim sCommand, sReadLine
dim oCPAppletMgr 'Control Applet manager object.
dim oClientAction 'Individual client action.
dim oClientActions 'A collection of client actions.
'dim bReturn
set objShell = WScript.CreateObject("Wscript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
'----------------Stop Automatic Updates Service--------------------
'
'
'On Error Resume Next
' NB strService is case sensitive.
strService = " 'wuauserv' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
objService.StopService()
Next
WScript.Echo "Service has been stopped"
'
'
'
'----------------- Delete Folder and Reg Keys --------------------------------
strExe = "cmd.exe /C rmdir %WINDIR%\SoftwareDistribution /S /Q && cmd.exe /C REG DELETE HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate /f"
' Connect to WMI
'
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
WScript.Echo "The software Distribution Folder and WindowsUpdate regsitry keys have been deleted."
'------------------ Start Automatic Update Service -------------
'On Error Resume Next
' NB strService is case sensitive.
strService = " 'wuauserv' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
objService.StartService()
Next
WScript.Echo "Service has been Started on " & strcomputer

'-------------- Force Checking to WSUS server by issueing a wuauclt.exe /resetauthorization /detectnow ------------

strExe = "cmd.exe /C wuauclt.exe /resetauthorization /detectnow"
' Connect to WMI
'
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
WScript.Echo "Force checkin has been sent. Process Complete."
'Initiate software update scan cycle actions
'Get the Control Panel manager object.
set  oCPAppletMgr=CreateObject("CPApplet.CPAppletMgr")
if err.number <> 0 then
    Wscript.echo "Couldn't create control panel application manager"
    WScript.Quit
end if
'Get a collection of actions.
set oClientActions=oCPAppletMgr.GetClientActions
if err.number<>0 then
    wscript.echo "Couldn't get the client actions"
    set oCPAppletMgr=nothing
    WScript.Quit
end if
'Display each client action name and perform it.
For Each oClientAction In oClientActions
    if oClientAction.Name = "Software Updates Assignments Evaluation Cycle" then
        wscript.echo "Performing action " + oClientAction.Name
        oClientAction.PerformAction
    end if
next
set oClientActions=nothing
set oCPAppletMgr=nothing

If you have some more thoughts, please share. I would like to script your thoughts to automate the administration.

Cheers!

June 6, 2011

Status message query to find out all sccm servers with specific component status

select stat.*, ins.*, att1.*, stat.Time from  SMS_StatusMessage as stat left join SMS_StatMsgInsStrings as ins on ins.RecordID = stat.RecordID left join SMS_StatMsgAttributes as att1 on att1.RecordID = stat.RecordID where stat.Component = "SMS_EXECUTIVE" and stat.Time >= ##PRM:SMS_StatusMessage.Time## order by stat.Time DESC

Cheers!

April 27, 2011

Collection query to list all clients where advertisement was not succeeded

We can create a collection with the below dynamic query to list all clients where specific advertisement was not successful. All you need to change the advert ID and use it to your production environment to make management happy by reports.

SMS_R_SYSTEM.ResourceID not in (select SMS_ClientAdvertismentStatus.ResourceID from SMS_ClientAdvertisementStatus where SMS_ClientAdvertisementStatus.AdvertisementID = "ADV20408" and SMS_ClientAdvertisementStatus.laststatusmessageID in (10009))

Cheers!

WMI Commands to perform SCCM actions

Here we go; WMIC is tool which can be used as command line and perform below sccm actions -

Disable Software-Distribution:
WMIC /namespace:\\root\ccm\policy\machine\requestedconfig path ccm_SoftwareDistributionClientConfig  CREATE ComponentName="Disable SWDist",Enabled="false",LockSettings="TRUE",PolicySource="local",PolicyVersion="1.0" ,SiteSettingsKey="1" /NOINTERACTIVE

Re-Activate Software-Distribution:
WMIC /namespace:\\root\ccm\policy\machine\requestedconfig path ccm_SoftwareDistributionClientConfig  WHERE ComponentName="Disable SWDist" delete /NOINTERACTIVE

Trigger Hardware Inventory:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000001}" /NOINTERACTIVE

Trigger Software Inventory:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000002}" /NOINTERACTIVE

Trigger DataDiscoverRecord (DDR) update:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000003}" /NOINTERACTIVE

Force a FULL HW Inventory on next HW-Inv Schedule:
WMIC /namespace:\\root\ccm\invagt path inventoryActionStatus where InventoryActionID="{00000000-0000-0000-0000-000000000001}" DELETE /NOINTERACTIVE

Repair SMS/SCCM Agent on a remote client:
WMIC /node:%MACHINE% /namespace:\\root\ccm path sms_client CALL RepairClient

Repair a list (all clients listed in clients.txt) of remote SMS/SCCM Agents:
WMIC /node:@clients.txt /namespace:\\root\ccm path sms_client CALL RepairClient

Cheers!

March 4, 2011

Run commands for SCCM clients

These are few things which I have shared for loving helpdesk engineers who help us to achieve healthy sccm environment.

ccmsetup - for checking ccmsetup installation and uninstallation activity logs
ccm - for checking downloaded content cache, client's logs, inventory, metering and other client related information
ccm/smsrap.cpl - for checking available programs listed on client's Run Advertised Programs under Control panel

Cheers!

February 20, 2011

Mastering SCCM - Step by step guide for SCCM

Tremendous efforts have been made by anyweb (Niall Brady, founder of windows-noob). New SCCM admins can refer this step by step guide to get a thorough idea of SCCM functionalities.

Please refer to below link-
SCCM 2007 step by step Guide

Cheers.

Client installed but showing as 'No' to SCCM console - troubleshooting tips #4

Hi Again,

While SCCM admins plan to upgrade sms client to sccm client and you have a large SCCM infrastructure with multiple sites, make sure that you have configured site code within client push installation method of primary sites or if you have planned to upgrade clients with software distribution methods, don't use auto discovery for all clients, it can cause you a large no of unhealthy clients. You will see number of clients which have client installed but showing as 'No' to sccm console. To eliminate this, you can prepare site wise client upgrade package and can deploy it to respective sites.

One more good option is to prepare a script which will discover client's site boundary (AD site) and assign site code immediately. this script can be deploy to all clients within your sccm infrastructure centrally.

Anyway, if you have such computers in which client is installed but showing 'No' in console, one more option is to set the correct site code and resolve the issue.

Hope it helps.

Clarifications on my previous posts

I started this blog for SMS Admins so that they can get all relevant information from here. Earlier, I was adding few important points of SMS 2003 from Microsoft technet library which have helped new admins working on SMS.

There are several blogs, tutorials and e-learning portals where people can have a look but they don't do so because of time constraint, I help them to see all relevant administrative tips on my blog portal.

If anyone has any comments about my blog, please let me know with your name and email id. I welcome your thoughts.

Anonymous comments would be treated as spam message and will be deleted immediately.

Cheers!

February 6, 2011

My Next Milestone 'Solutions Architect' by 2012

I am just understanding the responsibilities of 'Solutions Architect' and below are my findings about SA roles -
  • Assist in the refinement of business requirements
  • Respond to business requirements with feasible technical solutions
  • Provide an architectural design for the selected solution that:
  • Helps the customer verify that they're satisfied with what they're getting
  • Provides a blueprint for the project manager to plan with
  • Informs the constructors so that they can estimate cost & effort
  • Liaise with: 
    • The customer to ensure alignment with requirements
    •  The project manager to identify appropriate constructor engagement
    •  Constructors to validate feasibility & provide support throughout construction
    •  Write & present eloquently with the appropriate audience perspective in mind
    •  Build & maintain excellent relations with key stakeholders
    •  Apply their creative skills & talents in devising effective designs (a.k.a. thought leadership)
    •  Continuously expand their knowledge & specialisation of technology & design patterns
Finally, I can conclude that SA role is a Subject Matter Expert role who actively involves with Project Management team and helps Project manager to take decisions with expert judgement.

Cheers!

can't reinstall sccm client on machine 'MSI: Could not delete key'

Please find below scenarios with respective troubleshooting steps- MSI: Could not delete key \SOFTWARE\Classes\CLSID\{84ECA343-5158-48BB-87C3-37EF4B919F20}. Verify that you have sufficient access to that key, or contact your support personnel.


  1. Open command prompt window with run as account domain\smsclient account (to avoid any access related issue)
  2. Run ccmclean .exe /Q /All (I know that we can remove sccm client with ccmsetup.exe /uninstall switch but it seems that legacy sms client settings prevent sccm upgrade and thus, it needs to be uninstalled properly)
  3. Run installsccm.bat file on machine to install sccm client (please verify ccmsetup.log file for successful installation)

MSI: Setup was unable to create the WMI namespace CCM\SoftwareMetering Agent The error code is 80041002

  1. Open command prompt window with run as account tp1\srvsmsclinst (to avoid any access related issue)
  2. Run ccmclean .exe /Q /All (I know that we can remove sccm client with ccmsetup.exe /uninstall switch but it seems that legacy sms client settings prevent sccm upgrade and thus, it needs to be uninstalled properly)
  3. Run setWMI.bat to repair WMI (I use below script and have got 100% success @all time)
  4. Run installsccm.bat file on machine to install sccm client (please verify ccmsetup.log file for successful installation).
'setWMI.bat
'script here
net stop ccmexec

net stop winmgmt
%SYSTEMDRIVE%
CD %windir%\system32\wbem
rd /S /Q repository
net start winmgmt
net start ccmexec
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
for /f %%s in ('dir /b *.mof') do mofcomp %%s
wmiprvse /regserver

Hope it helps.

January 31, 2011

Microsoft SCCM 2012 (vNext) in Cloud computing environment?

Microsoft introduces Dynamic Datacenters to deliver cost effective solutions and is integrating
System Center products with private cloud computing foundations. These products are-

System Center Data Protection Manager
-- for data protection and recovery

System Center Configuration Manager
-- to design, configure and deploy

System Center Service Manager
-- for IT Service Management

System Center Operations Manager
-- to monitor and manage service end to end

System Center Virtual Machine Manager
-- to virtualize, deploy and manage

Opalis
-- IT Process Management

I am trying to get some news how these products work under cloud computing environment and will share you soon.

Cheers!

Go Green for IT - Implement Cloud Computing Infrastructure

Cloud computing is virtualized compute power and storage delivered via platform-agnostic infrastructures of abstracted hardware and software accessed over the Internet. These shared, on-demand IT resources, are created and disposed of efficiently, are dynamically scalable through a variety of programmatic interfaces and are billed variably based on measurable usage.

Cloud "Applications"
Examples: SalesForce, Gmail, Yahoo! Mail, Quicken Online

Advantages: Free, Easy, Consumer Adoption
Disadvantages: Limited functionality, no control or access to underlying technology

Cloud "Platforms"
Examples: Google App Engine, Heroku, Mosso, Engine Yard, Joyent or Force.com (SalesForce Dev Platform)

Advantages: Good for developers, more control than “Application” Clouds, tightly configured
Disadvantages: Restricted to what is available, other dependencies

Cloud "Infrastructure"
- Provide “Compute” and “Storage” clouds
- Virtualization layers (hardware/software)

Examples: Amazon EC2, GoGrid, Amazon S3, Nirvanix, Linode
Advantages: Full control of environments and infrastructure
Disadvantages: premium price point, limited competition

Cloud "Extenders"
- Provides extension to Cloud Infrastructure and Platforms with basic functionality

Examples: Amazon SimpleDB, Amazon SQS, Google BigTable
Advantages: Extends functionality of Compute & Storage Clouds to integrate with legacy system or other clouds
Disadvantages: Sometimes requires use of specific Platforms or Infrastructure

Cloud "Aggregators"
- Sits on top of various Cloud Infrastructures for management
Examples: RightScale, Appistry
Advantages: Provides more options for Cloud environments
Disadvantages: Dependent on Cloud Providers
Hosting Heads to the Clouds
Static -> Dynamic = Quick & Easy Scalability
Cost Prohibitive -> Cost Effective = Cost Efficiencies
Predictable -> Unpredictable = Innovations
Stagnant -> Growth = Evolution
Traditional Hosting -> Cloud Hosting = FUTURE!

sources: http://blog.GoGrid.com

January 20, 2011

Optimize your IT Infrastructure with cost effective solutions

One of the most admiring thing of Microsoft is to be very customer oriented and to provide best solution/services within optimum cost. I really appreciate that MS always focuses on business needs and there are timely enhancements of MS technologies.

Generally, Organization looks for optimized IT Infrastructure withing its production environment and it's like investing on IT resources as below-
  1. Infrastructure Setup need Servers and workstations
  2. Servers need servers management tools  
  3. Server management tools need server administrators
  4. Server Administrators need skills upgrade (Trainings & Certifications)
  5. Workstations need few agents to be managed properly
  6. agents need system engineers
  7. If company is medium or large scale enterprise, it further requires Global Service Desk and Onsite Service Desk
 As IT consultant, I think, now Microsoft is coming with solutions as

Infrastructure Setup need Servers and workstations

-- Cloud Computing, Virtualization
Servers need servers management tools
-- System Center products (SCCM, SCOM, etc)
Server management tools need server administrators
-- MS might come up with Artificial Intelligence
Server Administrators need skills upgrade (Trainings & Certifications)
-- Virtual Labs

Workstations need few agents to be managed properly
-- SCCM Client (for Managing)

Workstations need system engineers to troubleshoot any issues
(If company is medium or large scale enterprise, it further requires Global Service Desk - GSD and Onsite Service Desk - OSS)
If it's GSD - MS is coming up with Service Manager 2010 (SCSM 2010 provides built-in processes based on industry best practices for incident and problem resolution, change control, and asset lifecycle management. Through its configuration management database (CMDB) and process integration, Service Manager automatically connects knowledge and information from System Center Operations Manager, System Center Configuration Manager, and Active Directory Domain Services)


If it's OSS - TIFIC (finally recommended)

Why TIFIC?
IT environment presents a difficult challenge for IT Service Support organizations who are facing the reality of “doing more with less” — while improving customer satisfaction. End users support presents a unique challenge due to the shear number of applications (productivity, line-of-business, etc.), that many users have gone mobile and that the typical end user computing environment is going through constant change, which we all know is the root cause of most problems.


The net result is an overwhelmed, reactive IT support staff that and are facing some difficult challenges.

  • Higher call volumes, longer wait times and higher abandonment rates
  • Longer support calls
  • Lower first time fix rates and more costly escalations
  • Declining customer satisfaction

Utilizing Support Automation technologies, Enterprise IT Service Support organizations can reap significant business benefits that include:

  1. Transform the support organization from being reactive to being proactive — thereby increasing end-user and support staff productivity and satisfaction.
  2. Reduce the support load (fewer calls) on the service desk through automated resolution of known problems.
  3. Reduce the AHT (Average Handling Time)
  4. Increase FTR (First Time Resolution), eliminating costly escalations
  5. Improve end user satisfaction
note - pls go thru link for more information on TIFIC http://www.tific.com/?page_id=13

I will come up with Cloud computing concepts soon.
Cheers!

January 13, 2011

Important tips for SCCM Client Upgrade/Reinstall

If you are upgrading sms clients to sccm, you can run sccm client setup file directly to machines as it automatically detects any legacy version of sms and removes (uninstalls) it.

but if you have any problem with existing SCCM client and you really want to reinstall client to make it healthy, don't run ccmsetup.exe file directly to machine, first uninstall sccm client using ccmsetup.exe /uninstall from machine and then install it.

Note: Always try to lookup on sccm client logs for better troubleshooting and try repair client if it was working earlier and finally reinstall it.

Client installed but showing as 'No' to SCCM console - troubleshooting tips #3

It's better to understand the difference between reinstalling sccm client and repairing sccm client. When you reinstall a client, it creates SMS classes in WBEM repository, initiates policies for notification to SCCM management point and gets new SMS GUID as an identification but it won't delete the exisitng GUID (SMS keeps it until we delete certificate using ccmdelcert.exe from the toolkit.. or uninstall sccm client porperly). SMS identifies it as new record and acts on it as new client. If you have added this machine to somewhere your system based collection, it won't be getting any policies. Machine, having old GUID certificate, would be negligable and policies would be rejected from respective Management point.
While, if you repair a client; it removes old certs, assigns it new certificate and initiates policies as unique record. It works properly and policies are apporved by MP.

Cheers!

January 8, 2011

Client installed but showing as 'No' to SCCM console - troubleshooting tips #2

During troubleshooting this strange behaviour, I got to know that if sms clients are not upgraded as sccm clients, they will show status as Client installed 'Yes' but it won't be approved by site and will not work properly.

In other scenario, it might show client installed status as 'No' if your client is not upgraded or is not assigned to respective site.

You need to query all clients with legacy version and install sccm client on these machines.