Results 1 to 6 of 6
  1. #1
    Platinum Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    5,563
    Thanks
    50
    Thanked 9 Times in 8 Posts

    First look at Powershell

    I'm not certain at this point why, but I decided to take a look at PS. First I had to struggle to get it installed, which I did.

    Then I wanted to change the prompt and screen colors, because my vision couldn't cope with the tiny font. I THINK I got the colors fixed, and then I found a post about profiles and scripts, which seemed harmless enough, so I copied it:

    -----
    # Set Window Title
    $host.UI.RawUI.WindowTitle = "$ENV:USERNAME@$ENV:COMPUTERNAME - $(Get-Location)"

    # Set Prompt
    Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor Red
    Write-Host " :: " -NoNewline -ForegroundColor DarkGray
    Write-Host "$ENV:USERNAME@$ENV:COMPUTERNAME" -NoNewline -ForegroundColor Yellow
    Write-Host " :: " -NoNewline -ForegroundColor DarkGray
    Write-Host $(get-location) -ForegroundColor Green

    # Check for Administrator elevation
    $wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
    $prp=new-object System.Security.Principal.WindowsPrincipal($wid)
    $adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
    $IsAdmin=$prp.IsInRole($adm)
    if ($IsAdmin) {
    Write-Host "(admin) #" -NoNewline -ForegroundColor Gray
    return " "
    }
    else {
    Write-Host ">" -NoNewline -ForegroundColor Gray
    return " "
    }
    }
    -----

    Well, not only did it not set the prompt, but I now get an error:

    Windows PowerShell
    Copyright (C) 2012 Microsoft Corporation. All rights reserved.

    At C:\Users\CWBillow\Documents\WindowsPowerShell\Micr osoft.PowerShell_profile.ps1:24 char:2
    + }
    + ~
    Unexpected token '}' in expression or statement.
    + CategoryInfo : ParserError: ( [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

    PS C:\Users\CWBillow>

    I started out just wanting to remove the darn space after the prompt -- instead of c:\this is it I get c;\ this is it

    Small thing really, but I in my stupidity thought it would be pretty easy...sigh...

    Please:

    How do I get just a standard (dos) prompt like $p$g with no forced space, bright white text on dark blue...

    Regards,
    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator CLiNT's Avatar
    Join Date
    Dec 2009
    Location
    California & Arizona
    Posts
    5,317
    Thanks
    125
    Thanked 463 Times in 427 Posts
    What are you planning on doing in PowerShell, besides trying to make it look pretty?

    How to Reset the Looks of the Command Prompt or PowerShell Window
    DRIVE IMAGING
    Invest a little time and energy in a well thought out BACKUP regimen and you will have minimal down time, and headache.

    Windows 8.1, 64 bit
    Motherboard: DX58SO2*Chipset: X58 Express/Intel ICH10*BIOS: SOX5820J.86A.0888.2012.0129.2203*Processor: Intel Core i7 CPU X 990
    GPU: Nvidia GTX 580*Memory: Corsair 12 GB, 4x3@1600*PSU: Corsair HX1000*Hard drives: REVO X2 160GB*OCZ VERT X3 120GB*5 mechanical storage drives (12 TB) total.

  4. #3
    Platinum Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    5,563
    Thanks
    50
    Thanked 9 Times in 8 Posts
    Clint, I haven't the foggiest really. I have come across scenarios in the past that said "blah, blah, blah...and then in PowerShell...." I just had a minute, saw an article, and figured "Well, I'll just set it up so that if...." I've heard and read about it for years, so I just figured, "Why not?"

    It's 50/50 whether I'll ever truly need it. I am curious enough about it to want to know what it can do though.

    Thanks for the link...

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  5. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    20,286
    Thanks
    1
    Thanked 580 Times in 518 Posts
    There is all sorts of educational information, downloads, videos, etc. at Microsoft Script Center.

    I recommend you spend time there to get acquainted with PowerShell.

    Joe

  6. #5
    Platinum Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    5,563
    Thanks
    50
    Thanked 9 Times in 8 Posts
    Thanks Joe.

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  7. #6
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    784
    Thanks
    3
    Thanked 26 Times in 24 Posts
    Changing the screen colors and font size is easy. The PowerShell window is just a repurposed command prompt window so you can change the font/colors in the same way: access the window menu in the top left corner and select Propertties and then change the settings you want.

    Then to change the prompt, define a prompt function in profile.ps1. Here's mine - it puts the prompt character in a second line:

    Code:
    function prompt
    {
        Write-Host ("[PS " + $(get-location) +"]")
        return ">"
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •