Scott Hinsley's WebLog

  • Windows Server Longhorn: Server Core

    What is Server Core?

    Server core is a minimal installation option for Windows Server "Longhorn" providing a minimal environment supporting specific server roles.  Server Core reduces servicing and management requirements while providing a minimum attack surface for supported roles.

     

    Server Roles 

    ·         DHCP server

    ·         File Server

    ·         DNS server

    ·         Active Directory®

     

    Optional Components 

    ·         BitLocker

    ·         BitLocker Remote Admin Tool

    ·         Client For NFS

    ·         DFS Server

    ·         DFS Replication

    ·         Failover Cluster

    ·         FRS

    ·         Media Server

    ·         MultipathIO

    ·         Removable Storage Management

    ·         Network Load Balancing

    ·         LPD Print Service

    ·         Server For NFS

    ·         Single Instance Storage

    ·         SNMP

    ·         Subsystem for UNIX-based Applications

    ·         Telnet Client

    ·         Windows Server Backup

    ·         WINS 

    Installing Server Core 

    Minimum Requirements:

    Requirement

    Specification

    Minimum CPU Speed

    400 MHz for x86-based computers

    733 MHz for x64-based computers

    Minimum RAM

    256 MB

     

     

    This will likely be your first installation of Longhorn Server Core, but tuck this away for future reference:

    -          Previous version of Windows Server cannot be upgraded to Server Core, 

    -          Full installations of Longhorn cannot be converted to Server Core, 

    -          Server Core cannot be upgraded to a full installation of Longhorn Server

    -          Server Core will be upgradable to Server Core R2. 

    Installation

    1.       Now throw in the DVD, wait a few minutes and click Install now 

    2.       Enter your product ID. (You do have a product ID, don’t you?)

    3.       Choose the Server Core option. 

    4.       Accept the license agreement.

    5.       Choose Advanced 

    6.       Select a disk to install to…

    7.       Wait for the file copy to complete… 

    Configuring Server Core 

    8.       Logon with blank password. 

    9.       Set local administrator password:

     net user administrator  new_password

    - OR -

    net user administrator  *

    10.    Activate the server:

    a.       Check license status: 

    Cscript c:\windows\system32\slmgr.vbs -xpr

     

    b.      Local activation:  

    Cscript c:\windows\system32\slmgr.vbs -ato

     

    c.       Remote activation: 

    Cscript c:\windows\system32\slmgr.vbs dc-contoso-01 contoso\administrator p@ssw0rd -ato

     

    d.      Activate with user provided activation code: 

    Cscript c:\windows\system32\slmgr.vbs -atp

     

    e.      Help -? 

     

    11.   Rename the machine:

     NETDOM RENAMECOMPUTER %computername% /NewName:DC-CONTOSO-01 /REboot

     

    12.   Set IP Properties

    a.       Get interfaces:

     Netsh interface ipv4 show interfaces

     

    b.      Note IDX number for each network adapter to be modified. 

    c.     Set Static IP, subnet mask and Default Gateway

     netsh interface ipv4 set address name=3 source=static address=192.168.1.1 mask=255.255.255.0 gateway=192.168.1.2

     

    Where:

    Name is the number from step 2 above

    Address is the static IP address you are setting

    Mask is the subnet mask for the IP Address

    DefaultGateway is the default gateway

     

    d.      To change back to DHCP: 

    netsh interface ipv4 set address name=3 source=dhcp

     

    13.   Configuring DNS Settings:

    a.       Set the DNS Server address.

    netsh interface ipv4 add dnsserver name=3 address=127.0.0.1 index=1 

    netsh interface ipv4 add dnsserver name=3 address=192.168.0.1 index=2

     

    Where:

    Index is the interface number.

    Address is the IP address of your DNS server

    Index is the ordinal for the DNS address you would like to change.

     

    b.      Repeat for each DNS server you want to set, incrementing the index= number each time. 

    c.       To delete a DNS address: 

    Netsh int ipv4 delete dnsserver index=3 address=192.168.1.2

     

    1. Setting the display resolution to something useful with Regedit:
      1. Open Regedit,
      2. Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video
        1. You'll have to go fishing to find the key for your video adapter
      3. Set DefaultSettings.Xresolution & DefaultSettings.Yresolution to something you monitor will support.

    Example:

    DefaultSettings.Xresolution = 1152

    DefaultSettings.Yresolution = 768 

    Managing Server Core

    Server Core may be manage as follows:

    ·         Locally and remotely with Command Prompt.

    ·         Remotely with Terminal Server.

    ·         Remotely using Windows Remote Shell on Vista or "Longhorn"

    ·         Remotely via MMC snap-ins.

     

    15.   Check event logs with wevtutil from Vista or Longhorn:

    Wevtutil qe System /f:text /c:1 /rd:true

                            NOTE: Options and values are case-sensative

     

    16.   Complete local configuration tasks with Scregedit.wsf (1217 lines of script!) 

    a.       Enable Terminal Server Remote Admin Mode:

                                cscript C:\Windows\System32\Scregedit.wsf /ar 0 

    b.      Enable connection by down level TS clients:

              cscript C:\Windows\System32\Scregedit.wsf/cs 0 

    c.       Configure the pagefile.

    d.      Enable automatic updates.

    e.      Enable error reporting.

     

    1. Enable and use Windows Remote Shell (WinRS):

    a.       Enable WinRS on Server Core 

    WinRM quickconfig

     

    b.      Connect with WinRS: 

    winrs -r:dc-contoso-01 dir c:\windows

    winrs -r:dc-contoso-01 wevtutil qe System /f:text /c:15 /rd:true

    winrs -r:dc-contoso-01 wevtutil qe System /f:RenderedXml /e:SystemLog /c:15 /rd:true > event.xml

     

    18.   Time and International settings:

    a.       Setting Time: 

    control timedate.cpl.

     

    b.      International Settings: 

    control intl.cpl

     

    19.   Managing Server Core via MMC;

    a.       If you don't know how to do this, you are in the wrong session.

     TIP: if not domain joined, establish a session first:

     

    Net use * \\ServerName\c$ /u:UserName

     

    Driver Management 

    20.   Installing hardware with and without "in-box" drivers:

     If the driver is included in Longhorn Server Core:

    a.       Add the hardware.  PNP will start and do the rest. 

    Otherwise:

    a.       Copy the driver files to a temp folder on Server, 

    b.      Execute the following command: 

    Pnputil –i –a <path>\<driver>.inf

     

    c.       Restart if needed.

     

    21.   List and delete installed drivers:

    a.       List installed drivers:

    sc query type= driver

     

    NOTE:  The space after "type=" is a quirk of many tools you'll be using.

     

    b.      Delete specified driver: 

    sc delete service_name

     

    22.   Service Propeties

    a.       Change service parmeters:

    Sc config /? 

    Sc config "RemoteRegistry" start= auto

     

    NOTE: space after "=" sign.

     

    Managing Applications 

    23.   Installing, Viewing and Removing Applicaitons

    a.       Install: 

    Msiexec /I c:\install\NTBackupRestore.msi /qb 

    b.      List applications by name: 

    Wmic product get name /value

     

    c.       Removing Applications 

    Wmic product where name="NTBackupRestore" call uninstall

     

    d.      Listing hotfixes 

    wmic qfe list

     

    e.      Installing Hotfixes 

    Wusa.exe <patchname>.msu /quiet 

     

    24.   OCLIST & OCSETUP

    NOTE: Ocsetup is case sensitive!!!

     

    This will fail: 

    Start /w Ocsetup WindowsServerbackup

     

    This will succeed: 

    Start /w Ocsetup WindowsServerBackup

     

     Uninstall WindowsServerBackup

    Start /w Ocsetup WindowsServerBackup /uninstall

     

    Installing and Configuring Server Roles

     

     Install and Configure DNS

    25.   Installing DNS Server Role - ALREADY INSTALLED!

    a.       Run the following: 

    Start /w Ocsetup DNS-Server-Core-Role 

     

    26.   Configure DNS - Step By Step: 

    a.       Allow auto-creation of reverse lookup zones. 

    dnscmd 192.168.1.1 /config /disableautoreversezones 0

     

    b.      Create a secondary zone: 

    dnscmd 192.168.1.1 /zoneadd contoso.com /Secondary 192.168.1.2

     

    c.       Create a Primary zone: 

    dnscmd 192.168.1.1 /zoneadd contoso.net /Primary

     

    d.      Create a new A record: 

    dnscmd 192.168.1.1 /RecordAdd contoso.net dc-contoso-01 A 192.168.1.1

     

    e.      Add CNAME: 

    dnscmd 192.168.1.1 /RecordAdd contoso.net www CNAME dc-contoso-01.contoso.com

     

    f.        Delete a zone: 

    dnscmd 192.168.1.1 /zonedelete contoso.net

      

    27.   To automate DNS configuration, put all the commands in a batch file and run:

     Start /w c:\unattend\dns\dnsunattend.cmd

     

    Install and Configure DHCP 

    28.   Install DHCP Server Role using OCSETUP - Already Installed!!!

    a.       At the command prompt, type:  

    start /w ocsetup DHCPServerCore 

     

    29.   Authorize/Deauthorize DHCP server in Active Directory:

    a.       Authorize: 

    Netsh dhcp add server dc-contoso-01.contoso.com 192.168.1.1

     

    b.      De-authorize:

    Netsh dhcp delete server dc-contoso-01.contoso.com 192.168.1.1

     

    30.   Configure a DHCP scope:

    a.       Add a scope with specified IP network, subnet mask and comment: 

    netsh dhcp server 192.168.1.1 add scope 192.168.1.0 255.255.255.0 LonghornScope "Longhorn Engineering"

     

    b.      Add IP address range with ClientType set to DHCP: 

    netsh dhcp server 192.168.1.1 scope 192.168.1.0 add iprange 192.168.1.1 192.168.1.254

     

    c.       Add IP exclusion range: 

    netsh dhcp server 192.168.1.1 scope 192.168.1.0 add excluderange 192.168.1.1 192.168.1.20

     

    d.      Set router option value 003: 

    netsh dhcp server 192.168.1.1 scope 192.168.1.0 set optionvalue 003 IPADDRESS 192.168.1.1 192.168.1.2

     

    e.      Set DNS Server option value 006: 

    netsh dhcp server 192.168.1.1 scope 192.168.1.0 set optionvalue 006 IPADDRESS 192.168.1.1 192.168.1.2

     

    f.        Activate the new scope: 

    netsh dhcp server 192.168.1.1 scope 192.168.1.0 set state 1 

     

    31.   Viewing DHCP Configuration:

    Netsh dhcp server show scope

     

    32.   Removing DHCP Configurations:

    a.       Delete a scope:

    Netsh dhcp server delete scope 192.168.1.0 DHCPFULLFORCE

     

    1. DHCP configuration automation is possible much the same way as DNS.  Put all the command in a batch file and run: 

    c:\unattend\DHCP\DhcpUnattend.cmd 

     

    Installing Active Directory Domain Services

    1. Use DCPROMO /unattend:<filename> to install AD DS.  DON’T USE OCSETUP! 

    a.       New forest: 

    [DCINSTALL]

    ReplicaOrNewDomain=Domain

    TreeOrChild=Tree

    CreateOrJoin=Create

    NewDomainDNSName=contoso.com

    DNSOnNetwork=yes|no (Yes mean use existing DNS, NO means install DNS)

    ConfirmGC=Yes

    DomainNetbiosName=contoso

    AutoConfigDNS=yes

    SiteName=STL

    AllowAnonymousAccess=no

    DatabasePath=%systemroot%\ntds

    LogPath=%systemroot%\ntds

    SYSVOLPath=%systemroot%\sysvol

    SafeModeAdminPassword=<admin defined offline admin account password>

    CriticalReplicationOnly=No

    RebootOnSuccess=yes

     

    b.      Add new DC to existing forest/domain: 

    [DCINSTALL]

    ReplicaOrNewDomain=Replica

    CreateOrJoin=Join

    DNSOnNetwork=yes|no (Yes mean use existing DNS, NO means install DNS)

    ConfirmGC=Yes

    DomainNetbiosName=contoso

    AutoConfigDNS=yes

    SiteName=STL

    AllowAnonymousAccess=no

    DatabasePath=%systemroot%\ntds

    LogPath=%systemroot%\ntds

    SYSVOLPath=%systemroot%\sysvol

    SafeModeAdminPassword=<admin defined offline admin account password>

    CriticalReplicationOnly=No

    RebootOnSuccess=yes

      

    c.       Add new RODC to existing forest/domain:

    NOTE: Read-Only DC requires Windows Server 2003 Forest Functional Level or greater.

     [DCINSTALL]

    ReplicaOrNewDomain=ReadOnlyReplica

    ReplicatDomainDNSName="contoso.com"

    CreateOrJoin=Join

    DNSOnNetwork=yes

    InstallDNS=yes

    ConfirmGC=Yes

    SiteName=STL

    AllowAnonymousAccess=no

    DatabasePath=%systemroot%\ntds

    LogPath=%systemroot%\ntds

    SYSVOLPath=%systemroot%\sysvol

    SafeModeAdminPassword=<admin defined offline admin account password>

    CriticalReplicationOnly=Yes

    RebootOnSuccess=yes

      

    d.      Demote a domain controller: 

    [DCINSTALL]

    AdministratorPassword="<password>" - Password is removed after use.

    IgnoreIsLastDnsServerForZone=Yes

    IgnoreIsLastDCInDomainMismatch=Yes

    RebootOnSuccess=Yes

     

    Install and Configure File Server Roles

    The file server role is installed by default to provide administrative share support for management tools. To install additional file server features use the following procedure.

     

    1. To install file server role features
      1. For File Replication service, type:

           start /w ocsetup FRS-Infrastructure

      1. For Distributed File System service, type:

           start /w ocsetup DFSN-Server

    c.       For Distributed File System Replication, type:

    start /w ocsetup DFSR-Infrastructure-ServerEdition

    d.      For Network File System, type:

    start /w ocsetup ServerForNFS-Base

    Then type:

    start /w ocsetup ClientForNFS-Base

    e.      For Single Instance Store, type:

    start /w ocsetup SIS

     

    Optional Features 

    1. To install an optional feature
      1. At the command prompt, type: 

    start /w ocsetup featurename

     

    Where featurename is the name of a feature from the following list:

    ·  Failover Cluster: FailoverCluster-Core

    ·  Network Load Balancing: NetworkLoadBalancingHeadlessServer

    ·  Subsystem for UNIX-bases applications: SUA

    ·  Multipath IO: Microsoft-Windows-MultipathIO

    ·  Removable Storage Management: Microsoft-Windows-RemovableStorageManagementCore

    ·  Bitlocker Drive Encryption: BitLocker

    ·  Backup: WindowsServerBackup

    ·  Simple Network Management Protocol (SNMP): SNMP-SC

      

    Additional Resources

    Server Core Blog

     http://blogs.technet.com/server_core/ 

     

    Longhorn Server Product Site

     http://www.microsoft.com/windowsserver/longhorn/ 

     

    Command Line Reference A-Z:

     Http://go.microsoft.com/fwlink/?LinkId=20331

      

    Configuring DHCP with NetSH

    http://technet2.microsoft.com/WindowsServer/en/library/df9ecef3-7d85-49e6-a2aa-ff84a5bd3a391033.mspx?mfr=true

     

    DNSCMD.exe

      http://technet2.microsoft.com/WindowsServer/en/library/d652a163-279f-4047-b3e0-0c468a4d69f31033.mspx

      http://technet2.microsoft.com/WindowsServer/en/library/ed0e4eeb-34a5-420e-aa6a-961ae5fa0f291033.mspx?mfr=true

     

    Manage Resource Records (Console & DNSCMD)

     http://technet2.microsoft.com/WindowsServer/en/library/6432bae3-f734-48d2-9643-dfba56422a991033.mspx

     

     Resource Record Types

     http://technet2.microsoft.com/WindowsServer/en/library/7b005a9b-4397-4d94-a584-34c037e2457c1033.mspx

     

    Windows Management Instrumentation Command-line (WMIC)

     http://technet2.microsoft.com/WindowsServer/en/library/ea5d7f04-07e8-4b96-bda3-a2b2cc15391e1033.mspx?mfr=true

     

     AD DS Unattended Promotion

      http://support.microsoft.com/kb/223757/

     

  • HOWTO: TechNet Blogging with Windows Mobile

    The following was posted via Windows Mobile 5.0 using a Cingular 8525 with Pocket SharpMT...

    Several folks expressed interest in blogging on TechNet and MSDN blogs using Windows Mobile, so I thought I'd share what I've learned... The Windows Mobile application I use is called Pocket SharpMT. It supports tags, images, text formatting and a lot of other coolness that I haven't even looked at yet. Having a slide-out keyboard makes blogging with Pocket SharpMT on my 8525 a breeze. Until now, I had only posted a couple of test entries. So this is the first public test of my newfound freedom. Now that I'm mobile, I hope to pick up the pace. Perhaps I'll blog from airports, waiting rooms, coffee houses, restaurants or anywhere else I'm inclined/required to hang out...  

    WARNING: The urge to blog while in traffic may be a symptom of a more serious genetic disorder requiring professional assistance.

    HOWTO Section:

    First things first...

    Get the latest bits at (Thanks Randy!): http://www.randyrants.com/sharpmt/

    Here's what you'll need to do once you've installed Pocket SharpMT:

    1) Launch and click Tools | Options.

    2) Complete the following for TechNet blogs (CGI-BIN path is likely the same for MSDN blogs. Someone else will need to verify).

    Web server: blogs.technet.com

    CGI-BIN path: /metablog.ashx

    3) Provide your username and password.

    4) Click refresh and verify your blog is listed...

     The only thing I didn't like about Pocket SharpMT is the Software Input Panel (a.k.a. SIP) that pops out every time a text field is selected. Even setting the default device setting to NullKB didn't help. On most devices, this would be a plus, but with a slide-out keyboard it was annoying. After finding a hack, I noticed a handy little check-box labeled Auto-show SIP under Options. It was about then that I said "Gee, what do you suppose this does?" while smacking myself squarely on the forehead. In my enthusiasm over features, I had forgotten to RTFM. Those of us with slide-out keyboards haven't been left out after all!

    Happy blogging!

  • MOM 2005: Alert when a percentage of machines in a computer group fail to respond to ping requests.

    I was recently asked if it would be possible to generate an alert when a certain number of machines in a computer group become unreachable.  MOM already generates alerts when an agent fails to heartbeat and even notes when the heartbeat failure is accompanied by ping failures.  This is great to the owner of an individual system, but what if we're interested in something a bit more pandemic? 

    Terminal or web farm can have hundreds or even thousands of individual servers that are part of a larger collective. Failure of an individual machine wouldn't cause the average  person's blood pressure to go up.  On the other hand, how can we tell when a large number of systems within a web farm goes down without watching all those individual heartbeat alerts? 

    Approach

    Let use information that MOM already collects to avoid increasing network traffic or database size.  For our purposes, the information we need comes in the form of active Heartbeat failures that include ping failures.  We'll need to do a few things:

    1. Create a computer group containing machines to be monitored for ping failures,
    2. Create a script to monitor systems in your new group for ping failures,
    3. Create a rule to run your new script.

    1 - Create and Populate MOM Computer Groups

    If you already have a computer group in mind, great move on to step two.  If you don't have a computer group or you have one that has to be manually populated, open the MOM Administrator console and read on:

    a) From the Admin console, right-click Computer Groups and create a new computer group. 

    b) Pause to appreciate the welcome screen then click Next,

    c) Give your new computer group a meaningful name and description before clicking Next,

     Example: Terminal Server Farm A

    d) Pause once more to realize that laziness is indeed the mother of invention. 

    The next few pages offer several option to automate membership of your newly created computer group.  You can use manual inclusion/exclusion, name searches using filters, wild-cards and regular expressions or my personal favorite; formulas.

    e) Click next about 5 times until you come to the formulas page

    f) Select Specify a formula for this computer group, click Attribute and New. 

    g) Create a new attribute by using the controls to browse the local or a remote registry.  Select the key or value to be used to identify machines that could be used to identify systems that should belong in your new computer group. Really, it's that easy! 

    Tip: Do you have your own custom registry keys such as application service or server build markers?  You can add your own custom registry keys to be used during attribute discovery or use any other key or value that is unique to this particular collection of computers that belong in the new group.

    Example:

    HKLM\Software\XYZSoftware

    HKLM\System\CurrentControlSet\Services\MyCrashtasticCustomApplication

    For additional information on creating computer groups see Creating Computer Groups in the MOM  2005 Management Pack Developers Guide.

    2 - Create a script to monitor active ping failure for computer in a given computer group.

    MOM does a lot of the work for us... The number of systems within a computer group and anything we could possible want to know about the alerts is in the OnePoint database.  All we need is a little t-SQL and VBScript. 

    a) Locate the Scripts folder, right-click and choose New Script 

    b) Provide a name, description and language and click next.  In this case, I'm using VBScript...

    c) Insert your script and click next...

    The following is provided as an example: 

    '*************************************************************************************************
    '*percentFailed.vs 
    '*
    '* Written by: Scott W. Hinsley
    '* Date: 11/29/06
    '* 
    '* Requirements:
    '*
    '* - MOM 2005
    '* - Script Parameters:
    '* MOM_COMPUTER_GROUP_NAME
    '*  MOM Computer Group to be monitored for % ping failure.
    '* PERCENT_FAILED_THRESHOLD
    '*  Failure threshold expressed as a percentage of system in MOM_COMPUTER_GROUP at
    '*  which an alert should be generated.  Expressed in a range of 1 to 100.
    '* ONEPOINT_SERVER
    '*  Name of SQL Server hosting the OnePoint database. 
    '*
    '* Provided "AS IS" without warranty.
    '*
    '*************************************************************************************************

    Option Explicit
    On Error Resume Next

    Dim strMomComputerGroupName
    Dim strPercentFailedThreshold

    'Script Parameters
    strMomComputerGroupName = ScriptContext.Parameters.Get("MOM_COMPUTER_GROUP_NAME")
    strPercentFailedThreshold = ScriptContext.Parameters.Get("PERCENT_FAILED_THRESHOLD")
    strOnePointServer = ScriptContext.Parameters.Get("ONEPOINT_SERVER")

    ' Alert Constants

    CONST ALERT_DESCRIPTION_STRING = "'% does not respond %'"
    CONST ALERT_RESOLVED = 255
    CONST ALERT_INFORMATION = 20
    CONST ALERT_WARNING = 30
    CONST ALERT_ERRROR = 40
    CONST ALERT_CRITICALERROR = 50
    CONST ALERT_SERVICEUNAVAILABLE = 70

    'Database Constants

    CONST adOpenStatic = 3
    CONST adLockOptimistic = 3

    Dim strQuery
    Dim dblPercentFailed
    Dim strAlertDescription
    Dim strAlertName
    Dim strName
    Dim intLevel
    Dim strDescription

    'ADO variables
    Dim objConnection
    Dim objRecordSet

    'strQuery:  Contains query used to get MOM_COMPUTER_GROUP member count
    '      and the number of active heartbeat failures with ping
    '        failures. Used to form percentage to be compared with
    '         PERCENT_FAILED_THRESHOLD.
    '
    '     Consider making strQuery a stored procedure to enhance
    '  performance and code effeciency.

    strQuery = "DECLARE" & _
        " @vComputerGroupGUID NVARCHAR(39)," & _
        " @SearchString NVARCHAR(21)," & _
        " @vExcludeResolutionState NVARCHAR(3)," & _
        " @PingFailCount DECIMAL(4,0)," & _
        " @ComputersInGroup DECIMAL(4,0)," & _
        " @vComputerGroupName NVARCHAR(100)," & _
        " @PercentFailed DECIMAL(3,2)" & _
      " SET @vComputerGroupName = " & "'" & strMomComputerGroupName & "'" & _
      " SET @SearchString = " & ALERT_DESCRIPTION_STRING & _
      " SET @vExcludeResolutionState = " & ALERT_RESOLVED & _
      " SET @vComputerGroupGUID =" & _
         " (SELECT GUID" & _
       " FROM [OnePoint].[dbo].MSFT_ComputerGroup" & _
       " WHERE [OnePoint].[dbo].MSFT_ComputerGroup.Name = @vComputerGroupName)" & _
      " SET @PingFailCount =" & _
          " (SELECT COUNT([OnePoint].[dbo].[SDKAlertView].ComputerName) AS ActiveCount" & _
          " FROM [OnePoint].[dbo].[SDKAlertView]" & _
       " INNER JOIN [OnePoint].[dbo].[SDKComputerToComputerGroupView]" & _
        " ON [OnePoint].[dbo].[SDKAlertView].ComputerName =" & _
                    " [OnePoint].[dbo].[SDKComputerToComputerGroupView].ComputerName" & _
       " WHERE [OnePoint].[dbo].[SDKComputerToComputerGroupView].ComputerGroupGUID =" & _
        " @vComputerGroupGUID" & _
        " AND [OnePoint].[dbo].[SDKAlertView].Description LIKE @SearchString" & _
        " AND [OnePoint].[dbo].[SDKAlertView].ResolutionState <> @vExcludeResolutionState)" & _
      " SET @ComputersInGroup = (SELECT NumberOfComputers" & _
         " FROM [OnePoint].[dbo].[ComputerGroupView]" & _
         " WHERE ComputerGroupName = @vComputerGroupName)" & _
      " SET @PercentFailed = (SELECT @PingFailCount/@ComputersInGroup)*100" & _
      " SELECT @PercentFailed AS PercentFailed"

    'Creating the data connection...

    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordSet = CreateObject("ADODB.Recordset")

    'The following connection string demonstrates using a non-trusted SQL account.
    'Update credentials for your particular needs.

    objConnection.Open _
        "Provider=SQLOLEDB;Data Source=" & ONEPOINT_SERVER & ";" & _
            "Trusted_Connection=No;Initial Catalog=OnePoint;" & _
             "User ID=<ReadOnlySQLAccount>;Password=<password>;"

    objRecordSet.Open strQuery, objConnection, adOpenStatic, adLockOptimistic

    objRecordSet.MoveFirst

    dblPercentFailed = CDbl(objRecordSet.Fields.Item("PercentFailed"))

    'Compare value retrieved with strQuery with PERCENT_FAILED_THRESHOLD
    'Alert if PERCENT_FAILED_THRESHOLD is exceeded.
     
    If dblPercentFailed > strPercentFailedThreshold Then
     strAlertDescription = dblPercentFailed & "%" & " of systems in " & strMomComputerGroupName & _
        " failed to respond to ping attempts.  This is greater than the" & _
        " defined threshold of: " & strPercentFailedThreshold & "%"
     
     strAlertName = strMomComputerGroupName & ": Ping failure threshold exceeded."
     
     AlertRaise strAlertName, ALERT_CRITICALERROR, strAlertDescription

     Else
    End If

    'AlertRaise is Called if PERCENT_FAILED_THRESHOLD
    'exceded.

    Sub AlertRaise(strName, intLevel, strDescription)
      Dim objAlert
      Set objAlert = ScriptContext.CreateAlert()
      objAlert.Name = strName
      objAlert.AlertLevel = intLevel
      objAlert.Owner = "[unassigned]"
      objAlert.ResolutionState = 0
      objAlert.Description = strDescription
      ScriptContext.Submit(objAlert)
     
    End Sub

    '* End VBScript
    '*************************************************************************************************

    d) Add any necessary parameters to your script. In this case, I use the following parameters:

    MOM_COMPUTER_GROUP_NAME
    PERCENT_FAILED_THRESHOLD
    ONEPOINT_SERVER

    * See code comments for details.

    3 - Create a rule that will run the script on a scheduled interval.

    Find an appropriate spot for your new rule. You may want to create a new rule group... I'll leave that to you.

    a) Right-click Event Rules and select Alert or Respond to an Event.

    b) Select New | Timed Event | OK.  Configure an interval texceededhat is appropriate for your needs and click OK.

    c) Click Next until you come to the Reponses screen.  This is where you will put your script to work.

    d) On the reponses screen, select Add | Launch a script.

    e) ResponsesresponsesSelect your newly created script and and configure the required parameters.

    f) Last but not least, complete the company knowledge and provide a descriptive name for you new rule.

    Enjoy!

  • First day at Microsoft...

    This is my first blog entry ever!  It's fitting my first entry should be on my first day with Microsoft Consulting Services.  Too bad I blinked and 18 months have flown by!  It's been an amazing blur, full of incredible people, cool technology and endless possibility.  ...exactly the reasons I came to Microsoft.

    Officially I'm an infrastructure consultant.  I've spent a lot of time dedicated to directory services and messaging & collaboration.  The geek in me always wants to learn something new and different, so I've picked up quite a mixed bag of technologies and disciplines.  That said, this blog could go anywhere and everywhere...  AD, Exchange, LCS, MOM, scripting, SQL, Windows Mobile, Klingon or anything else that catches my interest.

     Stay tuned...


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker