-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-BMCLanConfig.ps1
70 lines (50 loc) · 1.67 KB
/
Set-BMCLanConfig.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
<#
.SYNOPSIS
Change BMC IP's.
.DESCRIPTION
This script will udpate BMC IP's using a CSV file using input creds
.PARAMETER ipmitoolPath
location of the ipmi tool path
.PARAMETER CSVPath
location of the BMC nodes to change
.PARAMETER GatewayIP
gateway address to change too
.PARAMETER SubNetMask
subnet mask to change too
.PARAMETER $creds
this will be prompted for
.EXAMPLE
.\Set-BMCLanConfig.ps1 -ipmitoolPath 'C:\tmp\' -CSVPath 'C:\tmp\bmclist.csv' -GatewayIP '192.168.0.1' -SubNetMask '255.255.255.0'
This would use the stated variables to change the BMC addresses.
#>
param
(
[Parameter(Mandatory=$True)]
[string]$ipmitoolPath,
[Parameter(Mandatory=$True)]
[string]$CSVPath,
[Parameter(Mandatory=$True)]
[string]$GatewayIP,
[Parameter(Mandatory=$True)]
[string]$SubNetMask,
[Parameter(Mandatory=$True)]
[PSCredential]$creds
)
$BMCData = Import-CSV $CSVPath
$Password = $creds.GetNetworkCredential().Password
$Username = $creds.UserName
cd $ipmitoolPath
foreach ($BMCNode in $BMCData) {
$Attempt = "Attempting LAN Configuration on {0}" -f $BMCNode.Name
Write-Output $Attempt
#Set New IP for Node
$NewIPOut = .\ipmitool.exe -H $BMCNode.BMCIP -P $Password -U $Username lan set 1 ipaddr $BMCNode.NewIP
Start-Sleep -Seconds 5
#Update Gateway for Node (leveraging new IP)
$GWOut = .\ipmitool.exe -H $BMCNode.NewIP -P $Password -U $Username lan set 1 defgw ipaddr $GatewayIP
#Update Subnet Mask for Node (leveraging new IP)
$NetMaskOut = .\ipmitool.exe -H $BMCNode.NewIP -P $Password -U $Username lan set 1 netmask $SubNetMask
Write-Output $NewIPOut
Write-Output $GWOut
Write-Output $NetMaskOut
}