########################################################## # # Script-Name: PowerShellug.ps1 # # authors: Niklas Goude # # Url: http://www.PowerShell.nu # ########################################################## param ([switch]$help) function GetHelp() { $HelpText = @" DESCRIPTION: NAME: PowerShellug.ps1 Merlin helps you join the Scandinavian PowerShell UserGroup PARAMETERS: -help Prints the HelpFile (Optional) SYNTAX: PowerShellug.ps1 This script helps you join the Scandinavian PowerShell UserGroup. Just answer Merlins question and he will point you in the right direction. PowerShellug.ps1 -help Displays the help topic for the script "@ $HelpText } function Get-Agent([string]$Character) { $GetAgent = new-object -com Agent.Control.2 $GetAgent.Connected = 1 [void]$GetAgent.Characters.Load($Character) $Agent = $GetAgent.Characters.Character($Character) [void]$Agent.Show() [void]$Agent.Speak("Hello PowerShell User!") Start-Sleep -s 5 [void]$Agent.Speak("My name is Merlin and I'm a member of the Scandinavian PowerShell User Group!") Start-Sleep -s 5 [void]$Agent.Speak("To become a member of the PowerShellug UserGroup you have to answer this question:") Start-Sleep -s 5 Prompt-User if($Question -match "picard") { [void]$Agent.Speak("Amazing! you are now qualified to become a member!") Start-Sleep -s 5 [void]$Agent.Speak("Just fill out the form in Internet Explorer") Start-Sleep -s 5 [void]$Agent.Play("doMagic1") Start-Sleep -s 3 Start-IE "http://powershellug.com/user/CreateUser.aspx?ReturnUrl=" } else { [void]$Agent.Think("Hmm, the answer wasn't correct") Start-Sleep -s 5 [void]$Agent.Speak("The answer can be found on the page that I'm about to conjure. Contact me again when you have gathered the correct information.") Start-Sleep -s 5 [void]$Agent.Play("doMagic1") Start-Sleep -s 3 Start-IE "http://en.wikipedia.org/wiki/Star_Trek_The_Next_Generation" } [void]$Agent.Speak("Have a nice day!") Start-Sleep -s 5 [void]$Agent.Hide() } function Prompt-User { # GAC [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") function Return-Text { $script:Question = $TextBox.Text.ToString() $Form.Close() } $Form = New-Object System.Windows.Forms.Form $Form.Size = new-object System.Drawing.Size(400,200) $Form.Text = "Merlins Question" $Form.StartPosition = "CenterScreen" $Label = New-Object Windows.Forms.Label $Label.Text = "Who is the Captain of the USS Enterprise (NCC-1701-D) ?" $Label.Location = New-Object System.Drawing.Size(50,50) $Label.Size = New-Object System.Drawing.Size(350,30) $Form.Controls.Add($Label) $TextBox = New-Object System.Windows.Forms.TextBox $TextBox.Location = New-Object System.Drawing.Size(50,90) $Form.Controls.Add($TextBox) $Button = new-object System.Windows.Forms.Button $Button.Location = new-object System.Drawing.Size(180,90) $Button.Size = new-object System.Drawing.Size(100,20) $Button.Text = "OK" $Button.Add_Click({Return-Text}) $form.Controls.Add($Button) $Form.Add_Shown({$Form.Activate()}) [void]$Form.ShowDialog() } function Start-IE([string]$Url) { $InternetExplorer = New-Object -Com InternetExplorer.Application $InternetExplorer.navigate2($Url) $InternetExplorer.Visible = $True } if($help) { GetHelp } else { Get-Agent "Merlin" }