Trevor Sullivan's Tech Room

Minding the gap between administration and development

Posts Tagged ‘systems management’

PowerShell: Report / Check the Size of ConfigMgr Task Sequences

Posted by Trevor Sullivan on 2012/01/10


Introduction

In Microsoft System Center Configuration Manager 2007 operating system deployment (OSD), there is a limitation of 4MB for task sequence XML data. This is discussed in a couple of locations:

The Technet document linked to above says the following:

Extremely large task sequences can exceed the 4-MB limit for the task sequence file size. If this limit is exceeded, an error is generated.

Solution: To check the task sequence file size, export the task sequence to a known location and check the size of the resulting .xml file.

Basically, the Technet troubleshooting article is suggesting that you would need to go into the ConfigMgr console, right-click a task sequence, export it to a XML file, and then pull up the file properties. That’s fine for one-off troubleshooting, but what if you had 1000 task sequences and needed to know how large all of them were? Read on to find out how!

Read the rest of this entry »

Posted in configmgr, powershell, scripting, wmi | Tagged: , , , , , , , , , , , , , , , , | 2 Comments »

PowerShell: Disable ConfigMgr Task Sequence Countdown Notification

Posted by Trevor Sullivan on 2011/11/22


Introduction

If you are using Microsoft System Center Configuration Manager (SCCM / ConfigMgr) to deploy task sequences to ConfigMgr client systems, you may notice that by default, a countdown notification is shown as a balloon notification in the client’s system tray. In some cases, this functionality may be undesirable, and you may therefore wish to disable the balloon notification. Unfortunately, the task sequence properties GUI in the ConfigMgr console does not allow you to disable the notification, but you can do so via script.

The SMS_TaskSequencePackage class in the root\sms\site_lab (where “lab” is your three-digit ConfigMgr site code) WMI namespace represents each task sequence that has been created in a Configuration Manager hierarchy. The ProgramFlags property on this class contains a series of bitwise values (not sure if that’s the right term) which represent various options. In this case, we care about option 0x400 (1024 in base 10), which if enabled, disables the countdown timer.

image

PowerShell Code

The PowerShell code included below will allow you to specify a task sequence package ID that you would like to disable balloon notifications on. I suggest running the code inside of the PowerShell Integrated Scripting Editor (ISE).

Make sure you update your ConfigMgr server name (where the provider sits) and ConfigMgr site code before running it!

function Disable-ConfigMgrTaskSequenceNotification {
    param (
        [Parameter(Mandatory = $true)] $SccmServer
        , [Parameter(Mandatory = $true)] $SiteCode
        , [Parameter(Mandatory = $true)] $TaskSequenceID
    )
    
    try {
        # Retrieve the WMI instance that represents the intended task sequence package
        $TaskSequencePackage = [wmi]"\\$SccmServer\root\sms\site_$SiteCode`:SMS_TaskSequencePackage.PackageID='$TaskSequenceID'";
    }
    # If the WMI object does not exist, catch the error and deal with it ... somehow.
    catch [System.Management.Automation.RuntimeException] {
        Write-Host -Object ("A Windows Management Instrumentation error occurred.`n" + `
            "`n* Is the computer powered on?" + `
            "`n* Is a firewall blocking access to WMI?" + `
            "`n* Is the WMI service started on the remote system?");
    }
    
    # If the object handle was acquired from WMI, then go ahead and process it
    if ($TaskSequencePackage) {

        # Echo out the current ProgramFlags value
        Write-Verbose -Message ("Current program flags for {0} are {1}" `
                    -f $TaskSequencePackage.Name, $TaskSequencePackage.ProgramFlags);

        # If the notification disablement is not enabled (confusing, I know), then enable it.
        if (($TaskSequencePackage.ProgramFlags -band 0x400) -eq 0) {
            Write-Verbose -Message ("Disabling countdown for task sequence: {0}" -f $TaskSequencePackage.Name);
            
            # This is where the meat is: perform the binary XOR operation (same as adding 1024 in base 10) and set
            # the resulting value back to the ProgramFlags property. Remember that -bxor oscillates between on & off, so
            # that's why we have to perform the check in the if { ... } statement, prior to blindly switching it.
            $TaskSequencePackage.ProgramFlags = $TaskSequencePackage.ProgramFlags -bxor 0x400;
            
            # Commit the in-memory WMI instance back to the ConfigMgr provider
            $TaskSequencePackage.Put();
        }
    }
    # If a task sequence cannot be found with the appropriate ID, then notify the user.
    else {
        Write-Host `
            -Object ("Could not find task sequence with ID {0} in the {1} WMI namespace on {2}" `
            -f $TaskSequenceID, "root\sms\site_$SiteCode", $SccmServer)
    }
}

Clear-Host;
$SccmServer = 'sccm01.mydomain.com';
$SiteCode = 'LAB';
$TaskSequenceID = Read-Host -Prompt 'Please enter a task sequence ID to modify';

Disable-ConfigMgrTaskSequenceNotification `
    -SccmServer $SccmServer `
    -SiteCode $SiteCode `
    -TaskSequenceID $TaskSequenceID `
    -Verbose;

When you execute this script, you’ll be prompted for a task sequence ID, so make sure to have that handy.

image

Hope this helps!

Posted in configmgr, powershell, scripting, wmi | Tagged: , , , , , , , , , , , , , , | 1 Comment »

ConfigMgr 2012 RC Issues with CAS + Primary Hierarchy

Posted by Trevor Sullivan on 2011/11/18


I just got done setting up a ConfigMgr 2012 Release Candidate primary site beneath a Central Administration Site (CAS), and when firing up the console on the primary site, I’m getting the following message: “Your Configuration Manager console is in read-only mode while this site completes tasks related to maintenance mode. After these tasks are complete you must reconnect you Configuration Manager console before you can edit or create new objects.”

Here are a few facts about the hierarchy:

  • The CAS runs on Windows Server 2008 R2 SP1
  • The CAS points to a remote SQL 2008 SP1 Server on Windows Server 2008 R2 SP1
  • The Primary Site runs on Windows Server 2008 R2 SP1
  • The Primary Site points to a local SQL 2008 R2 SP1 instance (with KB2603910 installed)

image

After passing this message box, the following error would appear in the SmsAdminUI.log file:

[5, PID:3140][11/16/2011 20:28:22] :System.Management.ManagementException\r\nGeneric failure \r\n   at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
   at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
   at Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlQueryResultsObject.<GetEnumerator>d__0.MoveNext()\r\nManagementException details:
instance of SMS_ExtendedStatus
{
    Description = " Could not find property systemIsolationState";
    ErrorCode = 1078464256;
    File = "e:\\nts_sccm_release\\sms\\siteserver\\sdk_provider\\smsprov\\sspobjectquery.cpp";
    Line = 3900;
    Operation = "ExecQuery";
    ParameterInfo = "Select COUNT(*) FROM SMS_G_System_NAPCLIENT where systemIsolationState=0";
    ProviderName = "WinMgmt";
    StatusCode = 2147749889;
};

 

Obviously something was going on, because this same error was not happening on the CAS when I’d launch the console. We can see in this message that the property named systemIsolationState apparently does not exist in the SMS_G_System_NAPCLIENT WMI class in the root\sms\site_### namespace. Now that we know exactly what’s missing, it’s time to fire up the WMI Explorer and see if that property does or doesn’t exist.

image

As you can see, the property surely does not exist on the “001” site, which is the primary site beneath the CAS. Next, let’s check the CAS for this property.

Note: I’m not sure that this property is necessarily supposed to exist on the CAS, but it’s worth checking out anyway. It’s highly probable that it should exist on the CAS, because it’s a common inventory class for system resources.

Here’s a similar screenshot from the CAS.

image

Aha! It looks like the property does exist on the CAS. At this point, I’m suspecting that something failed during the installation of the primary site, so let’s head back over to the primary site and check out its ConfigMgr setup log (c:\ConfigMgrSetup.log). I saw this message repeating towards the end of the setup:

INFO: Still monitoring Replication initialization.    Configuration Manager Setup    11/16/2011 3:35:38 PM    1168 (0x0490)
INFO: Still monitoring Replication initialization.    Configuration Manager Setup    11/16/2011 3:44:38 PM    1168 (0x0490)
INFO: Still monitoring Replication initialization.    Configuration Manager Setup    11/16/2011 3:53:38 PM    1168 (0x0490)
INFO: Still monitoring Replication initialization.    Configuration Manager Setup    11/16/2011 4:02:38 PM    1168 (0x0490)

And finally, after a while, it finished:

INFO: Stopping component monitoring as stop signal received.    Configuration Manager Setup    11/16/2011 6:52:25 PM    3752 (0x0EA8)
INFO: Stopping server role monitoring as stop signal received.    Configuration Manager Setup    11/16/2011 6:52:26 PM    3836 (0x0EFC)
INFO: Stopping replication monitoring as stop signal received.    Configuration Manager Setup    11/16/2011 6:52:26 PM    1168 (0x0490)
<11-16-2011 18:52:27> *****************************************************         1/1/1601 12:00:00 AM    1992907627 (0x76C95B6B)
<11-16-2011 18:52:27> ***** Exiting ConfigMgr 2012 Setup Bootstrapper *****         1/1/1601 12:00:00 AM    1992907627 (0x76C95B6B)
<11-16-2011 18:52:27> *****************************************************         1/1/1601 12:00:00 AM    1992907627 (0x76C95B6B)

I’m a little confused at how it finished successfully, because there were some other errors in the log as well:

omGetServerRoleAvailabilityState could not read from the registry on sccm03.mybiz.loc; error = 5:
omGetServerRoleAvailabilityState could not read from the registry on sccm03.mybiz.loc; error = 5:

Also this showed up:

INFO: SDK Provider is on sccm03.mybiz.loc.    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
INFO: Retrieving current site control image…    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
INFO:  SQL Connection succeeded. Connection: SMS ACCESS, Type: Secure    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
INFO: Stored SQL Server computer certificate for Server [sccm01.mybiz.loc] successfully on [sccm03.mybiz.loc].    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:25 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:28 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:28 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:31 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:31 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:34 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:34 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:37 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:37 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:40 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:40 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:43 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:43 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:46 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:46 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:49 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:49 PM    1748 (0x06D4)
CSql Error: Cannot find type data, cannot get a connection.    Configuration Manager Setup    11/16/2011 8:56:52 PM    1748 (0x06D4)
ERROR:  SQL Connection failed. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:52 PM    1748 (0x06D4)
INFO: Registered type CCAR_DB_ACCESS for sccm01.mybiz.loc CM_CEN    Configuration Manager Setup    11/16/2011 8:56:55 PM    1748 (0x06D4)
INFO:  SQL Connection succeeded. Connection: CCAR_DB_ACCESS, Type: Unsecure    Configuration Manager Setup    11/16/2011 8:56:55 PM    1748 (0x06D4)
INFO: Read CAS SQL Server information, stored CAS SQL Server certificate and registered connection to its database.    Configuration Manager Setup    11/16/2011 8:56:55 PM    1748 (0x06D4)

Someone else posted this same message when trying to do a CAS + Primary Site configuration. Next step: reinstall the primary site.

After re-installing the primary site, the same issues returned. Finally I decided to just install a stand-alone primary site without a CAS.

Posted in configmgr, ConfigMgr vNext, fixes | Tagged: , , , , , , , , | 8 Comments »

ConfigMgr: You Receive Error 0x80070490 in a Capture Task Sequence

Posted by Trevor Sullivan on 2011/10/24


If you ever work with Operating System Deployment (OSD) in Microsoft’s System Center Configuration Manager (SCCM / ConfigMgr) 2007, you might build a task sequence that only performs an OS image capture (as opposed to an OS build & capture). You might think — logically — that you only need a single task sequence step to perform this action: a “Capture Operating System Image” step. Unfortunately, this isn’t the case. If you attempt to run a task sequence like this, you’ll probably receive a 0x80070490 error code, which means “element not found.”

image

Read the rest of this entry »

Posted in configmgr, OSD | Tagged: , , , , , , , , , , , | Leave a Comment »

Dell Updates Client Configuration Toolkit (CCTK)

Posted by Trevor Sullivan on 2011/08/01


Dell has just recently updated the Client Configuration Toolkit (CCTK). CCTK is a well-documented command-line tool that allows IT administrators to manage hardware-level settings via script / batch. It uses a Hardware API (HAPI) driver, which can be dynamically installed at runtime, to make changes to the system’s BIOS / UEFI firmware configuration.

Download the Dell CCTK 2.0.1

The new publish date for this updated software is 7/25/11, and it is version 2.0.1. I’ve included the changes from the release notes below:

DELL CLIENT CONFIGURATION TOOLKIT

Version 2.0.1
Release Notes

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

What’s New in This Release
————————–
* Support for new BIOS options, ‘optimus’ , ‘controlwwanradio’ and
  ‘controlwlanradio’. For more information run the following commands
  – cctk.exe -h –optimus
  – cctk.exe -h –controlwwanradio
  – cctk.exe -h –controlwlanradio

* Support for additional arguments in the BIOS option, ‘keyboardillumination’.
  For more information, run the below command
  – cctk.exe -h –keyboardillumination

* Packaging CCTK installation file as a Dell Update Package (DUP) to:
  – simplify upgrade and installation of CCTK  in one-to-many environments
  – return Dell standard installation codes to simplify scripting for mass
    distribution
 
********************************************************************************

Posted in tools | Tagged: , , , , , | Leave a Comment »

Extreme PowerShell / ConfigMgr: Extending Hardware Inventory

Posted by Trevor Sullivan on 2011/07/05


Introduction

In previous versions of Microsoft System Center Configuration Manager (ConfigMgr / SCCM), a common task for administrators, engineers, and consultants, was to extend the hardware inventory configuration. These inventory extensions were written in Managed Object Format (MOF) and allowed the SCCM client agents to report back a wider array of information to the central site database for reporting purposes, collection building, and other management tasks. Making changes to the configuration could be a tedious task, as MOF is not very forgiving, and rather quite strict, in its syntax.

In Microsoft Systems Management Server 2003 (SMS 2003), each time a configuration change was made, it was necessary to deploy the updated MOF file to the SMS clients — this made ensuring hardware inventory consistency across all clients a challenging task. In SCCM, Microsoft included changes to these MOF files (SMS_DEF.mof and Configuration.mof) as part of the machine policy refresh task, which is a client-side polling mechanism for configuration changes.

In SCCM 2012 Beta 2, Microsoft is taking it a step further and has eliminated the SMS_DEF.mof altogether, left the configuration.mof behind by itself, and stuck the WMI inventory configuration in … WMI. What is WMI? WMI stands for Windows Management Instrumentation, a service built into the Windows Operating System since Windows XP (and Windows 2000 Service Pack 4, I think). It provides a standard method of exposing hardware and software level system information to applications, such as storage, processor, memory, running processes, installed software, and other application configuration data. SCCM is built on top of this technology, and often makes developing software and scripts around the product much easier than it otherwise might be.

For the remainder of this article, we’re going to look at specifically how to extend hardware inventory in SCCM 2012 programmatically using Windows PowerShell with the SCCM WMI provider.

Read the rest of this entry »

Posted in .NET, configmgr, ConfigMgr vNext, powershell, scripting, tools, wmi | Tagged: , , , , , , , , , , , , , , , | 2 Comments »

ConfigMgr 2012 Beta 2: PXE Booting for OSD

Posted by Trevor Sullivan on 2011/06/28


I recently was trying to PXE bootstrap an operating system deployment (OSD) job from a ConfigMgr 2012 Beta 2 PXE server, and was getting this message in the smspxe.log on the SCCM primary site server:

PXE::CBootImageManager::FindMatchingArchitectureBootImage
Warning: Matching Processor Architetcure Boot Image (0) not found

Read the rest of this entry »

Posted in configmgr, ConfigMgr vNext, fixes, OSD | Tagged: , , , , , , , , , , , | 1 Comment »

PowerShell: Initiate Evaluation of ConfigMgr DCM Baselines

Posted by Trevor Sullivan on 2011/06/22


Introduction

Recently, I was working with Desired Configuration Management (DCM) in System Center Configuration Manager (SCCM / ConfigMgr) 2007 SP2 R3. During the development of configuration items (CIs) and baselines, it’s common to have to trigger baseline evaluations to ensure that the validation rules you’re writing are correct.

Read the rest of this entry »

Posted in configmgr, ConfigMgr vNext, powershell, scripting, tools, wmi | Tagged: , , , , , , , , , , , | Leave a Comment »

ConfigMgr: Report of VMware Guests Missing VMTools

Posted by Trevor Sullivan on 2011/06/20


I needed to get a report of server systems that are missing the VMware Tools installation. This is pretty easy to do with a subselect query in Microsoft’s System Center Configuration Manager (SCCM / ConfigMgr). Here is the query I put together for this purpose:

select
    [sys].[AD_Site_Name0]
    , [sys].[Name0]
    , [cs].[Manufacturer0]

from v_R_System [sys]

join v_GS_COMPUTER_SYSTEM [cs] on [sys].[ResourceID] = [cs].[ResourceID]

where
    [sys].[ResourceID] not in
    (
        select [sys].ResourceID

        from v_R_System [sys]

        join v_GS_SERVICE [svc] on [sys].[ResourceID] = [svc].[ResourceID]

        join v_GS_COMPUTER_SYSTEM [cs] on [sys].[ResourceID] = [cs].[ResourceID]

        where
            [svc].[Name0] = ‘vmtools’
    )
   
    and [cs].[Manufacturer0] = ‘VMware, Inc.’
    and [sys].[Client0] = 1

Posted in configmgr, ConfigMgr vNext | Tagged: , , , , , , , , , | Leave a Comment »

PowerShell: Disable CapsLock

Posted by Trevor Sullivan on 2010/10/13


Here’s a quick code snippet that shows how to disable CapsLock using PowerShell, combined with some embedded C# and .NET Interop (aka. P/Invoke.NET) code.

Credit goes to “BobS00327” for the C# code necessary to handle this.

function Set-CapsLock([switch]$Disable = $true)
{
    $CapsCtrl = @"
    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class CapsLockControl
    {
        [DllImport("user32.dll")]
            static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
        const int KEYEVENTF_EXTENDEDKEY = 0x1;
        const int KEYEVENTF_KEYUP = 0x2;

        public static void Main()
        {
            if (Control.IsKeyLocked(Keys.CapsLock))
            {
                keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr) 0);
                keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                    (UIntPtr) 0);
            }
        }
    }
"@

    if (-not [CapsLockControl]) {
        Add-Type $CapsCtrl -ReferencedAssemblies System.Windows.Forms
    }
    if ($Disable) {
        [CapsLockControl]::Main()
        Write-Host "Capslock has been disabled"
    }
}

Set-CapsLock -Disable

Posted in .NET, powershell, scripting, tools | Tagged: , , , , , , | 1 Comment »