-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStart-AOS.ps1
47 lines (41 loc) · 1.14 KB
/
Start-AOS.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Start-AOS
Param(
[string[]]$aosServerNames = $env:COMPUTERNAME,
$aosServiceName = 'AOS60$01'
)
try
{
$servicesList = New-Object System.Collections.ArrayList
foreach ($AOSServer in $aosServerNames)
{
$service = Get-Service -ComputerName $AOSServer $aosServiceName
if ($service.Status -eq "Stopped")
{
$servicesList.add($service) | Out-Null
Write-Output "Starting AOS in $AOSServer"
$service.Start()
}
else
{
Write-Output "Could not start AOS in $AOSServer the service status is $service.Status"
}
}
foreach ($service in $servicesList)
{
if ($service.Status -eq 'Running')
{
Write-Output "AOS in $($service.MachineName) is running"
}
else
{
Write-Output "Waiting AOS $($service.MachineName) to start"
$service.WaitForStatus("Running")
Write-Output "AOS in $($service.MachineName) is running"
}
}
}
catch
{
Write-Output "Error stoping AOS"
break
}