This is a draft in process post.

[code language=”powershell”]
Function Start_EPM_Service
{
param ($service_name, $server, $port, $Form, $Label)

$socket = new-object System.Net.Sockets.TcpClient("192.168.1.1", $port)

# If there is no connection to port then catch the exception and continue.
trap {
continue
}

If(-not $socket.Connected) {
Stop-Service $service_name
start-sleep -Milliseconds 500;
If (Test-Path C:OracleMiddlewareuser_projectsdomainsEPMSystemservers$serverlogs$server.log) {
Remove-Item C:OracleMiddlewareuser_projectsdomainsEPMSystemservers$serverlogs$server.log
}
Write-Host "Starting $service_name"

$initial = 0
#Start WebLogic Admin Server and wait for next RUNNING

Start-Service $service_name
$Label.Text = "Starting $service_name"

do {
$Form.Refresh()
start-sleep -Milliseconds 150;
}
until(Test-Path C:OracleMiddlewareuser_projectsdomainsEPMSystemservers$serverlogs$server.log)

do {
$f = select-string -path C:OracleMiddlewareuser_projectsdomainsEPMSystemservers$serverlogs$server.log -pattern "BEA-000360";
$i = 0
do {
$Form.Refresh()
start-sleep -Milliseconds 150;
$i = $i + 1
}
until ($i -gt 20)
}
until ($f.count -gt $initial)

$Label.Text = "$service_name started and online"

do {
$Form.Refresh()
start-sleep -Milliseconds 150;
$i = $i + 1
}
until ($i -gt 20)

}
else {
Write-Host "Service $service_name already started."
$socket.Close()
}
}

# Show message box popup and return the button clicked by the user.
function Read-MessageBoxDialog([string]$Message, [string]$WindowTitle, [System.Windows.Forms.MessageBoxButtons]$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]$Icon = [System.Windows.Forms.MessageBoxIcon]::None)
{
Add-Type -AssemblyName System.Windows.Forms
return [System.Windows.Forms.MessageBox]::Show($Message, $WindowTitle, $Buttons, $Icon)
}

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")

$Form = new-object Windows.Forms.Form
$Form.Text = "EPM Starter"

$Label = New-Object System.Windows.Forms.Label
$Label.Text = "Starting"
$Label.AutoSize = $True
$Form.Controls.Add($Label)

$Form.BackColor= [System.Drawing.Color]::White

$pictureBox = new-object Windows.Forms.PictureBox

$pictureBox.Width = 141
$pictureBox.Height = 141
$Form.width = $pictureBox.Width + 120
$Form.height = $pictureBox.Height + 90

$point = new-object System.Drawing.Point(50,30);

$pictureBox.Location = $point

$pictureBox.Image = [System.Drawing.Image]::Fromfile("C:scriptsloading.gif")
$Form.controls.add($pictureBox)

$buttonClicked = Read-MessageBoxDialog -Message "Load SOA for Close Suite?" -WindowTitle "Got Consolidations?" -Buttons YesNo -Icon Question

$Form.Show()

if ($buttonClicked -eq "Yes") {
Start_EPM_Service Oracle_AdminServer AdminServer 7001 $Form $Label
Start_EPM_Service Oracle_SoaServer soa_server1 8001 $Form $Label
}

Start_EPM_Service HyS9EPMServer_epmsystem1 EPMServer0 9000 $Form $Label

$Label.Text="Metavero EPM Test Drive Started, Enjoy!"

$point = new-object System.Drawing.Point(10,20);
$pictureBox.Location = $point
$pictureBox.Width = 193
$pictureBox.Height = 47

$pictureBox.Image = [System.Drawing.Image]::Fromfile("C:scriptsmetavero.gif")

$tagLine = new-object Windows.Forms.PictureBox
$tagLine.Image = [System.Drawing.Image]::Fromfile("C:scriptstagline.png")

$point = new-object System.Drawing.Point(8,77);
$tagLine.Location = $point
$tagLine.Width = 241
$tagLine.Height = 133
$Form.controls.add($tagLine)

$i = 0
do {
$Form.Refresh()
start-sleep -Milliseconds 150;
$i = $i + 1
}
until ($i -gt 100)

$Form.Dispose()
$Form.Close()
[/code]