Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Powershell Contest... I really want that trip!

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-15-2006   #1 (permalink)
fixitchris
Guest


 

Powershell Contest... I really want that trip!

I'm just thinking of some ideas to submit for a script for the contest. I
came up with this so far. You MVPs out there, what would you like to see
added / changed to impress the judges? (besides error handling)... I've been
using PS for about 2 weeks now, so it is a learning curve but any new
challenge is a learning experience. thanks for the help.


[reflection.assembly]::loadwithpartialname("system.windows.forms");
[reflection.assembly]::loadwithpartialname("system.eventargs");
[reflection.assembly]::loadwithpartialname("system.drawing");


$opt_handler = { $filter_ = "Name = '" + $lv.Text + "'"; (get-wmiObject
win32_service -filter $filter_).changestartmode($this.text)};
$button_handler = {$svc = Get-Service $lv.Text; $rc = $svc.start() ;
write-host $rc; bld_ };
$button2_handler = {$svc = Get-Service $lv.Text; $rc = $svc.stop() ;
write-host $rc; bld_ };
$listview_handler = { if ($_.isselected -eq 1) {$lv =
$this.items[$_.itemindex]; gci $hklm_ | ?{ $_.pschildname -eq $lv.text } |
%{ $textbox.Text = (StartType((gp $_.pspath).start)) } } };
function BuildListView() { foreach( $lv in $listview.Items ) {
$listview.Items.Remove($lv) } ; get-wmiobject win32_service |
%{$lv=$listview.items.add($_.name); $lv.subitems.add($_.state) } ;};
function StartType ($start)
{
switch ($start) {
0 {$opt0.checked = 1; return "Boot"; Continue }
1 {$opt1.checked = 1; return "System"; Continue }
2 {$opt2.checked = 1; return "Automatic"; Continue }
3 {$opt3.checked = 1; return "Manual"; Continue }
4 {$opt4.checked = 1; return "Disabled"; Continue }
"" {return "Unknown";Continue}
}
}
[string]$hklm_ = "hklm:\system\currentcontrolset\services\"
[int]$rc = 0;
Set-Alias bld_ BuildListView

$window = New-Object windows.forms.form; $window.Size = New-Object
system.drawing.size @(220,600); $window.Text = "Windows Services";
$window.FormBorderStyle = "FixedDialog"; $window.MaximizeBox= 0;
$button = new-Object windows.Forms.Button;$button.Text = "Start";
$button2 = new-Object windows.Forms.Button;$button2.Text =
"Stop";$button2.Left = 80;
$button3 = New-Object windows.forms.button;$button3.text = "refresh";
$button3.left = 160; $button3.width = 50;
$listview = New-Object windows.forms.listview;$listview.Top =
25;$listview.Height = 400;$listview.width = 210;$listview.view="Details";
$listview.MultiSelect=0;$listview.FullRowSelect =
1;$listview.Columns.Add("Name",125);$listview.Columns.Add("Status",60);
$listview.hideselection = 0;
$lvi = New-Object windows.forms.listviewitem;
$opt0 = New-Object windows.forms.radiobutton; $opt0.location = "25,450";
$opt0.text = (starttype(0)); $opt0.checked = 0;
$opt1 = New-Object windows.forms.radiobutton; $opt1.location = "25,475";
$opt1.text = (starttype(1)); $opt1.checked = 0;
$opt2 = New-Object windows.forms.radiobutton; $opt2.location = "25,500";
$opt2.text = (starttype(2)); $opt2.checked = 0;
$opt3 = New-Object windows.forms.radiobutton; $opt3.location = "25,525";
$opt3.text = (starttype(3)); $opt3.checked = 0;
$opt4 = New-Object windows.forms.radiobutton; $opt4.location = "25,550";
$opt4.text = (starttype(4)); $opt4.checked = 0;
$label = New-Object windows.forms.label; $label.text = "Service Startup Mode
: " ; $label.location = "15,435"; $label.width = 150; $label.height = 15;

$button.add_click($button_handler);
$button2.add_click($button2_handler);
$button3.add_click($function:BuildListView);
$listview.add_ItemSelectionChanged($listview_handler);
$window.add_load($function:BuildListView);
$opt0.add_click($opt_handler);
$opt1.add_click($opt_handler);
$opt2.add_click($opt_handler);
$opt3.add_click($opt_handler);
$opt4.add_click($opt_handler);

$window.controls.add($listview);
$window.Controls.Add($button);
$window.Controls.Add($button2);
$window.Controls.Add($button3);
$window.controls.Add($label);
$window.Controls.Add($opt0);
$window.Controls.Add($opt1);
$window.Controls.Add($opt2);
$window.Controls.Add($opt3);
$window.Controls.Add($opt4);

$window.ShowDialog();

My System SpecsSystem Spec
Old 11-15-2006   #2 (permalink)
Andrew Watt [MVP]
Guest


 

Re: Powershell Contest... I really want that trip!

Hi,

I could be wrong but I read the info,
http://www.microsoft.com/technet/scr...t/default.mspx,
as meaning that any non-trivial script would count as an entry. I
don't think they are looking for 1 (or 12) super-duper "best in
category" scripts.

Andrew Watt MVP

On Wed, 15 Nov 2006 12:42:02 -0800, fixitchris
<fixitchris@discussions.microsoft.com> wrote:

>I'm just thinking of some ideas to submit for a script for the contest. I
>came up with this so far. You MVPs out there, what would you like to see
>added / changed to impress the judges? (besides error handling)... I've been
>using PS for about 2 weeks now, so it is a learning curve but any new
>challenge is a learning experience. thanks for the help.

My System SpecsSystem Spec
Old 11-15-2006   #3 (permalink)
fixitchris
Guest


 

Re: Powershell Contest... I really want that trip!

You're right. I guess i'm just trying to challenge myself so that powershell
and .NET framework becomes second nature to me.
My System SpecsSystem Spec
Old 11-15-2006   #4 (permalink)
Adam Milazzo
Guest


 

Re: Powershell Contest... I really want that trip!

Andrew Watt [MVP] wrote:
> Hi,
>
> I could be wrong but I read the info,
> http://www.microsoft.com/technet/scr...t/default.mspx,
> as meaning that any non-trivial script would count as an entry. I
> don't think they are looking for 1 (or 12) super-duper "best in
> category" scripts.
>
> Andrew Watt MVP

Yeah, kinda sucks that it's not merit-based, but I guess you can't
complain too much. :-)
My System SpecsSystem Spec
Old 11-16-2006   #5 (permalink)
Marco Shaw
Guest


 

Re: Powershell Contest... I really want that trip!

> I'm just thinking of some ideas to submit for a script for the contest. I

Has anyone tried to make a submission? I don't know if the system accepts
it. After submitting, it seems to redirect to an error page.

I haven't retried today...

Marco


My System SpecsSystem Spec
Old 11-16-2006   #6 (permalink)
fixitchris
Guest


 

submit error!

I get an error subtmitting as well....
My System SpecsSystem Spec
Old 11-16-2006   #7 (permalink)
Marco Shaw
Guest


 

Re: Powershell Contest... I really want that trip!

> Has anyone tried to make a submission? I don't know if the system accepts
> it. After submitting, it seems to redirect to an error page.


Still not working today it seems.

Marco


My System SpecsSystem Spec
Old 11-16-2006   #8 (permalink)
Rick
Guest


 

RE: submit error!

I've been getting the error page for two days now

"fixitchris" wrote:

> I get an error subtmitting as well....

My System SpecsSystem Spec
Old 11-17-2006   #9 (permalink)
Greg Stemp (Microsoft)
Guest


 

Re: Powershell Contest... I really want that trip!

Hey, guys. I apologize for the inconvenience; unfortunately, Microsoft.com
has been experiencing some technical problems that seem to have broken the
contest submission tool. However, all is not lost: you can still enter the
contest simply by emailing your submission to scripter@microsoft.com. Do
that, and I'll make sure everything gets taken care of.

Thanks and, again, I apoogize for the inconvenience.

Greg Stemp
Microsoft Scripting Guy

"Marco Shaw" wrote:

> > Has anyone tried to make a submission? I don't know if the system accepts
> > it. After submitting, it seems to redirect to an error page.

>
> Still not working today it seems.
>
> Marco
>
>
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
CONTEST: How would you do it in Powershell! Brandon Shell PowerShell 7 07-30-2007 02:47 PM
PowerShell Scripting Contest - 2 weeks left Jeffrey Snover [MSFT] PowerShell 4 12-01-2006 04:21 PM
Powershell scripting contest Marco Shaw PowerShell 3 11-17-2006 11:04 AM
[FYI] Windows PowerShell contest (prizes!!!) Marco Shaw PowerShell 1 11-02-2006 10:36 AM
Exchange 2007 "Activate the PowerShell" One liner Contest Abhishek Agrawal [MSFT] PowerShell 0 06-17-2006 09:39 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008