03 March 2010

How do I – Filter SharePoint STSADM commands with Powershell?

One of the first things I do on any new SharePoint server is update the Powershell profile so that I can easily filterSTSADM commands.  As we all know, there are tons of commands in STSADM and the built in filtering to search for any given command is… well, wanting.
Powershell to the rescue.  Using Powershell, we can filter the -help output from STSADM to make things more searchable.  This is done as follows:
  1. Open Windows Explorer.
  2. Navigate to C:\Windows\System32\WindowsPowershell\v1.0\
  3. Open for edit (preferably in a plain text editor like Notepad, NOT Wordpad or Word),  the file named “Microsoft.PowerShell_profile.ps1”.
  4. Add the code block below.
  5. Save and exit.
  6. Open Powershell.
  7. Start using STSADMQ.
function global:stsadmq($filter)
  write-host -foreground "Green" "STSADM Commands matching $filter"
  stsadm -help where {$_ -like $filter}
You can now use the wild card filter to find the needed STSADM command that you’re searching for like this:

I hope STSADMQ saves you as much time as it has for me.


No comments:

Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.

SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...