STSADM and “command is invalid”

Hey folks,

I’ve seen this enough that it warranted blogging about it specifically. Here’s the deal…

Problem

When running an STSADM command in SharePoint, you get a result of command is invalid” following what you believe to be perfectly good syntax. And you know what, it might well be. But what you probably did is cut and pasted the command from a website somewhere. Yep, at 2am when you are busy troubleshooting, you found some comment or instruction in a web based blog or forum that instructed you to perform something. Rather than typing the command in yourself, you instead cut and pasted (why not, I do that all the time too ;).

The problem is, from the HTML page to your DOS prompt to the fussy STSADM command, the ASCII characters probably got skewed (you know what, it might not be ASCII, I don’t really know … or care, all I know is the “-” in the command is different or munged).

The Solution

It’s really simple. Don’t give up on your syntax and/or research. Simply augment your approach. You have two choices really:

Option 1: Don’t cut and paste (meh, I’m still going to do that, so on to Choice #2)

Option 2: After the cut and paste and running the command fails, simply go through the command syntax in the DOS/CMD prompt and replace all the extended characters like #$%& and particularly the dash “-” with a retype on your keyboard, replacing the non-valid characters with valid characters

  • Note: Usually it will bitch about the last entry in the STSADM syntax, such as -force which is often the last instruction you’ll give in many commands, such as “psconfig -cmd upgrade -inplace b2b -wait -force”