PowerShell Team
Automating the world one-liner at a time…
Latest posts
Improving Parameter Set Design
Designing useable cmdlets is part engineering and part art. It’s not an easy task to define the conceptual boundaries of a cmdlet (where does one cmdlet end and the next begin) or to provide great feature control without inundating the user with parameters. However, you can improve the usability of your cmdlets by avoiding two common parameter set design flaws. Parameter sets with no mandatory parameters Some cmdlets, like Get-Process, can be run without any parameters, so you'd expect them to have at least one parameter set with no mandatory parameters. But look at the syntax of Get-WmiObject. The firs...
Using New-WebServiceProxy to get, modify, and add items to a list in SharePoint 2007
The motivation Let’s say that you want to retrieve and modify a list in a SharePoint site, but you don’t have access to Microsoft.SharePoint.dll. One possible solution is to try to search online or ask someone to let you copy the dll. If you are able to get a hold of it, you will quickly realize that the Microsoft.SharePoint.dll has some dependencies and that you are stuck again. Well, I will show you how you can get, modify and add items to a list in SharePoint using PowerShell V2. Pre requisites: First, you need a SharePoint site and credentials to modify that particular list. The illustration below shows...
Windows PowerShell 2.0 on Windows Update
Today, we released Windows PowerShell 2.0 and WinRM 2.0 for pre-Windows 7 operating systems on Windows Update. This non-security, optional update is designed for Windows Server 2008 SP2, Windows Vista SP2, Windows Server 2003 SP2, and Windows XP SP3. Windows PowerShell 2.0 and WinRM 2.0 are also available as part of the Windows Management Framework (WMF) Core Package on the Microsoft Download Center and Windows Server Update Services (WSUS). The WMF Core Package available on the Microsoft Download Center and the Windows Update release contain the same binaries of the product...
Specifying a View in TechNet and MSDN URIs
[This isn't only a PowerShell topic, but I've been asked a few times, so I thought I post the answer here.] If you've visited TechNet or MSDN lately, you'll notice that there are new view options for the pages. TechNet has a new ScriptFree view, in addition to the familiar Classic view. MSDN has two new views, ScriptFree and Lightweight. When you change your page view, your preference is saved and new pages that you open are shown in the saved view until you change your view again. If you are linking to a page, you can specify a view in the link. This allows you to determine how users see the linked page. For exa...
PowerShell Integration Into Visual Studio
Quest has released a beta of PowerGUI Visual Studio (aka PowerGUI VSX). Check out Kirk Munro’s blog entry HERE for more details. Check out this screenshot: I can’t wait to install it and kick the tires! Jeffrey Snover [MSFT] Distinguished Engineer Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
Kudos to NetApp for Data ONTAP PowerShell ToolKit
Kudos to NetApp for releasing the Data ONTAP PowerShell Toolkit last week at TechEd. I was monitoring the twitter feeds last week and saw a flurry of activity talking about NetApp’s broad adoption of PowerShell and release of the Data ONTAP PowerShell Toolkit surfacing all of their management functionality through cmdlets. I decided to investigate and headed to the NetApp booth where I saw an awesome, live automated, disaster recovery demo driven entirely by PowerShell. We’re talking automated failover to a remote site in less than three minutes using a combination of the NetApp cmdlets, cluster cmdlets and wha...
Export and Import PowerShell ISE Opened Files
Unlike other tools, PowerShell ISE doesn’t have project files. Project files are a good way to set your environment up with a well known state. Thanks to the ISE Object Model, it is possible to add some project functionality. The script below has two main functions “Export-ISEState” and “Import-ISEState”. They can be used to save files and PowerShellTabs and reopen them later. Even script contents for untitled files are saved. To save the current state (state = files and PowerShellTabs), use something like: Export-ISEState c:\temp\files.isexml To load the state la...
Save All PowerShell ISE files
PowerShell ISE is a simple tool and in some cases it has the bare essentials. For instance, it does not have an option to save all files. On the flipside, it offers an Object Model from its first version that allows adding features beyond the essentials like this one and many more. If we had the "Save All" option in the ISE, one interesting question is what to do about untitled files. They are supposed to be transient. One could argue that Save All could just skip untitled files. Another could argue that we should just pick a name for untitled, but I would disagree with "another" :-) Picking a na...
Renaming Tabs in the ISE
When you have multiple PowerShell tabs open in the ISE, it may be handy to rename them, so you can tell which is which. This is especially useful when using Remoting with Enter-PSSession. The problem when using Enter-PSSession is that you have no access to the root ISE object ($psise) when remoting, so you should use another (local) tab and enter the following: $psise.PowerShellTabs[0].DisplayName = 'myRemoteMachine' Needless to say, if you want to rename the second tab, you'd use PowerShellTabs[1] ... and so on To rename the current PowerShell tab, enter: $psise.Curren...