header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left
Random Cmdlets
Get-ItemProperty
Retrieves the properties of a specified item.


Get-ResourceConfig
Use the Get-ResourceConfig cmdlet to get resource property schema from Active Directory.


Get-PEHeader
Gets the Portable Header information from an executable file.


Suspend-Queue
Use the Suspend-Queue cmdlet to stop outbound activities for a queue on a computer that has the Hub Transport server role or the Edge Transport server role installed.


Remove-MailboxDatabase
Use the Remove-MailboxDatabase cmdlet to delete a mailbox database object.


Remove-ContentFilterPhrase
Use the Remove-ContentFilterPhrase cmdlet to remove one or all custom words that the Content Filter agent processes.


Clear-ItemProperty
Deletes the value of a property but it does not delete the property.


Read-Host
Reads a line of input from the console.


Get-QADGroup
Retrieve all groups in a domain or container that match the specified conditions. Supported are both Active Directory Doman Services (AD DS) and Active Directory Lightweight Directory Services (AD LDS).


Set-PSDebug
Turns script debugging features on and off, sets the trace level and toggles strict mode.


  
Latest Scripts from PoshCode.org

egg_timer
A script I submitted for Event 10 of the Scripting games. Displays a simple Windows Form that counts down three minutes. It makes a good example for using Windows forms.

SnapReminder
Remind the users of their snapshots - for use in VMware, see this post for more details: http://www.virtu-al.net/2009/06/22/powercli-snapreminder/

LibrarySqlBackup
Standalone script adapted from SQL Server Powershell Extensions (sqlpsx) http://sqlpsx.codeplex.com. Defines SQL Server backup and restore functions.

Format-TablePlus
This is a wrapper function for Format-Table that adds a @-Width@ parameter, and a @-PadEnd@ parameter (without which it trims the end of every line of output. Set -PadEnd to get the original Format-Table behavior of adding needless whitespace on the end of every line of output.

Colorize Subversion SVN
Colorize STAT, UPDATE and DIFF (without params) commands output for Subversion (svn) and Mercurial (hg). Here's a PowerShell functions that you can use to make those numerous commands you run every day via the PowerShell CLI a little easier to read by adding colors. Autodetect for svn or hg. Update autodetect to work with psdrives that are a UNC path. Also now works with repositorys in the root directory of drive. Added $args to each function so you can do things like sd -r2 -rtip -U0

Get-DirSize
A v2.0 function to recursively get the sizes of all subdirectories under a root path.

vProfiles
vProfiles V1.1 By Alan Renouf http://virtu-al.net, copies vSwitches and PortGroups from one host to another.

Prevent-Screensaver
Simulate user activity to prevent desktop lock or screensaver for specified period of time

TabExpansion for V2CTP3
The most needless, useless and worthless Tabexpansion for powershell.exe(v2.0CTP3) in PoshCode. Update: # Parameter name (and command alias) expansion with Ctrl+E ls -f *.txt -r | ? { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -e OEM<Ctrl+E><tab>. <br> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -Exclude OEM<tab> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -Encoding OEM<tab> Get-ChildItem -Filter *.txt -Recurse | Where-Object { $_.LastWriteTime -lt "2009/5" } | Select-String powershell -ErrorAction OEM<tab><tab>...

TabExpansion
The most needless, useless and worthless Tabexpansion for powershell.exe(v1.0) in PoshCode. Please dot souce this script file to use. Update:. # WMI Namespaces expansion for Get-WmiObject gwmi -Namespace <tab>. Get-WmiObject -Namespace root\asp<tab>. # WMI Classes expansion which is corresponding to WMI Namespace (*) gwmi -Namespace ROOT\CIMV2\ms_409 -Class <tab>_<tab>. (*) it needs to remove old $PSHOME\WMIClasses.txt if it exists.
  
 

April 24th, 2009.

Idera, one of our sponsors has joined forces with Don Jones to create some super PowerShell videos that you can find HERE.  Best of all...  They are FREE!

Follow the link above for more information.  Don Jones covers the basics of PowerShell, using PowerShell and Active Directory, using PowerShell and Exchange 2007, using PowerShell and SQL Server 2008, and using PowerShell to manage servers and clients.

The Community has just taken a great leap in getting the word out about how cool PowerShell is!

Marco Shaw - Co-Community Director

Community News
New sponsor: Compellent

PowerShellCommunity.org has an exciting new sponsor: Compellent.  Just added to our sponsors page:

Compellent is a leading provider of enterprise-class network storage solutions...

Microsoft TechDays Defy All Challenges

On April 1st, 2009, Microsoft is putting on a free 24 hour virtual event covering developer-related topics.

There will be 95 live sessions provided via Live Meeting in the following tracks:
*Windows Development and Frameworks
*Windows Mobile Development
*Office...

Microsoft releases IIS7 PowerShell snapin

The full details are HERE.  Microsoft has just released a production version of a IIS snapin for managing IIS7 on Windows Server 2008.  This snapin is independent of any features shipping with Windows Server 2008 R2 (like PowerShell...

New Sharepoint and SQL forums

Due to recent interest in the forum, we've added two new discussion areas:

PowerShell Expert Panel at TechEd EMEA 2008

 We are extremely proud of the the job that Jonathan Medd (of the Get-Scripting Podcast) did at TechEd EMEA 2008 with a panel discussion which was made possible by support from PowerShellCommunity.org. You can find the video on

  
Recent Blog Entries
Jun 11

Written by: Karl Prosser
6/11/2008 9:23 PM

I've spend a lot of time in the past looking at the performance of PowerShell but have never gotten around to blogging about it. However it has become quite a hot button among MVPs and others in recent days and we've been busy testing and comparing the speeds different techniques in PowerShell in both V1 and V2.

In V1 there seems to be extreme slowdowns when invoking cmdlet, functions, any type of scriptblock and when using the pipeline. If you write a one liner that is easy to read, very elegant, but uses a lot of "powershelly" techniques its performance is often terrible, compared to it you write it out as a longer script using more traditional imperative style with "C"ish loops as the like. This brings up the whole concept of what is cheaper and more valuable - CPU cycles that keep getting cheaper, or human time in writing and maintaining code - dynamic languages and especially shells will definitely answer that programmer productivity is more valuable, and thus performance can come second.(read about it in the context of python here.) However 59 millisecond average to call an empty powershell function on a dual core machine is pushing this truth to an absurdity. PowerShell should as a language should NOT be slower than BASIC on my Commodore-64 - an 1MHZ 8 bit machine.

Here is some background of where we are coming from. Brandon Shell Started it all here. And after we spend hours running tests and bantering about the subject on the #powershell IRC room on freenode, Mow covered some cool stuff here.

Basically the results of my tests showed that new-object is very slow in V1, but calling any CMDLET, even a simple C# cmdlet with one line of code is extremely slow, and about 30 to 50 times slower than calling that SAME  line of code from powershell as a static method on a C# assembly. Additionally if you take that 50 times faster static method call, and wrap in it a simple powershell function, you loose all your spend gains and its even slower than calling the new-object CmdLet.

The great thing from Mows tests is that in V2 it seems that on the language side of things, scriptblocks,functions and the pipelines have spend up drastically (in the magnitude of about 2000% to 3000%. And cmdlet invocation has spend up also, but is about 6 times slower than just calling C# static methods. GO V2 GO V2 , but is it enough?

Given that V1 is going to be important for a long time, I think that powershell scripters need to still try to script in a "PowerShelly" way, but when they determine that something really has to be performant , they need to know what workarounds they can do in PowerShell to speed things up, understanding where the bottlenecks in PowerShell are.

But this post isn't about those performance solutions - I'm sure that we will cover a lot of them over the coming of the months. I want to RANT.

One of the reasons I think PowerShell has so many language quirks (and thus related gotchas when learning to do advanced stuff and solving bugs) is because it is Defined by Implementation instead of being Defined by Specification. To be honest, PowerShell is more of a platform , than a language or even a shell, and as it brings some new ideas and melds existing ideas in totally new ways, almost experimental ways, I don't think it could have been defined any other way. However its quirks and yes also its performance is a result of that. I believe it needs to be reviewed by traditional language designers and not be excused "because its a shell language". I believe that the importance of PowerShell is growing phenomenally and being part of Microsoft's common engineering requirement I strongly believe such close working with the CLR team should be done, and even if PowerShell is defined by Implementation and will likely be in version 2 also - SPEND THE TIME TO AT LEAST DEFINE THE SPECIFICATION, DOCUMENT THE INTENDED (and thus real) BEHAVIOUR, RELEASE A FULL GRAMMAR, RELEASE OFFICIAL XSD SCHEMAS of the XML ELEMENTS, and if specification is what defines it, and that specification is best represented in the automated unit tests - maybe , just maybe even release such tests  , as per other dynamic languages. I think some of this stuff should at least be done BEFORE V2 is released. I mean getting a V2 and not even having a V1 grammar. </end of rant>

Disclaimer:

Despite the above concerns, I love PowerShell, and the general performance doesn't bother me. Being able to code at the speed of thought, and do things with far less code than C#, and do things interactively and dynamically totally win out. PowerShell does introduce many new tangents on concepts and mash together some amazing things, its amazing they got it as right as they did the first time. I know if I had implemented such a platform/language it would be less consistent and probably slower than a ZX81. PowerShell V2, even though only in CTP2 already shows great performance enhancements.

If that disclaimer gave you the warm fuzzies, don't get too comfortable, i have another pet peeve to blog about, and that is the fallacy called "Restricted Runspaces" and how the lack of being able to truly sandbox PowerShell has me running in the direction of IronRuby - But that's for another day.

-Karl / Shell Tools

 

Tags:

Your name:
Title:
Comment:
Add Comment    Cancel  
  

PowerShellCommunity is sponsoring this year's Microsoft Technet Scripting Games, along with the new PoshCode.org. Submit your entry today!

right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer