SCCM - Options for Removing Windows Updates

November 21, 2013 FoxDeploy

Recently, a client had an issue with a particular patch to Office interfering with a line of business application.  The patch in particular was KB 2826026 - Office 2010 update: October 8, 2013.  Normally the procedure to uninstall a patch is to use Group Policy or SCCM to push out the following Windows Update Stand Alone tool command:

WUSA /uninstall /kb:2826026

However this only works with Windows Operating System Updates (which are deployed in the MSU format).  When dealing with a software product update like this one for Office, the correct answer is to look in the registry for information about the update.

Browse to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\, and then search for the KB number of the update you need to remove.  Once found, look at the Uninstall String, and you’ll see a value like this:

"C:\Program Files\Common Files\Microsoft Shared\OFFICE14\Oarpmany.exe" /removereleaseinpatch "{90140000-0011-0000-0000-0000000FF1CE}" "{D7D96A96-F61F-48AD-B2DC-4F4B6938D2AB}" "1033" "0"

This command will remove the offending patch, but requires manual intervention (clicking Yes) and then will force a restart.  You can use these values with an MSIexec command though to run the removal of the patch through Windows Installer, which will allow for logging and standard reboot controls, etc.

Use this example to help you create your MSI command:

msiexec /package {90140000-0011-0000-0000-0000000FF1CE} MSIPATCHREMOVE={D7D96A96-F61F-48AD-B2DC-4F4B6938D2AB} /qb /norestart /l+ c:\windows\system32\ccm\logs\KB2826026_unins.txt

This may force the shutdown of Office, and will not complete until the system has restarted, however.

Continue Reading...

Use PowerShell to quickly start a new Google Search

November 16, 2013 FoxDeploy

Hi guys,

In this two-part series, I’ll demonstrate how I created a quick little function to launch a new Google search from the command line using Powershell.  It started with me being annoyed that looking up the maximum RAM for my motherboard was a multistep process, first using **Get-WmiObject Win32_BaseBoard Select Product**  and then Googling it to see the max RAM.  I wanted to start a search right from the Powershell window!

To start off, I wanted to make a function accept infinite number of characters with spaces as an argument.  This became a problem as PowerShell uses spaces to delimit parameters, so I had to get a bit clever.  I didn’t want to have to create thirty or more parameters in my function header to accept all of the possible names.  I got around this by using the $args variable, which alongside the $input variable can be used to handle either Pipeline Input or the function being called itself with parameters.  Using $input leads to another problem–For here there be dragons!–the $input automatic variable is NOT an array, but rather a construct known as an enumerator.  That means two things:

  1. Unless you call its .Reset() Method, you can only access its value a single time.  One time use!
  2. You cannot use it in the Begin phase of your functions, only in the Process.

If you want to really learn about how weird these things are, check out these blogs posts here about them.

With all of that in mind, I instead created a structure in the script to detect if there are arguments present, and if not, set $args equal to the values in $input by means of classing $input as an array (this means throwing an @ sign at the front, and robing it in a nice warm pair of parentheses), and then running the .Split() Method on $args, to give us separate objects (necessary to build a URL).

The code reads the content of $args (which will be similar whether the function receives a parameter or pipeline input) and then for each object in $args, throws it onto a $query variable with a plus sign at the end of it.  In the last step of the code, $query is substringed to remove a dangling plus sign, and then committed to $url, which is then invoked using the Start command, to open in your browser of choice.

Here is the code.

`<# .Synopsis Searches the Googes .DESCRIPTION Lets you quickly start a search from within Powershell .EXAMPLE Search-Google Error code 5 --New google search results will open listing top entries for 'error code 5'` `.EXAMPLE search-google (gwmi win32_baseboard).Product maximum ram`

``If you need to get the maximum ram for your motherboard, you can even use this type of syntax #> function Search-Google { 
  Begin { 
      $query='https://www.google.com/search?q=' 
      } 
  Process { 
    if ($args.Count -eq 0) {
      "Args were empty, commiting `$input to `$args" 
      Set-Variable -Name args -Value (@($input) | % {$_}) 
      "Args now equals $args" $args = $args.Split() 
    }
    ELSE { 
      "Args had value, using them instead" 
    }

    Write-Host $args.Count, "Arguments detected" "Parsing out Arguments: $args" for ($i=0;$i -le $args.Count;$i++){ $args | % {"Arg $i `t $_ `t Length `t" + $_.Length, " characters"} }``

    $args | % {$query = $query + "$_+"}`

  } 
  End { 
    $url = $query.Substring(0,$query.Length-1) 
    "Final Search will be $url `nInvoking..." 
    start "$url" 
  } 
}

   And here is the result.

And a new browser tab was born…

 

In the end, you can use this to get the maximum RAM, just as I wanted to!

search-google (gwmi win32_baseboard select -expand Product) maximum ram

If you want to add this to your default Powershell window (and why wouldn’t you?), simply add it to your PowerShell Profile, which is launched every time you open the program.

Continue Reading...

Automating Google Maps & Traffic to determine when to drive to work using PowerShell

November 08, 2013 FoxDeploy

When I moved a while back, I wondered what the best route to take to work would be, and also when I should leave for work, but I didn’t know the area well enough to be certain.  I could go to Google Maps and put in my home address and work address and see what the current traffic time was, but this wouldn’t help me determine if I needed to leave at 7:45 or if I could eat another bagel and walk out the door at 8:00 and still make it to work on time (bagel carbohydrates notwithstanding).

So I did what I always do and turned to PowerShell to build a tool to do this.  I’d already used some PowerShell driven Internet Explorer automation to save me loading 100 URLs to see what the title was of each (to track down what the patch was doing for a particular KB Update Number), so I knew I could start there and work out a solution.

[IO.Directory]::CreateDirectory($Path) Out-Null
Continue Reading...

Continued: CREATING A GUI NATIVELY FOR YOUR POWERSHELL TOOLS USING .NET METHODS

October 30, 2013 FoxDeploy

When we left off, we had a nice fancy UI that didn't do anything! This session, we'll link our pinging code from before into our GUI, and then update the contents on the screen as part of the process. Once we're done with this, we'll experiment with some of the other controls available, and then customize things a bit more. Continue Reading...

Creating a GUI Natively for your PowerShell tools using System.Windows.Forms

October 23, 2013 FoxDeploy

The first post in the FoxDeploy GUI Creating series, this post is focused on making a GUI using Windows Forms! Continue Reading...

Solving 5447, MP has rejected a policy request because it was not approved.

October 21, 2013 FoxDeploy

You may see the error message like this from time to time:

 Component: SMS_MP_CONTROL_MANAGER

MP has rejected a policy request from GUID:XXXXX-XXXX-XXX-XXX-XXXXXXXXXXXXXX because it was not approved.

This really means that the client…is not approved.  This can happen for a few reasons, but namely one.  If you set SCCM to Manual Approval mode at some point, be it for testing or troubleshooting, any clients that attempted to be approved at that time are marked as Unapproved, pretty much until the end of time.  You have to find these systems and mark them as approved.

Continue Reading...

Microsoft MVP

Five time Microsoft MVP, and now I work for the mothership


Need Help?

Get help much faster on our new dedicated Subreddit!

depicts a crowd of people in a night club with colored lights and says 'join the foxdeploy subrreddit today'


Blog Series
series_sml_IntroToDsc
series_sml_PowerShellGUI series_sml_IntroToRaspberryPi Programming series_sml_IntroToWindows Remote Management Series The Logo for System Center Configuration Manager is displayed here Depicts a road sign saying 'Learning PowerShell Autocomplete'




Blog Stats