Month: September 2010

Blocking SharePoint 2010 installs on unauthorized computers

SharePoint 2010 provides the ability to lock down, track, and even block random installations of Microsoft SharePoint Server 2010. The SharePoint 2010 setup wizard is designed to check for a registry key on the local system and block the install. If you want to block unauthorized SharePoint 2010 installs in your organization, you can setup the following registry key on all unauthorized computers. HKLM\Software\Policies\Microsoft\Shared Tools\Web Server Extensions\14.0\ SharePoint\DisableInstall (DWORD): 1  This will ensure that setup.exe is blocked on the computer. You can use domain group policy to add this registry setting to all computers. If you want to do this using PowerShell, you will require Group Policy PowerShell cmdlets. The following steps will show you how to do that. 

The above commands will first import the Group Policy cmdlets and then use Set-GPRegistryValue cmdlet to include the new registry setting. Since we changed the default domain policy iteself, it will now apply to all the systems in the domain. Once this setting is applied, if you try to run SharePoint 2010 setup.exe, you will see a message as shown here. Now, there …

Waking up (bare metal) systems in S5 state

I have always wanted to use wake-on lan in my lab setup to start the systems in S5 sleep state. S5 sleep state is a power-off state where but some components remain powered so the computer can “wake” from input from the keyboard, clock, modem, LAN, or USB device. All my systems in lab are headless and the only option I have is to use wake-on lan. However, I could not really achieve this until today. I referred to quite a few documents and asked several people about this. But, none of these resources indicated that there is a “preboot wake on lan” option in the NIC bootstrap. If you use server hardware, you must have seen an option to bring up the NIC bootstrap & configuration screen by pressing CTRL+S (Broadcom) during system POST. On my server, it looks similar to what I have posted here. In the above screen, you need to change “Pre-boot Wake On LAN” to enable and press F4 to save the changes. This is it. You can wake up …

Adding header to newly created scripts in PowerShell ISE

Here is a simple function that you can use to add a script header everytime you create a new script file in PowerShell ISE. Jeff Hicks posted a function to create an addon menu option to do this. What I am showing here does not add any menu option. This function uses $psISE.CurrentPowerShellTab events and adds the header only to untitled files. 

How this one works is quite simple. We do an event subscription for the CollectionChanged event of $psISE.CurrentPowerShellTab object. Once we receive this event, we use the Add-Header function to insert the script header. While writing this, I found an issue (hopefully.!) with the ISE object model and I had to workaround that issue. The workaround I’d put is dirty but that is what I could find. Let me know if you have a better way to do this.  You can copy & paste this to your ISE profile and every time you open a new file, either using CTRL+N or File -> New, the script header as stored in $header gets inserted. This is how it …

WMI Query Language (WQL) – Data Queries: Associators Of

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 (this post) 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 As we saw in the previous post, Select queries can be used to retrieve instances of WMI class. But select queries are not the only way to query for instances. We can also use Associators Of keyword to the same. However, there is a difference. Select queries always return a collection of instances of a WMI class where as “Associators Of” returns a collection of …

Survey: Windows PowerShell training in India

I created a survey to understand how many of you (read as techies based out of India) would be interested in a formal Windows PowerShell training.There are many classroom or online training events that happen outside of India. I do not know or aware of any such event within India. I really want to understand how many of you would really pay for such a training and what mode of training you prefer. This does not mean that I am starting this training here in India. However, that is a possibility. 🙂 This is just a high level survey to understand the interest in this. Go ahead and take the survey and let me know if you have anything else to share using the comments box. I will keep the survey open for two weeks and then publish the responses.

Quick PowerShell Tip: Get Process commandline information

This morning I answered a quetion on TechNet Windows PowerShell forum regarding retrieving a process commandline arguments. You cannot do this using Get-Process cmdlet. I thought I should share it here as well. Let us look at an example. I started a PowerShell process by passing a .PS1 script name to it. For the sake of demo, this script just sleeps for a long time. I used Start-> Run option to run the following commandline   PowerShell.exe C:\scripts\Testravi.ps1    Get-Process has no commandline property to see the arguments I just sent to PowerShell.exe  However, Win32_Process WMI class provides the commandline arguments information. This calss has a property called CommandLine. So, we can use Get-WMIObject cmdlet to see the commandline arguments passed to PowerShell.exe. To do this,  

This will filter the process information for the PowerShell process and output the commandline property value.     

Managing Windows Deployment Services (WDS) using PowerShell – Part 1

I just can’t believe that I have not written anything here for a month. There were several things that happened last month and I did not really have any energy left to write some content here. There were several interesting things I learned and experimented. Now that I am done with quite a few things, I will start (hopefully.!) writing regularly.  I will also resume the WQL series shortly. I regularly use Windows Deployment Services (WDS) to deploy OS in my lab environment. I used WDSUtil.exe a bit to automate a few aspects of this work. However, WDSUtil spits out lot of text and using this for automation isn’t really good idea. I can use PowerShell to parse the output but it is not worth the effort. It is not easy to objectify the output of WDSUtil using PowerShell. There is a lot of flexibility in using objects than simple text. I strongly believe in “everything PowerShell” when it comes to automation. So, I started looking at Windows Deployment Server COM object model to see …