Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

Comment Re:PowerShell is yucky yucky yucky! (Score 2) 265

Because some of the tools-- rm, mv, ls-- use a "take 2 letters from the word, thats the command" convention, while others are completely different (tar, unzip, gunzip, passwd, man). Theres no common convention whereby you could say"I want to do X" and know what the command is off-hand.

To the uninitiated, there is no particular reason to think "mv" would be the move command; you have to already know that.

Comment Re:Know Microsoft, Know Pain (Score 1) 265

Massive, heterogeneous, "Enterprisey" deployments benefit from far more complete tools than fucking PowerShell,

I mean its not like PowerCLI is a thing required for the creation of AutoDeploy profiles for VMware, or like thats a major feature for using stateless hosts on datacenter-scale clusters. Its not like Storage arrays commonly require SSH to configure, but offer powershell as an alternative.

Reading your post, I get the impression that you think that network switches, routers, and SANs are configurable via some webpage. I can promise you, when that is the case, its an awful experience. Generally "enterprisey" admins are sticking to CLI for those things because CLI reduces the chance of screwups: you can stage and review your change in notepad and then deploy it to hundreds of clients.

Comment Re:I'll bite (Score 5, Informative) 265

The bloody verbosity of the platform (it really is a platform - not a language) was the worst part

A few things-- the language has a large number of shortcuts, like "fl" instead of "format-list" or "?" instead of "where-object" or "%" instead of "foreach". But the verbosity of it is not really a bad thing, as it makes the resulting code at least somewhat self-documenting; its crystal clear what each command will do most of the time.

An IDE was necessary so you could scroll through the list of available functions to find the one you were looking for as they were generally not that obvious

This is what tab-completion or get-member or even "get-help [command] -examples" is for.

A quick for loop to rename files? Definitely bash. Holy cow is that a pain in Powershell.

$date = get-date -format yyyyMMdd
get-childitem -filter *.txt | foreach {rename-item $_.fullname "$date_$($_.name)"}

Really not that painful.

You mention usefulness- the usefulness as you said is that its a platform supported by an incredible number of vendors. Just about every piece of infrastructure I've come across has vendor-provided powershell integration; the ability to take output from a get-VM command and pass it into a storage provisioning command makes a number of tasks incredibly easy.

Lastly, I would say: man pages.

get-help is your friend, and is far superior to man with the -detailed or -examples switches. Not sure where you're getting the "1.7GB", but this page indicates that the size is more like 9KB.

Comment Re:I'll bite (Score 1) 265

An MMC would not allow you to use a text-field to search for a user, press a button, and have a new VDI instance spun up, storage provisioned, and permissions configured.

A more common use case would be what I described, but without the GUI, repeated 100 times for 100 different users.

Comment Re:I'll bite (Score 5, Informative) 265

The nix shells I have used are very powerful, but also very, very painful to learn. Learning sed / awk syntax could easily fill 4 of those 8 hours I mentioned; and thats not even getting into how each and every tool has its own unique idea of how to do syntax. What does a -z switch specify? I dont know, probably fire up that man page and dig through it. What about -h? Is that help, or human readable?

it really just feels like a kludged attempt to bring CMD.exe to something closer to bash.

Theyre not even remotely close. They both operate on the idea that data should be passable between consecutive commands via a pipeline, but bash makes no attempt to deal with different types of data nor any good way to determine what data is incoming. Powershell solves this by being object oriented, and letting you easily determine the type of data coming in, export it to XML, and reimport it at a later session if desired.

As an example-- if you have an error in bash, whats the stack trace look like? Do you have a good way of capturing it? In powershell you can reference the $error[0] variable, and pull up any piece of info you might need to troubleshoot, or even just export the whole thing by "$error | export-cliXML -file C:\somefile.xml" if you're running a nightly job; any issues can later be imported into a new session to diagnose.

Now the question becomes just because you can use it, does it mean you should?

Yes. If you deal with IT infrastructure at all, you would be absolutely crazy not to learn it; its explicitly supported (with native commands) by:

  * ALL of the major virtual infrastructure providers (VMWare, HyperV, Xen
  * All versions of windows
  * A great many storage providers (EMC, NetApp, probably others)
  * A number of network infrastructure providers
  * IIS, and Exchange -- like it or not these are huge players
  * And anything else you want to add support for yourself-- I note that Hadoop for example has community support for powershell

By support, I dont mean in the sense that you could use bash to launch SSH to manage these things. I mean in the sense that VMWare allows you to run the following native powershell commands:
      Connect-VIServer myVMCluster
      Get-VM | Where-object {$_.powerState -eq "PoweredOn"} | foreach { stop-VM $_}

And all of your VMs will be shut off. Trying to do something like that in bash is doable, it just requires screwing around with scripted SSH access to the VMhosts which is painful, for anyone who has done it.

I much prefer being able to see /etc/fstab than working with some nebulous class with functions that barely make sense.

This is a criticism of object-oriented languages, not powershell. You might as well rail against .Net, or Java, or C++.

Comment Re:PowerShell is yucky yucky yucky! (Score 1) 265

Its an eyesore if your idea of a pretty scripting language is one that uses unconventional naming schemes and arbitrarily picked switches that require a man page to explain, sure. The beauty of powershell is you can do tasks you've never done before simply using tab-completion, relying on the parameter names to describe what they do.

Powershell is good for the same reason that this:
public String getFirstThreeCustomers (String[] customerList) {
    final int NUMBER_OF_CUSTOMERS = 3;
    String outputText;
    for (int i = 1; i NUMBER_OF_CUSTOMERS; i++) {
        outputText = outputText + customerList[i-1];
    }
    return outputText;
}

Is better code than this:
public String gfc (String[] i) {
      return i[0] + i[1] + i[2];
}

Both do the same thing, one is short but not really clear what its used for, the other is explicit and flexible, but wordy.

Comment Re:PowerShell is yucky yucky yucky! (Score 4, Interesting) 265

Then there is some stupid security setting I remember always running into whenever I want to use it.

This makes it sound like you havent done really any research or significant work with powershell other than running one-liners when you need to do something that cant be done in GUI (like deal with Exchange certificates). When thats your exposure, yes, it looks clunky, but thats also ignorance speaking.

The command you want to do to get rid of that prompt is (as administrator) "Set-executionpolicy -Scope MachinePolicy -ExecutionPolicy bypass"-- this sets it forever.

Powershell looks "ugly" because it aims for clarity, not brevity. Commands are explicit in what they do, such that anyone even with no powershell experience could look at most powershell scripts and get a pretty good idea of whats happening; consider a common one-liner below:
        Get-ADUser -Filter {Surname -eq "Smith"} | Foreach { Add-ADGroupMember -identity "Domain Admins" -member $_ }

The commands are wordy, but they explain exactly what they do, and each of the parameters are self-describing; you dont need to look at something like "tar -xvzf someFile" and say "gosh, what does the z switch do again".

Comment Re:I'll bite (Score 4, Insightful) 265

Have you ever seen init scripts? Theyre way more painful to deal with than anything powershell ever is.

The reason they have an IDE for it is because you can use it to do incredibly complex things, like design GUIs that tie in administration elements from Active Directory, SANs, switch configuration, virtual infrastructure configuration and deployment, and computer administration-- all in one language with a common syntax.

Doing something like that would be a nightmare in bash. It sounds like you havent used powershell, which is a pretty good reason not to comment on it.

Comment Re:I'll bite (Score 4, Informative) 265

It sounds like you dont use it often, which is hardly a good reason to knock it. But I can offer a few tips:

1) Remember that just about everything is an object, with one or more attributes and methods. Even strings are objects, and can use methods such as ".equals(System.obj)". Get-Member is your friend for determining what methods and attributes apply:
        "This is a string" | get-member

2) All (properly made) commands take the form of [verb]-[noun]:
        get-member
        set-ADUser
        remove-item
        get-help

3) When iterating over a group using "foreach" or "where-object", the special variable $_ is used as a placeholder for the current element:
        @("arrayIndex1", "arrayIndex2") | foreach { write-host $_ }
        @("RedFish", "BlueFish", "BlueBird") | where-object {$_ -like "blue*"}

4) When in doubt, use one of the following:
        Get-Help [command]
        Get-Command
        $variable | get-member
        $variable | format-list *

Im of the opinion that it takes all of about 8 hours to learn to do the majority of things you would want to do in powershell (partly because thats about how long it took me). You just have to take some time to sit down and learn it, and then make an effort to use it instead of GUI administration tools. It is far, far superior to old windows command prompt and vbs,

Slashdot Top Deals

You knew the job was dangerous when you took it, Fred. -- Superchicken

Working...