Windows PowerShell 1.0

Congratulations to the Microsoft team that had the nerve to undertake writing yet another command line shell and giving it some thought to make it useful.

I just tried it and here are my first impressions:

The hyphenated commands

This has to be the worst idea so far this century. I would strongly recommend using the CamelCase naming convention for commands. Just take a look where the hyphen key is
located on the keyboard! Here is an example of what I mean:

“GetItemProperty” instead of “Get-ItemProperty”

They are already using the CamelCase notation in the latter half of the command.

 The HELP system

So far I don’t find it to be very intuitive.

I would like to see something like the Unix/Linux ‘apropos’ or ‘man -K’ commands.

Let’s say I want to find out how to change the prompt.
    man prompt               # doesn’t work
   $prompt                      # doesn’t work
    Get-Alias prompt     # doesn’t work

Turns out that the word ‘prompt’ is a function which is considered a command and is discovered with Get-Command. So I type:
    Get-Command -name prompt    # only shows truncated version of the function definition.

Finally, after painstakingly reviewing the syntax for ‘Get-Command’, I decided to try the ‘syntax’ parameter:
    Get-Command -name prompt -syntax    # Finally shows me what I was looking for.

        ‘PS ‘ + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { ‘>>’ }) + ‘> ‘

I guess now would be a good time to mention that I started this quest because I wanted to get rid of the ‘PS’ at the beginning of my prompt.

I still haven’t figured out how to change the prompt from the command line. I also can’t seem to find the intial profile file that PowerShell uses but I did read somewhere that if I create profile.ps1 in ‘My Documents\WindowsPowerShell’ it will be executed on start up.

In the end, this is what I ended up doing to remove the ‘PS’ from the prompt.

     ” + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { ‘>>’ }) + ‘> ‘

Don’t know why I couldn’t just get rid of everything up to the first dollar sign.

Advertisements

11 comments so far

  1. Windows PowerShell on

    Blog Your Initial PowerShell Experiences

    Michael Fisher has just started using PowerShell and is blogging his impressions. You can see them at

  2. Jeffrey Snover on

    Thanks Michael!

    I blogged your blog on my blog. (Saying that a couple dozen times makes your mouth feel funny 🙂 )

    http://blogs.msdn.com/powershell/archive/2007/01/06/blog-your-initial-powershell-experiences.aspx

    http://blogs.msdn.com/powershell/default.aspx

    Thanks!

    Jeffrey Snover [MSFT]
    Windows PowerShell/MMC Architect
    Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

  3. Jeffrey Snover on

    OOps, the second blog entry should be:
    http://blogs.msdn.com/powershell/archive/2007/01/06/hyphens-in-command-names.aspx

    Jeffrey Snover [MSFT]
    Windows PowerShell/MMC Architect
    Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

  4. Keith Hill on

    After a while you’ll learn the aliases which really makes the commands terse e.g. ‘gp’ for Get-ItemProperty, gci for “Get-ChildItem”, gps for “Get-Process”, etc. Besides reaching for a hyphen is no more of a pain than % or $ or @. At least the hyphen doesn’t require the shift key. 🙂 Give it some more time. It is a complex shell but is very powerful and can allow you to do some amazing things if you stick with it. If you have questions, a lot of the PowerShell team members, MVPs and others answer questions on the newsgroup microsoft.public.windows.powershell.

  5. Keith Hill on

    Oh yeah, forgot to mention I belong to that hybrid club: software geek & dirt biker. I’ve currently got a KTM 250 XC and race the occasional motocross and enduro. I usually make it to one national a year (heh to watch) – Thunder Valley in Littleton (Denver).

  6. Claudio on

    Hi,

    Maybe you like the following prompt, put it in your profile:
    – You can see when you use PS in Admin modus.
    – It is counting your commands you can quickly use your commands again. By using r [number].
    type h for historylist.
    ————————————
    function Get-WhoAmI {
    $me = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    “UserSID= ” + $me.User + ” (” + $me.Name + “)”
    “AuthenticationType= ” + $me.AuthenticationType
    “ImpersonationLevel= ” + $me.ImpersonationLevel
    “Token= ” + $me.Token
    “Groups= ”
    foreach($Group in $me.Groups)
    {
    “`tGroupSID= ” + $Group + ” (” + $Group.Translate([System.Security.Principal.NTAccount]) + “)”
    }
    }

    function Get-IsLocalAdmin {
    ([System.Security.Principal.WindowsIdentity]::GetCurrent()).Groups -contains “S-1-5-32-544”
    }

    function prompt
    {
    if (Get-IsLocalAdmin) {
    $IsAdmin = “*”
    }
    $host.UI.RawUI.WindowTitle = “$IsAdmin$env:USERDOMAIN\$env:USERNAME$IsAdmin – Windows PowerShell”

    $history = @(get-history)
    if($history.Count -gt 0)
    {
    $lastItem = $history[$history.Count – 1]
    $lastId = $lastItem.Id
    }

    $nextCommand = $lastId + 1

    “`n$pwd`n$nextCommand> ”
    }

    New-Alias whoami Get-WhoAmI

    ————————————–

  7. Johan Johansson on

    Using a hyphen is difficult because of awkward placing? You’re joking, right? You really need to try use any command shell or do any programming on a swedish keyboard.

  8. […] Fisher has just started using PowerShell and is blogging his impressions.  You can see them at https://fastdad.wordpress.com/2007/01/05/windows-powershell-10/ .  10,000 thanks […]

    • fastdad on

      I made those observations 7 years ago. Since then I’ve retired and never had the opportunity to use PowerShell, sorry.

  9. Hyphens in Command Names on

    […] In my previous blog entry, I talked about how Michael Fisher had blogged his intial impressions about PowerShell. […]

    • fastdad on

      I made those observations 7 years ago. Since then I’ve retired and never had the opportunity to use PowerShell, sorry.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: