Categorized | Computers, Programming

STSADM.exe – Copy and Paste == Command Line Error

Posted on 28 July 2010 by Jason Grimme

stsadm.exe is a command driven application that I use very often to administrate a SharePoint server via command line.  More specifically, it is very heavily in a PowerShell script I wrote that deploys multiple solutions to SharePoint.

The general syntax for stsadm is stsadm -o createsiteinnewdb -url http://sharepointserver

More than often I will run into a problem where when I copy and paste these commands, stsadm says that it is invalid “Command line error“.  This can be very frustrating because the command looks correct in every sense.  Sometimes I even copy and paste from a known good command and I still get rejected.  If I type in the command, it works just fine.
So eventually I had enough and converted the copied and pasted string and the manually typed  string to binary to compare.

stsadm –o createsiteinnewdb

011100110111010001110011011000010110010001101101001000001001011001101111
001000000110001101110010011001010110000101110100011001010111001101101001
011101000110010101101001011011100110111001100101011101110110010001100010

stsadm -o createsiteinnewdb

011100110111010001110011011000010110010001101101001000000010110101101111
001000000110001101110010011001010110000101110100011001010111001101101001
011101000110010101101001011011100110111001100101011101110110010001100010

I highlighted the octet that is different in the two strings.  These bits represent the dash in the -o flag.  In the rejected string, the dash turned out to be an en-dash (&#8211) while in the accepted string, the dash is a hyphen (&#x2d).  In the text-editors I use, the en-dash and hyphen have no visual diference.  In most font-faces used by text editors (Courier-New) for example, the two are visually identical. Somewhere along the line, hypens are being converted to en-dashes.  I know word processors will do this automatically, but I am obviously not using a word processor.

I know this all sounds silly, but if you do some Googling you will find quite a few people who have experienced this problem specifically with stsadm.  So if stsadm rejects you like an ambitious nerd trying to pick up girls at the bar, check your dashes!

Tags | , ,

Leave a Reply

Security Code:

-->