Month: December 2010

Remote install of SharePoint 2010 prerequisites

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: Did you ever try installing SharePoint 2010 prerequisites remotely? If so, you would know by now that it is not easy. Essentially because of the Windows update packages in the prerequisites. It is a known issue that Wusa.exe cannot be invoked in a remote session. If you try to install SharePoint 2010 prerequisites remotely — either using PowerShell remoting or WMI — it fails with an error code 5. We cannot really claim to have a fully unattended SharePoint deployment process until we have a solution to the prerequisite install process. So, with that background, I started working on the script for remotely installing SharePoint 2010 prerequisites. In today’s post, I will show you how to do that. To achieve this, I used a combination of PsExec.exe and PowerShell remoting. Here are the prerequisites for this script to work. PowerShell remoting must be enabled the remote system where you are deploying SharePoint prerequisites. On the remote system, CredSSP must be enabled …

PowerShell to list / add / remove Windows roles & features remotely

Lot of my R & D work at home happens on a couple of physical systems and lot of virtual machines hosted on Hyper-V. One thing that I regularly do is to rebuild lot of these machines and in that process, I add/remove Windows OS features many times. One default setting I have on all my systems is PowerShell remoting. This helps me access any system from a central location to add / remove these Windows features. I have been using PowerShell remoting combined with Server Manager cmdlets in Windows Server 2008 R2. But, every time I want to enable/disable a feature, there is lot of typing. So, I ended up writing my own wrapper for doing this remotely using three functions or cmdlets — whatever you call it. These functions have been tested on Windows Server 2008 R2 and ServerCore R2 OS. ServerCore is a bit tricky though. We don’t have PowerShell enabled by default. So, we have to manually enable Windows PowerShell feature using OCSetup. Only then, we can use this script for …

Creating complex scheduled tasks using WMI Timer events and PowerEvents Module

A few weeks ago, I wrote about WMI Timer events using Win32_LocalTime and then mentioned how to work around the DayOfWeek issue. In today’s post, I will show you how to use WMI timer events to create complex scheduled tasks. As system administrators, you may have to create scheduled jobs for performing various sysadmin tasks. We generally use Task Scheduler for such jobs. However, using the regular OS task scheduler, there is no easy way to create a scheduled task that occurs — for example — every Thursday of every fourth week of a month in the third quarter of every year. As I mentioned in my earlier posts, this is one area where WMI timer events are quite useful.

However, the major drawback of Register-WMIEvent is that the event registration is alive only until the PowerShell consle window is open. So, for this task to execute, you must have the console window open at all times. This is because Register-WMIEvent creates only a temporary event consumer. So, how do we create a permanent …

Learn WMI Query Language using PowerShell

These posts in the form of an ebook now available Back in July, I started a series of articles on WMI query language. There has been lot of delay in finishing up the series and when I did finish it, there were several issues with my blog. I had to re-write last two parts of the series. So, lot of links you might have bookmarked may not be valid since the entire blog content went through a churn. So, I thought it will be good to publish one post with links to all articles in this series. So, here it is — all 10 parts of the series. 1. WMI query language – An introduction 2. WMI query language – Keywords and Operators 3. WMI query language – Data Queries: SELECT, FROM, and WHERE 4. WMI query language – Data Queries: Associators Of 5. WMI query language – Data Queries: References Of 6. WMI query language – Event Queries: Introduction 7. WMI query language – Event Queries: Syntax 8. WMI query language – Event Queries: …

WMI Query Language (WQL) – Schema Queries

These posts in the form of an ebook now available Here are the links to all articles in this series of posts on WQL. 1. WMI query language – An introduction 2. WMI query language – Keywords and Operators 3. WMI query language – Data Queries: SELECT, FROM, and WHERE 4. WMI query language – Data Queries: Associators Of 5. WMI query language – Data Queries: References Of 6. WMI query language – Event Queries: Introduction 7. WMI query language – Event Queries: Syntax 8. WMI query language – Event Queries: Intrinsic Events 9. WMI query language – Event Queries: Extrinsic Events 10. WMI query language – Schema queries (this post) In this last and final part of this series, we will look at how to use WQL for querying the WMI schema. Schema queries are used to retrieve class definitions (rather than class instances) and schema associations. In simple words, if you need to find out what type of information (this is what schema really means) a specific class holds, you use schema queries.Here is …

WMI Query Language (WQL) – Event Queries: Extrinsic Events

These posts in the form of an ebook now available Here are the links to all articles in this series of posts on WQL. 1. WMI query language – An introduction 2. WMI query language – Keywords and Operators 3. WMI query language – Data Queries: SELECT, FROM, and WHERE 4. WMI query language – Data Queries: Associators Of 5. WMI query language – Data Queries: References Of 6. WMI query language – Event Queries: Introduction 7. WMI query language – Event Queries: Syntax 8. WMI query language – Event Queries: Intrinsic Events 9. WMI query language – Event Queries: Extrinsic Events (this post) 10. WMI query language – Schema queries In this part of the WQL series, we shall look at extrinsic events. Extrinsic events represent events that do not directly link to standard WMI model. For example, Windows registry defines extrinsic events for all registry change events. For intrinsic events, having a WMI provider isn’t mandatory. This is mostly because they are defined within the standard WMI model and WMI takes care of these …