Month: April 2011

Graphical User Interface (GUI) for your PowerShell scripts: survey results

Last week, around the same time, I decided to a small survey on why scripters would choose to create UI for their PowerShell scripts and what do they use to create a UI. With that thought, I created a simple survey with just three questions and shared with you all twitter. This survey received 34 responses. I think this response is good enough to understand the major reasons for creating GUI for PowerShell scripts. Note: This survey was purely around what UI framework do people use to create UI for the PowerShell scripts and not about what tools they use. I included PrimalForms and Visual Studio only because they facilitate easier creation of UI. PowerGUI AdminConsole fits perfectly into the options if I were to do a survey on the tools you use to create GUI apps to wrap PowerShell scripts. Thanks to all who answered this survey. So, with no further delay, here are the results: Do you create GUI for any of your PowerShell Scripts? What are some of the reasons for creating UI for PowerShell scripts? …

Find all Hyper-V hosts and windows virtual machines in your AD environment

Several Microsoft products use Service Connection Points (SCP) to advertise themselves using objects stored in Active Directory. Clients query the directory to locate services. Microsoft Hyper-V, as I mentioned, also registers or publishes its information in AD as a service connection point. Now, we can use ADSI or AD cmdlets or Quest AD cmdlets to retrieve this information. To retrieve a list of all “Hyper-V hosts” in the AD environment, Using ADSI

Using Microsoft AD cmdlets

Using Quest AD cmdlets

The above methods retrieve the name of the computers running Hyper-V role. To retrieve a list of all “Windows Virtual Machines” in the AD environment, Using ADSI

Using Microsoft AD cmdlets

Using Quest AD cmdlets

This is it! If you observe the above code, I just changed the Name property alone to either “Microsoft Hyper-V” or “Windows Virtual Machine”. I tested the above commands only on Windows Server 2008 R2 and Windows Virtual machines only. I am not sure if Linux or other virtual machines running on Hyper-V get …

Creating SQL snapshots using SMO and PowerShell

First of all, I am not SQL guy. I work on SharePoint quite a bit and venturing into SQL now. So, the first thing is to learn how I can script my SQL management tasks. I know there are quite a few things on the Internet but exploring all this myself gives an opportunity to learn how SQL works. This post is about how we can use SQL Management Objects and PowerShell to create database snapshots. Make a note, I did not mention T-SQL. I am not sure if someone else already a wrote post around this or not. But, this is just the way I learned to do it. Do let me know if you know a better way or done it earlier. With no further delay, here is the script.

I have enough inline comments in the above code to explain what it is doing. Remember, you need SQL Enterprise edition to use DB snapshots. This is it. I am off to exploring how I can revert a snapshot without using T-SQL …