Saturday, June 21, 2008

Generating TinyURLs from PowerShell

 

TinyURL is a web service that provides short aliases for long URLs. Here's a function to generate URL aliases using TinyURL's API. The returned URL is short and never expires.

 
function New-TinyUrl($url){
    (new-object net.webclient).downloadString("http://tinyurl.com/api-create.php?url=$url") 
}
 
PS > $vug = New-TinyUrl -url http://marcoshaw.blogspot.com/2008/06/windows-powershell-virtual-user-group.html
PS > $vug
PS > http://tinyurl.com/4k9ons

 

Test it in your default browser:

PS > (new-object -com shell.application).open($vug) 

 

-Shay

Friday, June 20, 2008

Windows PowerShell Virtual User Group #6

 

Marco's Windows PowerShell Virtual User Group #6 is going to take place next week:
Tuesday, Jun 24 7:30pm – 10:30pm (Timezone: Eastern Time)

 

Agenda

8:00PM-8:10PM: Introduction
8:10PM-8:40PM: Bruce Payette (Microsoft)
8:40PM-9:10PM: Wassim Fayed (Microsoft)
9:10PM-9:40PM: Hal Rottenberg
9.40PM-9:50PM: Closing

 

Speaker topics

Bruce Payette : PowerShell v2 modules.
Wassim Fayed : PowerShell v2 remoting.
Hal Rottenberg: Managing VMware Infrastructure using PowerShell.

 

To join for video:
https://www.livemeeting.com/cc/winserver_usergroup/join?id=5H2F88&role=attend&pw=8%5E-%5CzqX

To join for audio:
Toll free: +1 (866) 553-8146
Participant code: 5592528585

 

Required login information (via LiveMeeting)

Meeting ID: 5H2F88
Entry Code: 8^-\zqX

 

Mark your calendar :)

Wednesday, June 18, 2008

Portable PowerShell

 

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

Tuesday, June 17, 2008

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

Monday, June 16, 2008

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

Sunday, June 15, 2008

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
    }
}