PowerShell Team
Automating the world one-liner at a time…
Latest posts
Howto: Invoking cmdlets from within a cmdlet…
A fairly common question cmdlet developers have is "How do I invoke a cmdlet from within a cmdlet". This usually comes up when converting a script or function into a compiled cmdlet. Marco Shaw is writing a nice series of blog posts covering this topic using the PowerGadgets cmdlets as examples. Check it out at: http://marcoshaw.blogspot.com/2007/09/howto-invoking-cmdlets-within-cmdlet.html (As an aside - we're doing a bunch of stuff in V2 that will make this scenario both easier and more effective. It's pretty cool! We'll be releasing the details on this and other V2 features in Novemb...
Get-WmiHelp & Search-WmiHelp
Both PowerShell and Windows Management Instrumentation (WMI) are pretty incredible technologies that can do a lot of amazing things, but we're all human, and keeping an encyclopedic mental reference of all of these amazing things would give Good Will Hunting a headache. For years, when I used WMI I almost always had a browser open to MSDN to help me figure out and remember the little details of a class in WMI, and, for all of the desktop clutter, it never bothered me... until I started using Powershell and had Get-Help and Get-Command. These two cmdlets rocked my world.&nb...
Outputting vs. Emitting Objects
Sunil wrote: Hello, Firstly i am sorry to post an unrelated question to this post. However i dont know where to post my questions. Here is my questionSay I have 2 cmdlet'sGet-locationGet-serviceWhen I create a test.ps1 file out of these 2 command and then run it, it will always do a Get-service |fl in the outputIe. A full listing of the second command. Is there a way we can avoid this? thanks, As a general rule, the best place to ask questions is the PowerShell Newsgroup: Microsoft.Public.Windows.PowerShell What you are seeing with your script is that your script does not PRINT ("OUTPUT to the HOST") the LOCATI...
Documentation One Liner
I'm constantly amazed and delighted by what people are able to do with a single line of PowerShell. The System Center Virtual Machine Manager (SCVMM) team just released a PowerShell Cmdlet Reference HERE. That is cool – it allows anyone to go take a look at their Cmdlets to either get a better idea for what SCVMM does (or how it does it) or to learn from how they did their cmdlets. I encourage everyone that ships cmdlets to do something similar. That might seem like a big ask until you look at how they produced their documentation: Get-Command -PSSnapin VirtualMachineManagerSnapin | Sort-Object Noun, Verb | ...
Impersonation and Hosting PowerShell
Some of you reported that Impersonation doesn’t work while hosting PowerShell in ASP.net applications. The problem occurs when PowerShell's pipeline is invoked in the following way from an ASP.NET application: WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity; WindowsImpersonationContext ctx = null; try { &...
Controlling WinDbg with PowerShell
Roberto Farah runs a Debugging Toolbox blog and recently got turned onto PowerShell. He has now written a set of PowerShell functions (PowerDbg Library) which allows PowerShell to control WinDbg. The effect is (almost) the same as if WinDbg had embedded PowerShell as its own scripting language. Roberto considered a couple approaches before deciding to leverage the WScript.Shell com object and the SendKeys method to get the job done. (Note to self – learn more about what things can be done with this approach.). One note on style/naming. Roberto's functions put his library name at the beginning of the nam...
Interview with TechTarget
I recently did an interview with TechTarget here: http://searchwinit.techtarget.com/originalContent/0,289142,sid1_gci1270125,00.html BTW – it was a relatively long interview and the discussion got digested into the article. It is completely accurate but either I misunderstood one question or the digesting process changed the meaning of one conversation slightly. Christina and I talked about "application vendors jumping on board". I interpreted this as "NEW" application vendors and hinted about some behind the scenes discussions I've been having. I should have talked about all the great application vendors t...
New and Improved Cmdlet Help Editor Tool
The latest version of the Cmdlet Help Editor has been posted on the same link. It contains a few fixes. I recommend you all upgrade to this version: http://www.wassimfayed.com/PowerShell/CmdletHelpEditor.zip Please let me know if you have any specific questions. Wassim Fayed[MSFT]
Export-Demo
A while ago I wrote a script START-DEMO which I use to give demos (You can get the latest/greatest copy HERE. ) This script is also a great teaching tool. You can create your own demo.txt file with commands and explanations and then people can run it using Start-Demo. The great things about this are: Our test manager Michael Naixin Li asked me about how this related to the examples we have in our help system. In response, I wrote the script Export-Demo.ps1 (code below). This script takes one or more help topics and extracts the EXAMPLEs to create a stream of text which can be saved and run as a demo.txt fil...