Where() method in powershell 4 breaks my objects!

Boe Prox wrote an excellent post on the new Where() and Foreach() methods in Powershell Version 4 over at his blog: http://learn-powershell.net/2013/11/26/checking-out-the-where-and-foreach-operators-in-powershell-v4/ I decided to play around with these a bit and discovered a behavior I didn’t expect. When using the Where() method instead of Where-Object, the output differ and I can no longer access and update my original object. This is because Where() always returns a collection of objects (even if it’s only a collection of one object).

PowerShell Tip: Gracefully close a process

Killing a process is easily done by using the cmdlet Stop-Process, but it has a tendency to stop those processes somewhat ungracefully. Lets take an example of using notepad.exe This script will start a new instance of notepad.exe, enters some important data and waits for three seconds: add-type -AssemblyName microsoft.VisualBasic add-type -AssemblyName System.Windows.Forms $Process = Start-Process notepad.exe -PassThru Start-Sleep -Milliseconds 500 [Microsoft.VisualBasic.Interaction]::AppActivate($Process.Id) [System.Windows.Forms.SendKeys]::SendWait("This is some some important data") Start-Sleep -Seconds 3 Now that we have a process with some unsaved data lets get to the point.

Subscriptions in SCOM 2007 automatically disabled

This post is all about an old and well known issue but I haven’t found any automated solution to it so I’d like to share mine. But first an introduction: When editing a subscription in System Center Operations Manager 2007 the subscription is tagged with the SID of the administrators user account. This is all good until the day that that account is removed from the SCOM administrators role. And maybe, if the administrator in question leaves the company, the account is even removed from Active Directory.

Use Powershell to merge XML

Let’s say that we have to XML documents each containing a list of books (I’m using the XML example file from this page since I’m too lazy to write my own) and we want to join them to one XML. File1.xml looks like this: <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> <book id="bk102"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.

Smart card stops working for RemoteApp after November updates

UPDATE: Microsoft just announced that they have temporarily removed the update. For more details see: KB2830477 KB2830477 was released Tuesday November 12 2013 and updates the RDP Client on Windows 7 to RDP 8.1. After installing it we have experienced issues with Smard Cards no longer being available in the remote session. Uninstalling KB2830477 solves the problem. So if smart card authentication suddenly stopped working on your windows 7 clients, check if you got KB2830477 installed.