DCSIMG
June 2008 - Posts - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

News


btn_donate_LG

View Shay Levy's profile on LinkedIn Follow Shay Levy at Twitter Shay Levy's Facebook profile Subscribe to my FriendFeed


site statistics




June 2008 - Posts

Do you know your aliases?

 

This little PowerShell script you can check how familiar you are with all the built-in aliases in PowerShell V2 CTP2.
For each alias there are 7 cmdlet names to choose from. There are 10 questions, and at the end of the quiz you can review your results and optionally run the quiz again.

You need to have PowerShell V2 CTP2 installed for the script to run.

Good luck :)

 

 

PowerShell at the tip of your browser

EDIT: Updated list of features can be found HERE 


I've created a PowerShell browser toolbar using Conduit community toolbars. It provides one-click access to many PowerShell related resources. Any changes I'll make to the toolbar will automatically be seen by users who installed it, no need to reinstall. The toolbar works on IE and also on any platform that Firefox runs on: Mac, Linux and Windows. If you want the toolbar to be available for both browsers, run setup on each one separately.

If what preventing you from installing it is your precious screen space, remember, you can always hide it.

If you feel I missed something or someone please leave a comment at the bottom of this page. The toolbar is still in progress and will be updated constantly. Here's how it looks:

 

(The image is sliced due to display width restrictions)

 toolbar1

 

You can access the toolbar (display it) on any windows explorer window, not necessarily Internet Explorer, Just go to View > Toolbars > PowerShell Toolbar

computer

  Options

Click the Toolbar Options menu arrow:


 main

In the Toolbar Options you can configure additional components to appear on your toolbar including Email notifier, add or remove buttons or gadgets like the Radio Player or add shortcuts to your favorite commonly-used applications.  

Notice that you can "Refresh Toolbar" for the last changes to appear.

 

Web Search

search

All web search is powered by Google. Besides the default "Search" entry I've added additional search providers to the bar. For example, the "Google Microsoft search" option allows you to search inside Microsoft related sites. There's also the option to search blogs with "Google blog search".

Here's how it looks when searching for PowerShell.
There is a button in the toolbar to highlight the search term inside the page.

 

highlightcopy12 
  
 highlightcopy3

  

Your search terms history can be viewed and cleared by clicking on the search arrow.

search14

 

 Blogs

Various PowerShell blogs. Drop me a line if you blog doesn't appear.

blogscopy9

 

Download

Need to download PowerShell? Get All PowerShell versions and requirement software.

downloadcopy3 

 

  Resources

resources

 

 Radio

Here you can define additional radio stations based on your location. Notice that you can listen to all PowerScripting Podcasts directly from the toolbar.

 radio5

 

 

Chat

The Chat button provides you with a way to communicate with all other users that use this toolbar. So, click Chat and choose a nick name to start chatting.

chatcopy3

 

Messages

The Message box allows communication with users in "real time" (15 min). I'll use this feature to send notifications when new content is added to the toolbar.

msg3
  

 

Weather

What's it like outside? Click the Weather button to see your local forecast. the Weather icon changes dynamically according to your current weather conditions.

This component automatically configures itself to your current location, according to your computer's IP. You ca also use this component to check out the weather in thousands of locations around the world.

weather4

 
 
IE Uninstall
  • Click Start, Settings, and go to Control Panel.
  • Locate the Add/Remove Programs.
  • Search for "PowerShell Toolbar".
  • Select Change/Remove.

    ieuninstall2

     

     Firefox Uninstall

  • Open the browser and select Tools from the menu.
  • Select Add-ons.
  • Select the Extensions tab.
  • Find the toolbar and select Uninstall.

    ffuninstall4

     


    The Community Toolbar has a Facebook group, so join in and share your ideas about the toolbar, suggest your own features etc. Most of the postings to the group will include toolbar notifications when new stuff is added or removed but feel free to start any discussion you think is relevant. Cheers.

    That's it. You're all invited to install and explore it. If you find it useful or having improvement suggestion, drop me a line. Click HERE to install the toolbar.

    ActiveXPoSH - PowerShell for VBScript/JScript


    SAPIEN Technologies has released a new COM component named ActiveXPoSH (included in PrimalScript 2007 script editor). It is a special PowerShell host that allow developers/scripters to run single cmdlets or entire scripts from VBScript/JScript code. The component is free for personal and commercial use.

    You can find more details in this document and download it from here.

    PowerShell Popcorn

     

    My son heard all the alien beeps and asked me for this one, the Popcorn tune. I couldn't say no :)

     

    1..2  | % {
        
        1..2 | % {900,800,900,700,550,700,450 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
        
        900,1000,1050,1000,1050,1000,1050,900,1000,900,1000,800,900,800,900 | % { [console]::beep($_,50); sleep -m 150}
        sleep -m 250
        
        1..2 | % {900,800,900,700,550,700,450 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
        
        900,1000,1050,1000,1050,1000,1050,900,1000,900,1000,800,900,1000,1050 | % { [console]::beep($_,50); sleep -m 150}
        sleep -m 250    
    
        1..2 | % {
            1..2 | % {1350,1250,1350,1050,800,1050,680 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
            1350,1500,1600,1500,1600,1500,1600,1350,1500,1350,1500,1200,1350,1200,1350 | % { [console]::beep($_,50); sleep -m 150}
            sleep -m 250
        }
    }

    Portable PowerShell

     

    Hallelujah! Get all the details on Karl Prosser [MVP] blog.

    Webcast: Managing Hyper-V Virtual Machines with WMI and Windows PowerShell

     

    Start Date: Wednesday, July 02, 2008 8:00 AM Pacific Time (US & Canada)

     

    Event Overview

    Before the beta release of Microsoft System Center Virtual Machine Manager 2008, there was only one option for automating management of Hyper-V virtual machines—Windows Management Instrumentation (WMI). In this webcast, you learn how to automate the most common management tasks, how to create a delegation model using Windows Authorization Manager, and where the power of WMI can pick up where Virtual Machine Manager leaves off. In addition, the Hewlett-Packard Windows Server 2008 Academy team shares their experience automating the deployment of 600 virtual machines in less than three hours using WMI and Windows PowerShell.

     
    Presenters: Dung Hoang Khac, Principal Consultant, HP, and Aric Bernard, Senior Technology Consultant, HP

     

    Register for the event.

    Listing enumeration type values (updated)

     

    The old function return duplicate names when the enumeration has two names with the same value, for example: 

     

    PS >  Get-EnumValues Microsoft.PowerShell.ExecutionPolicy
    
            Name Value
            ---- -----
    Unrestricted     0
    RemoteSigned     1
       AllSigned     2
      Restricted     3
      Restricted     3

     

    Here is the modified version of the function:

    function Get-EnumValues([type]$type){ 
       [enum]::getNames($type) | select @{n="Name";e={$_}},@{n="Value";e={$type::$_.value__}} | ft -auto
    }

     

    And the results:

    PS >  Get-EnumValues Microsoft.PowerShell.ExecutionPolicy
    
    Name         Value
    ----         -----
    Unrestricted     0
    RemoteSigned     1
    AllSigned        2
    Restricted       3
    Default          3
     
    -Shay

    Scripting Sysadmin meme

     

    In response to Steve's Scripting/Sysadmin Meme

     

    How old were you when you started programming?

    I was 27 when I started to write HTML/ASP pages.

     

    What was your first machine?

    My first real computer was Windows 95 PC. When I was 12 (I think), my uncle gave me a Texas Instruments (I can't remember the model name) but at that time I wasn't a computer geek.

     

    What was the first real script you wrote?

    Looping through ADO recordset and populating Active Server Pages (ASP).

     

    What scripting languages have you used?

    JavaScript/DHTML, VBScript/JScript.
    Now that PowerShell is out all other scripting languages are set aside.

     

    What was your first professional sysadmin gig?

    I started as a sysadmin in a government institution back in 1998 and I'm still holding that position (aside from one year in which I left and returned).

     

    If you knew then what you know now, would have started in IT?

    Yes. Ever since I have been in the field I have found that being in IT brings out the best in  me.

     

    If there is one thing you learned along the way that you would tell new sysadmins, what would it be?

    Learn to script! Knowing to script is your sysadmin added value, sorts of a 'super sysadmin' if you will. You'll be able to do magic when your boss wants something that the GUI can't provide.

     

    What’s the most fun you’ve ever had scripting?

    Every day that passes with Windows PowerShell scripting is a great deal of fun. I learn something new every day.

     

    Who am I calling out?

    Alexandair Nicolic, Rolf Masuch and Andy Schneider

    Close Encounters of the PowerShell Kind

     
    Five tones:

    $notes = 900,1000,800,400,600
    $duration = 400,400,400,400,1600
    0..($notes.length-1) | % {[console]::beep($notes[$_],$duration[$_]) }

     

    Spaceship Siren:

    1..10 | % { 370..470 | % { [console]::beep($_,5) }}

     

    Talking alien :)

    900,500,1000,800,400,600,1200,300,200,500,1100,300 | %{[console]::beep($_,100)}

     

    CTP2 Alien:

    1..20 | foreach { 
        
        $rnd = (Get-Random -min 0 -max 20)*100
        
        if($rnd -eq 0) {
            sleep -m 10
        } else {
            [console]::beep($rnd,100)
        }
    }

    CTP2 - Get Process/Service from remote computers

     

    One major change to the Get-Process/Get-Service cmdlets in CTP2 is the ability to get objects from remote computers via a new parameter, computerName (or -c for short). You can map process/service objects to their computer by the machineName member.

     

    PS > Get-Service s* -c computer1,computer2 | select name,machineName
    
    Name                  MachineName
    ----                  -----------
    sacsvr                computer2
    SamSs                 computer1
    SCardSvr              computer1
    Schedule              computer1
    seclogon              computer1
    SENS                  computer1
    ServeRAIDManagerAgent computer2
    (...)
    PS > Get-Process s* -c computer1,computer2 | select name,machineName
    
    Name          MachineName
    ----          -----------
    searchindexer computer1
    services      computer2
    services      computer1
    slp_srvreg    computer2
    smax4pnp      computer1
    smss          computer2
    smss          computer1
    snmp          computer2
    spoolsv       computer2
    spoolsv       computer1
    (...)

    Free eBook - TCP/IP Fundamentals for Microsoft Windows

     

    The eBook (4.7 MB PDF), from Microsoft, describes the fundamentals of TCP/IP in Windows Vista, Windows Server 2008, Windows XP, and Windows Server 2003.