- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is what happens when you try to use Powershell for something that's clearly more suited to CMD
Admin
Thanks I been looking for these codes for a while. I'll copy them to my own processes.
Admin
The real WTF is that PowerShell commands manipulate objects, so formatting the output (which is an array of objects) to a string and then parse it, is useless and counter-productive
Admin
With SharePoint, the ugly was is often the only way. This is probably a gem, in the eyes of a SharePoint developer.
Admin
The real problem to fix is how this code got submitted to TDWTF in the first place.
Admin
Shut the fuck up
Admin
I think you already mostly described how this got written in the first place: Cow-orker didn't know how to do it, so googled, found some stuff on stackexchange (or maybe expert-sexchange), then crammed it all together till it works. This is what you get - especially the inappropriate variable names because he doesn't really understand what's going in.
It's like any Indian outsourcing result, except the 'till it works' rather than 'till it compiles' bit.
Admin
Admin
A broken clock is right twice a day. Just because they call it a day after it compiles doesn't necessarily mean it won't work.
Nitpick: Until abbreviates to 'til.
Admin
SPEnterpriseSearchCrawContentSource
? That sticks in my craw!Admin
("some output that is actually correct" is a High Fantasy novel term.)
Admin
https://www.merriam-webster.com/dictionary/till
Admin
I'm a longtime SharePoint guy who lived and worked through the advent of Powershell.
Pre-Powershell there were lots of SharePoint admin tasks that could be done (painfully) using the older CMD-based command line admin app(s) that produced only text output. The early days of Powershell and the SharePoint admin tooling to run under it were very, very poorly documented. And equally poorly understood. Which led to lots of folks using the new tools in the old way.
For whatever reason, SharePoint for both devs & IT admin has long been a cesspool of people who just barely know enough to do their jobs badly. Really grokking how to do things the right way and get the benefits the platform promised (and really is capable of) was/is pretty rare. So cargo-cult cut-and-paste is largely the only coin of the SharePoint realm. And that was before we even start talking about the widespread 3rd-world outsourcing that quickly followed SharePoint's rise in popularity with the enterprise crowd.
In many ways Microsoft's huge direction change with the 2013 & subsequent versions was/is an acknowledgement that they released something that the bulk of their customers simply lack the technical skills or capacity to use well. So ever since they've been steering everyone towards cloudy installations mostly managed by MSFT and using disconnected service-oriented client-side APIs so the devs' bad code can't crash the server infrastructure.
It's a huge exercise in moving their customers into a sandbox safe enough to contain their incompetence.
Admin
"Look, bash is ugly, but somehow, PowerShell manages to be even more ugly. It's almost impressive."
But in this case, the author is writing PowerShell in a bash-like way (treating everything as strings and doing string manipulation). If they were using PowerShell properly, they'd realise that the result of Get-SPEnterpriseSearchCrawlContentSource is an object, and they can just access the fields directly rather than formatting it in a table (using "ft"). I'd like to see bash do that!