-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect-drac-console.ps1
73 lines (51 loc) · 2.25 KB
/
connect-drac-console.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$idraclist = @()
$idraclist = Import-Csv .\serverlist.csv
$acceptableAnswer = $null
$url = $null
$addServer = $false
while($acceptableAnswer -eq $null) {
$count = 1
foreach($server in $idraclist){
if($(Test-Connection $server.url -Count 1 -quiet)){ $status = "Green" }
else { $status = "Red"; $server.status = "down" }
Write-host -NoNewline "[$count]" -ForegroundColor $status
Write-host -NoNewline " $($server.name) - $($server.model) ("
Write-host -NoNewline "$($server.os)" -ForegroundColor Cyan
Write-Host ")"
$count++
}
write-host "[$count] Add a server to this list." -ForegroundColor Cyan
[uint16]$number = Read-Host -prompt "Choose server to connect to [1-$count]"
if($number -eq $count){
$acceptableAnswer = $true
$addServer = $true
} elseif(($number -ge $count) -or ($number -le 0)){
} elseif ($idraclist[$number-1].status -eq "up") {
$acceptableAnswer = $true
$url = $idraclist[$number-1].url
}
}
if($addServer) {
$server_url = Read-Host -Prompt "What is the server's iDRAC address (e.g. 'idrac.domain.com')"
$server_name = Read-Host -Prompt "What is the server's name (e.g. 'My server')"
$server_model = Read-Host -Prompt "What is the server's model (e.g. 'Dell PowerEdge R610')"
$os_list = @(
"Windows Server 2016",
"Windows Server 2012R2",
"ESXi 6.5",
"ESXi 6.0",
"XCP-NG 7.5.0",
"XCP-NG")
$os_count = 1
foreach($choice in $os_list) {
Write-host "[$os_count] $choice"
$os_count++
}
[uint16]$server_os = Read-host -Prompt "What is the server's OS [1-$os_count]"
Add-Content -Value "$server_name,$server_model,$($os_list[$server_os-1]),$server_url,up" -Path .\serverlist.csv
}
else {
$creds = Get-Credential -Message "Credentials to connect to $url"
Write-host "Connecting to $url"
Start-Process ".\jre\bin\java" -Argumentlist "-cp avctKVM.jar -Djava.library.path=.\lib com.avocent.idrac.kvm.Main ip=$url kmport=5900 vport=5900 user=$($creds.GetNetworkCredential().UserName) passwd=$($creds.GetNetworkCredential().Password) apcp=1 version=2 vmprivilege=true helpurl=https://$($url):443/help/contents.html"
}