├── HPEBIOS
├── 1.1
│ ├── ConfigureBIOSAdminPassword.ps1
│ ├── ConfigureBootMode.ps1
│ ├── ConfigureBootOrder.ps1
│ ├── ConfigureEMSConsoleAndSerialPort.ps1
│ ├── ConfigureIntelTurboBoost.ps1
│ ├── ConfigureNetworkBootsettings.ps1
│ ├── ConfigurePowerOnPassword.ps1
│ ├── ConfigureProcessorPower.ps1
│ ├── ConfigureServerAvailability.ps1
│ ├── ConfigureServerSecurity.ps1
│ ├── ConfigureThermalAndFanOption.ps1
│ ├── ConfigureUEFIOptimizedBoot.ps1
│ ├── LICENSE
│ ├── ResetBIOSAdminPassword.ps1
│ ├── ResetBIOSUserDefaultSettings.ps1
│ └── ResetPowerOnPassword.ps1
├── 2.0
│ ├── ConfigureAdminInfo.ps1
│ ├── ConfigureBIOSAdminPassword.ps1
│ ├── ConfigureBootMode.ps1
│ ├── ConfigureBootOrder.ps1
│ ├── ConfigureEMSConsoleAndSerialPort.ps1
│ ├── ConfigureIntelTurboBoost.ps1
│ ├── ConfigureNetworkBootsettings.ps1
│ ├── ConfigurePCIDeviceWithPCIeLinkSpeedForGen10.ps1
│ ├── ConfigurePowerOnPassword.ps1
│ ├── ConfigureProcessorPower.ps1
│ ├── ConfigureServerAvailability.ps1
│ ├── ConfigureServerSecurity.ps1
│ ├── ConfigureTPM(TrustedPlatformModule).ps1
│ ├── ConfigureThermalAndFanOption.ps1
│ ├── ConfigureUEFIOptimizedBoot.ps1
│ ├── ConfigureWorkloadProfileForGen10servers.ps1
│ ├── ResetBIOSAdminPassword.ps1
│ ├── ResetBIOSUserDefaultSettings.ps1
│ └── ResetPowerOnPassword.ps1
├── 2.1
│ ├── ConfigureAMDCorePerformanceBoosting.ps1
│ ├── ConfigureAdminInfo.ps1
│ ├── ConfigureBIOSAdminPassword.ps1
│ ├── ConfigureBootMode.ps1
│ ├── ConfigureBootOrder.ps1
│ ├── ConfigureEMSConsoleAndSerialPort.ps1
│ ├── ConfigureIntelCoreBoosting.ps1
│ ├── ConfigureIntelTurboBoost.ps1
│ ├── ConfigureNVDIMMConfiguration.ps1
│ ├── ConfigureNetworkBootsettings.ps1
│ ├── ConfigurePCIDeviceWithPCIeLinkSpeedForGen10.ps1
│ ├── ConfigurePowerOnPassword.ps1
│ ├── ConfigureProcessorJitterControl.ps1
│ ├── ConfigureProcessorPower.ps1
│ ├── ConfigureServerAvailability.ps1
│ ├── ConfigureServerSecurity.ps1
│ ├── ConfigureTPM.ps1
│ ├── ConfigureThermalAndFanOption.ps1
│ ├── ConfigureUEFIOptimizedBoot.ps1
│ ├── ConfigureVirtualInstallDisk.ps1
│ ├── ConfigureWorkloadProfileForGen10servers.ps1
│ ├── ResetBIOSAdminPassword.ps1
│ ├── ResetBIOSDefaultManufacturingSettings.ps1
│ └── ResetPowerOnPassword.ps1
├── 2.2
│ ├── AddiSCSIBootAttempt.ps1
│ ├── ConfigureAMDCorePerformanceBoosting.ps1
│ ├── ConfigureAdminInfo.ps1
│ ├── ConfigureBIOSAdminPassword.ps1
│ ├── ConfigureBootMode.ps1
│ ├── ConfigureBootOrder.ps1
│ ├── ConfigureEMSConsoleAndSerialPort.ps1
│ ├── ConfigureIntelCoreBoosting.ps1
│ ├── ConfigureIntelTurboBoost.ps1
│ ├── ConfigureNVDIMMConfiguration.ps1
│ ├── ConfigureNetworkBootsettings.ps1
│ ├── ConfigurePCIDeviceWithPCIeLinkSpeedForGen10.ps1
│ ├── ConfigurePowerOnPassword.ps1
│ ├── ConfigureProcessorJitterControl.ps1
│ ├── ConfigureProcessorPower.ps1
│ ├── ConfigureServerAvailability.ps1
│ ├── ConfigureServerSecurity.ps1
│ ├── ConfigureTPM.ps1
│ ├── ConfigureThermalAndFanOption.ps1
│ ├── ConfigureUEFIOptimizedBoot.ps1
│ ├── ConfigureVirtualInstallDisk.ps1
│ ├── ConfigureWorkloadProfileForGen10servers.ps1
│ ├── InstallTLSCertificate.ps1
│ ├── RemoveiSCSIBootAttempt.ps1
│ ├── ResetBIOSAdminPassword.ps1
│ ├── ResetBIOSDefaultManufacturingSettings.ps1
│ ├── ResetPowerOnPassword.ps1
│ └── UninstallTLSCertificate.ps1
└── 3.0.0.0
│ ├── AddiSCSIBootAttempt.ps1
│ ├── ConfigureAMDCorePerformanceBoosting.ps1
│ ├── ConfigureAdminInfo.ps1
│ ├── ConfigureBIOSAdminPassword.ps1
│ ├── ConfigureBootMode.ps1
│ ├── ConfigureBootOrder.ps1
│ ├── ConfigureEMSConsoleAndSerialPort.ps1
│ ├── ConfigureIntelCoreBoosting.ps1
│ ├── ConfigureIntelTurboBoost.ps1
│ ├── ConfigureNVDIMMConfiguration.ps1
│ ├── ConfigureNetworkBootsettings.ps1
│ ├── ConfigurePCIDeviceWithPCIeLinkSpeedForGen10.ps1
│ ├── ConfigurePowerOnPassword.ps1
│ ├── ConfigureProcessorJitterControl.ps1
│ ├── ConfigureProcessorPower.ps1
│ ├── ConfigureServerAvailability.ps1
│ ├── ConfigureServerSecurity.ps1
│ ├── ConfigureTPM.ps1
│ ├── ConfigureThermalAndFanOption.ps1
│ ├── ConfigureUEFIOptimizedBoot.ps1
│ ├── ConfigureVirtualInstallDisk.ps1
│ ├── ConfigureWorkloadProfileForGen10servers.ps1
│ ├── InstallTLSCertificate.ps1
│ ├── RemoveiSCSIBootAttempt.ps1
│ ├── ResetBIOSAdminPassword.ps1
│ ├── ResetBIOSDefaultManufacturingSettings.ps1
│ ├── ResetPowerOnPassword.ps1
│ └── UninstallTLSCertificate.ps1
├── HPEMigrationAdvisoryTool
└── 1.0.0.0
│ ├── HPEMigrationAdvisoryTool.dll
│ ├── HPEMigrationAdvisoryTool.psd1
│ ├── HPEMigrationAdvisoryToolLicense.rtf
│ ├── HPEMigrationAdvisoryTool_4407ac86-ebaf-4ead-8c0a-dab65dc1854d_HelpInfo.xml
│ ├── HPEMigrationAdvisoryTool_4407ac86-ebaf-4ead-8c0a-dab65dc1854d_ModuleInfo.xml
│ ├── PSGetModuleInfo.xml
│ ├── Readme.txt
│ ├── ShowLicense.ps1
│ └── en-US
│ ├── HPEMigrationAdvisoryTool.dll-Help.xml
│ └── about_HPEMigrationAdvisoryTool.Help.txt
├── HPEOA
├── 2.0
│ ├── GettingCmdletsResult.ps1
│ ├── GettingFanTemperatureInfo.ps1
│ ├── GettingPowerInfo.ps1
│ ├── GettingServerStatus.ps1
│ ├── Input.csv
│ ├── InputNamedOrPipelineParameters.ps1
│ ├── LogProcessing.ps1
│ ├── SettingUIDOn.ps1
│ ├── UpdatingModuleAndHelp.ps1
│ ├── UpdatingiLOFW.ps1
│ ├── UsingFind-HPEOA.ps1
│ ├── UsingInvoke-HPEOAiLOCommand.ps1
│ ├── UsingUpdate-HPEOAFirmware.ps1
│ └── WorkingWithCertificates.ps1
├── Community Scripts
│ ├── CollectBladeInfo.ps1
│ └── README.md
└── GetOADetails.ps1
├── HPEOSProvisioning
├── AddUnattendXmlAndDrivers.ps1
├── GetWindowsImageIndex.ps1
└── InstallWindowsOS.ps1
├── HPEREST
└── HPRESTExamples.ps1
├── HPERedfish
└── HPERedfishExamples.ps1
├── HPESmartArray
└── 1.0
│ ├── CreateLogicalDrive.ps1
│ ├── GetPhysicalAndLogicalDrive.ps1
│ ├── GetSmartArrayControllerHealthStatus.ps1
│ └── ResetSmartArrayController.ps1
└── HPEiLO
├── 1.5
├── BootModeConfigurations.ps1
├── ConfigureAndTestDirectorySettings.ps1
├── ConfigureFederationGroupSettings.ps1
├── DecodeSMBIOSRecord.ps1
├── Error_Handling.ps1
├── Generate_CertificateSigningRequest.ps1
├── Import_Parameters_From_CSV_File.ps1
├── Input_Named_Or_Pipeline_Parameters.ps1
├── InvokeRIBCL.ps1
├── LanguagePackInstallation.ps1
├── Log_Processing.ps1
├── ServerFirmwareUpdate.ps1
├── Using_Find-HPiLO.ps1
├── Using_Get-HPiLOMemoryInfo.ps1
└── Using_Invoke-HPOAiLOCommand.ps1
├── 2.0
├── BackupAndRestore.ps1
├── BootConfiguration.ps1
├── ComponentRepositoryManagement.ps1
├── ConfigureFederationGroupSettings.ps1
├── DefaultDirectorySchemaSetting.ps1
├── EstablishingConnection.ps1
├── Gen10NewFeatures.ps1
├── GenerateCertificateSigningRequest.ps1
├── GetFirmwareVerificationScan.ps1
├── GettingServerInformation.ps1
├── InstallSetInput.csv
├── InstallSetManagement.ps1
├── InventoryInformation.ps1
├── LanguagePackInstallation.ps1
├── LicenseKey.ps1
├── LogProcessing.ps1
├── SmartArrayInformation.ps1
├── UpdateFirmware.ps1
├── UsingFindHPEiLO.ps1
└── iLOInput.csv
├── 2.1
├── ApolloChassisPowerManagementSettings.ps1
├── BackupAndRestore.ps1
├── BootConfiguration.ps1
├── ComponentRepositoryManagement.ps1
├── ConfigureFederationGroupSettings.ps1
├── DecodeSMBIOSRecord.ps1
├── DefaultDirectorySchemaSetting.ps1
├── EstablishingConnection.ps1
├── Gen10NewFeatures.ps1
├── GenerateCertificateSigningRequest.ps1
├── GetFirmwareVerificationScan.ps1
├── GettingServerInformation.ps1
├── InstallSetInput.csv
├── InstallSetManagement.ps1
├── InventoryInformation.ps1
├── LanguagePackInstallation.ps1
├── LicenseKey.ps1
├── LogProcessing.ps1
├── SaveAHSLog.ps1
├── SmartArrayInformation.ps1
├── UpdateFirmware.ps1
├── UsingFindHPEiLO.ps1
└── iLOInput.csv
├── 2.2
├── ApolloChassisPowerManagementSettings.ps1
├── BackupAndRestore.ps1
├── BootConfiguration.ps1
├── ComponentRepositoryManagement.ps1
├── ConfigureFederationGroupSettings.ps1
├── DecodeSMBIOSRecord.ps1
├── DefaultDirectorySchemaSetting.ps1
├── EstablishingConnection.ps1
├── Gen10NewFeatures.ps1
├── GenerateCertificateSigningRequest.ps1
├── GetFirmwareVerificationScan.ps1
├── GettingServerInformation.ps1
├── InstallSetManagement.ps1
├── InventoryInformation.ps1
├── LanguagePackInstallation.ps1
├── LicenseKey.ps1
├── LogProcessing.ps1
├── SaveAHSLog.ps1
├── SecurityDashboardSettings.ps1
├── SmartArrayInformation.ps1
├── UpdateFirmware.ps1
├── UsingFindHPEiLO.ps1
└── iLOInput.csv
└── 3.0
├── ApolloChassisPowerManagementSettings.ps1
├── BackupAndRestore.ps1
├── BootConfiguration.ps1
├── ComponentRepositoryManagement.ps1
├── ConfigureFederationGroupSettings.ps1
├── DecodeSMBIOSRecord.ps1
├── DefaultDirectorySchemaSetting.ps1
├── EstablishingConnection.ps1
├── Gen10NewFeatures.ps1
├── GenerateCertificateSigningRequest.ps1
├── GetFirmwareVerificationScan.ps1
├── GettingServerInformation.ps1
├── InstallSetInput.csv
├── InstallSetManagement.ps1
├── InventoryInformation.ps1
├── LanguagePackInstallation.ps1
├── LicenseKey.ps1
├── LogProcessing.ps1
├── SaveAHSLog.ps1
├── SecurityDashboardSettings.ps1
├── SmartArrayInformation.ps1
├── UpdateFirmware.ps1
├── UsingFindHPEiLO.ps1
└── iLOInput.csv
/HPEBIOS/1.1/LICENSE:
--------------------------------------------------------------------------------
1 | (c) Copyright 2016 Hewlett Packard Enterprise Development LP
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/HPEMigrationAdvisoryTool.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HewlettPackard/PowerShell-ProLiant-SDK/44097f0cec2000135b9c441816b37e6f86cca51d/HPEMigrationAdvisoryTool/1.0.0.0/HPEMigrationAdvisoryTool.dll
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/HPEMigrationAdvisoryTool_4407ac86-ebaf-4ead-8c0a-dab65dc1854d_HelpInfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | http://www.hpe.com/info/powershell-updatehelp
4 |
5 |
6 | en-US
7 | 1.0.0.0
8 |
9 |
10 |
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/HPEMigrationAdvisoryTool_4407ac86-ebaf-4ead-8c0a-dab65dc1854d_ModuleInfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | http://www.hpe.com/info/powershell-updatehelp
4 | 1.0.0.0
5 |
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/PSGetModuleInfo.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HewlettPackard/PowerShell-ProLiant-SDK/44097f0cec2000135b9c441816b37e6f86cca51d/HPEMigrationAdvisoryTool/1.0.0.0/PSGetModuleInfo.xml
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/Readme.txt:
--------------------------------------------------------------------------------
1 | This module provide Invoke-HPECmdletMigration Cmdlet.
2 | Invoke-HPECmdletMigration Cmdlet suggests changes for existing HPE Cmdlets used in PowerShell scripts to update to the latest HPE Cmdlets module.
3 |
4 | Migration suggestion are provided for the following items :
5 | 1) ModuleName
6 | 2) Cmdlets
7 | 3) Parameter
8 | 4) Property
9 | 5) value.
10 |
--------------------------------------------------------------------------------
/HPEMigrationAdvisoryTool/1.0.0.0/en-US/about_HPEMigrationAdvisoryTool.Help.txt:
--------------------------------------------------------------------------------
1 | TOPIC
2 | about_HPEMigrationAdvisoryTool
3 |
4 | SHORT DESCRIPTION
5 | This module provides Cmdlets to migrate HPE Cmdlets to latest HPE Cmdlets module.
6 |
7 | LONG DESCRIPTION
8 | This module provide Invoke-HPECmdletMigration Cmdlet. Invoke-HPECmdletMigration Cmdlet suggests changes for existing HPE Cmdlets used in PowerShell scripts to update to the latest HPE Cmdlets module.
9 | Migration suggestion are provided for the following items.
10 | 1) ModuleName
11 | 2) Cmdlets
12 | 3) Parameter
13 | 4) Property
14 | 5) value.
15 |
16 |
17 | CmdletChangeItem Properties.
18 |
19 | ChangeType : Provides change type (Rename,Classify,Fragment, Obsolete)
20 | LineNumber : Line number of Cmdlet in the script file
21 | LinePosition : Line position of Cmdlet in the script file.
22 | Severity : Severity of changes. if it is high then Cmdlet execution will be failed if suggested changes is not considerd. (High,Mediem,Low)
23 | Cmdlet : Provide Existing Cmdlet and NewCmdlet If the Cmdlet name has changed.
24 | Parameter : Provide the parameter which required changes.Each item of parameter contains ExistingName and NewName.
25 | ParameterReference : Provide references for the parameter listed under 'Parameter' property. Each item contains (LineNumber, LinePosition, Name).
26 | Property : Provide the property which required changes.Each item of property contains ExistingName and NewName.
27 | PropertyReference : Provide references for the property listed under 'Property property. Each item contains (LineNumber, LinePosition, Name).
28 | Value : Provide the value which required changes.Each item of value contains ExistingName and NewName.
29 | ValueReference : Provide references for the value listed under 'Value' property. Each item contains (LineNumber, LinePosition, Name).
30 |
31 |
32 | Method Exposed By CmdletChangeItem.
33 |
34 | GetAdditionalMigrationInfo() :- This returns all the Changes (Parameter,Property,value) for the Cmdlet to migrate to latest HPE Cmdlets module.
35 |
36 | GetPipelineInputVariable() :- Returns the pipeline variable name.(If not pipeline input varaible then it return null).
37 |
38 | GetReturnVaraible() :- Returns the variable name where Cmldet result is stored.
39 |
40 |
41 | Enum Exposed by HPECmdletMigration.
42 |
43 | [HPE.MigrationAdvisoryTool.ChangeItemType] :- provide name for change item. (Cmdlet,Parameter,Property,Value).
44 |
45 | [HPE.MigrationAdvisoryTool.ChangeType] :- provide change item type (Rename, Classify, Fragment, Obsolete).
46 |
47 | NOTE
48 | 1) This Cmldet provides suggestion based on Cmdlets recognised as PowerShell cmdlet token. If the Cmldet is passed as string and invoke through Invoke-Command
49 | then no suggestion will provided for such Cmdlets.
50 | 2) If the change type is "Classify" in that case ParameterReference/PropertyRefrence will be null. Update the script with new Cmdlet and Parameter/Property (if availiable).
51 |
52 | 3) All the migraion suggestions are provided in context to HPE Cmdlets.
53 | 4) If the there is no suggestion for input script file,In that case the script file has Cmdlets which dont required any change for the migration.
54 |
55 |
56 | TROUBLESHOOTING NOTE
57 |
58 |
59 |
60 | EXAMPLES
61 | PS C:\> $returnObject = Invoke-HPECmdletMigration -ScriptFile C:\powerTest.ps1 -CmdletModule HPBIOSCmdlets
62 |
63 | PS C:\> $returnObject
64 |
65 |
66 | ChangeType : Rename
67 | LineNumber : 7
68 | LinePosition : 30
69 | Severity : High
70 | Cmdlet : Existing : Set-HPBIOSPowerprofile; New : Set-HPEBIOSPowerProfile
71 | Parameter : {HPPowerProfile}
72 | ParameterReference : {HPPowerProfile}
73 | Property : {StatusType}
74 | PropertyReference : {StatusType}
75 | Value : {Balanced}
76 | ValueReference : {Balanced}
77 |
78 | ChangeType : Rename
79 | LineNumber : 24
80 | LinePosition : 30
81 | Severity : High
82 | Cmdlet : Existing : Set-HPBIOSPowerProfile; New : Set-HPEBIOSPowerProfile
83 | Parameter : {HPPowerProfile}
84 | ParameterReference : {hpPowerprofile}
85 | Property :
86 | PropertyReference :
87 | Value : {Balanced, Maximum_Performance}
88 | ValueReference : {balanced, maximum_Performance}
89 |
90 | ChangeType : Rename
91 | LineNumber : 30
92 | LinePosition : 2
93 | Severity : High
94 | Cmdlet : Existing : Set-HPBIOSPowerProfile; New : Set-HPEBIOSPowerProfile
95 | Parameter : {hppowerprofile}
96 | ParameterReference : {hppowerprofile}
97 | Property :
98 | PropertyReference :
99 | Value : {balanced}
100 | ValueReference : {balanced}
101 |
102 |
103 |
104 | PS C:\> $returnObject [0].Parameter
105 |
106 | ExistingName NewName
107 | ------------ -------
108 | HPPowerProfile PowerProfile
109 |
110 |
111 |
112 | PS C:\> $returnObject [0].ParameterReference
113 |
114 | LineNumber LinePosition Name
115 | ---------- ------------ ----
116 | 2 24 HPPowerProfile
117 |
118 |
119 |
120 | PS C:\> $returnObject [0].Value
121 |
122 | ExistingValue NewValue
123 | ------------- --------
124 | Balanced BalancedPowerAndPerformance
125 |
126 |
127 |
128 | PS C:\> $returnObject [0].ValueReference
129 |
130 | LineNumber LinePosition Name
131 | ---------- ------------ ----
132 | 2 40 Balanced
133 |
134 | KEYWORDS
135 |
136 |
137 |
138 | SEE ALSO
139 |
140 |
--------------------------------------------------------------------------------
/HPEOA/2.0/Input.csv:
--------------------------------------------------------------------------------
1 | IP, Username, Password
2 | 192.168.10.201, Administrator, 12iso*help
--------------------------------------------------------------------------------
/HPEOA/Community Scripts/CollectBladeInfo.ps1:
--------------------------------------------------------------------------------
1 | # A sample script to collect general blade info from a list of OAs (20170131)
2 | #
3 | # Step 1: Save this script on the server with OA Cmdlts loaded
4 | #
5 | # Step 2: create a CSV file with OA info (headers: "IP", "UserName", "Password")
6 | # IP, Username, Password
7 | # 10.1.1.20,Administrator,mypassword
8 | # 10.1.1.21,Administrator,mypassword
9 | #
10 | # Step 3: run this PS script with 1 param, the CSV file name
11 | #
12 | # > .\CollectBladeInfo.ps1 .\myOAs.csv
13 | #
14 | # Step 4: Review results
15 | # The new "output" file will be in the same directory as input file
16 | # example: .\myOAs-output.csv
17 |
18 | Param(
19 | [string]$OAListFile
20 | )
21 |
22 | if ( -not (Test-path $OAListFile))
23 | {
24 | write-host "`n Parameter of 'CSV file' not valid! '$OAListFile' `n"
25 | exit
26 | }
27 |
28 | # Import/load the HPE OA Cmdlet
29 | Import-Module HPOACmdlets
30 |
31 | # Read in the CSV content
32 | write-host "`n Reading $($OAListFile) file.... "
33 | $OA_List = Import-Csv $OAListFile
34 |
35 | # Set output CSV file name
36 | $outputfile = "$((Get-Item $OAListFile).Basename)-output.csv"
37 |
38 | # Delete output file if already exists
39 | if (Test-Path $outputfile)
40 | {
41 | Remove-Item $outputfile
42 | }
43 |
44 | # Loop through each OA specified in CSV file
45 | foreach ( $OA in $OA_List )
46 | {
47 | write-host "`n Connecting to OA - $($OA.IP) using user name: $($OA.UserName) (this may take a few secs...) "
48 | $OAConnection = Connect-HPOA -OA $OA.IP -Password $OA.Password -Username $OA.UserName
49 | if ($?) # Check if the above connect command was successful
50 | {
51 | if ( $((Get-HPOAStatus -Connection $OAConnection).OnboardAdministrator.Role) -like "Active" )
52 | {
53 | write-host " gathering blade info.... "
54 | $OACollectData = Get-HPOAServerInfo -Connection $OAConnection
55 | write-host " writing information to csv file '$outputfile' "
56 | $OACollectData.ServerBlade | select @{Name='OA';Expression={$($OA.IP)}}, Bay, Type, ProductName, PartNumber, SerialNumber, Memory | Export-Csv -Append $outputfile -notypeinformation
57 | write-host " disconnecting from OA. "
58 | Disconnect-HPOA -Connection $OAConnection
59 | }
60 | else
61 | {
62 | write-host " OA status is not 'Active', OA skipped. "
63 | }
64 | }
65 | else
66 | {
67 | write-host " Failed to connect to $($OA.IP) using user name: $($OA.UserName) OA skipped. "
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/HPEOA/Community Scripts/README.md:
--------------------------------------------------------------------------------
1 | # PowerShell samples by users for HPOA cmdlets
2 |
3 | This location contains scripts using "Scripting Tools for Windows PowerShell: HPOACmdlets". These scripts have been provided by users of the cmdlets for various use cases for managing HPE servers using the Onboard Administrators.
4 |
5 | ## Getting Started
6 |
7 | Install the HPOACmdlets from https://www.hpe.com/servers/powershell on an system that will be used for administration of HPE servers. Once the cmdlets are installed, these sample scripts can be executed on an administrator client.
8 |
9 | ### Prerequisites
10 |
11 | HPOACmdlets are required for the samples to execute correctly. These cmdlets are available at https://www.hpe.com/servers/powershell
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/HPEOA/GetOADetails.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [string]$OA,
3 | [string]$Username,
4 | [string]$Password
5 | )
6 |
7 | if($OA -eq "")
8 | {
9 | $OA = Read-Host "Enter OA Address"
10 | }
11 |
12 | if($Username -eq "")
13 | {
14 | $Username = Read-Host "Enter Username"
15 | }
16 |
17 | if($Password -eq "")
18 | {
19 | $Password = Read-Host "Enter Password"
20 | }
21 |
22 | $connection = Connect-HPOA -OA $OA -Username $Username -Password $Password
23 |
24 | if($connection -eq $null)
25 | {
26 | Write-Host "Connection cannot be established."
27 | exit
28 | }
29 |
30 | $result = $connection | Get-HPOAFRU
31 |
32 |
33 | Write-Host "***** OA details *****" -ForegroundColor Yellow
34 | Write-Host ""
35 | Write-Host "OAIP `t`t:`t $($result.IP)"
36 | $result.OnboardAdministrator
37 |
38 | Write-Host "***** Blade details *****" -ForegroundColor Yellow
39 | Write-Host ""
40 | $result.Blade
41 |
42 | Write-Host "***** Interconnect details *****" -ForegroundColor Yellow
43 | Write-Host ""
44 | $result.Interconnect
45 | [array]$VCBayList = @()
46 | foreach($interconnect in $result.Interconnect)
47 | {
48 | if($interconnect.Model -match "VC")
49 | {
50 | $customObj = New-Object psobject
51 | $customObj | Add-member NoteProperty VCModuleName $interconnect.Model
52 | $customObj | Add-member NoteProperty BayNumber $interconnect.Bay
53 | $VCBayList += $customObj
54 | }
55 | }
56 |
57 |
58 | $interconnectDetails = $connection | Get-HPOAEBIPA
59 |
60 | foreach($obj in $VCBayList)
61 | {
62 | foreach($item in $interconnectDetails.EBIPADeviceInterconnectSettings)
63 | {
64 | if($Obj.BayNumber -eq $item.Bay)
65 | {
66 | $obj | Add-member NoteProperty VCIP $item.EBIPA
67 | }
68 | }
69 |
70 | }
71 |
72 | Write-host "***** VC IP Address ******" -ForegroundColor Yellow
73 | Write-Host ""
74 | $VCBayList
75 |
76 | Write-Host "***** Enclosure details *****" -ForegroundColor Yellow
77 | Write-Host ""
78 | $result.Enclosure
79 |
80 | Disconnect-HPOA -Connection $connection
81 |
82 |
--------------------------------------------------------------------------------
/HPEOSProvisioning/AddUnattendXmlAndDrivers.ps1:
--------------------------------------------------------------------------------
1 | ########################################################
2 | #Add autounattend.xml and drivers into Windows ISO file
3 | ########################################################
4 |
5 | <#
6 | .Synopsis
7 | This script allows user to add autounattend.xml and drivers into input windows ISO.
8 |
9 | .DESCRIPTION
10 | This script allows user to add autounattend.xml and drivers into input windows ISO. This will create a new ISO based on OutputFile input.
11 | ImageFile :- Use this option to specify the windows ISO file as input.
12 |
13 | ImageIndex :- Use this option to specify the install.wim image index.
14 |
15 | DiskPartitionMode :- Use this option to specify the disk partition mode either it can be UEFI or LegacyMode.
16 |
17 | InstallToDiskID :- Use this option to specify the disk ID to install the windows.
18 |
19 | Password :- Use this option to specify the password for windows user.
20 |
21 | Driver :- Use this option to specify the driver(s) folder path.
22 |
23 | .EXAMPLE
24 | AddUnattendXmlAndDrivers.ps1
25 | This mode of execution of script will prompt for
26 |
27 | ImageFile :- Accept windows ISO full path.
28 |
29 | ImageIndex :- Accept Install.wim image index.
30 |
31 | DiskPartitionMode :- Accept the disk partition mode either it can be UEFI or LegacyMode.
32 |
33 | InstallToDiskID :- Accept the disk ID to install the windows.
34 |
35 | Password :- Accept the password for windows user.
36 |
37 | Driver :- Accept the driver(s) folder path.
38 |
39 | .EXAMPLE
40 | AddUnattendXmlAndDrivers.ps1 -ImageFile "C:\TestFolder\Windows2016_Datacenter.iso" -ImageIndex 4 -DiskPartitionMode UEFI -InstallToDiskID 0 -Password admin123 -Driver C:\TestFolder\Drivers
41 |
42 | .NOTES
43 |
44 | Company : Hewlett Packard Enterprise
45 | Version : 1.0.0.1
46 | Date : 27/11/2017
47 |
48 | .INPUTS
49 | Inputs to this script file
50 | ImageFile
51 | ImageIndex
52 | DiskPartitionMode
53 | InstallToDiskID
54 | Password
55 | Driver
56 | OutputFile
57 |
58 | .OUTPUTS
59 | System.Management.Automation.PSObject[]
60 |
61 | .LINK
62 | http://www.hpe.com/servers/powershell
63 | https://github.com/HewlettPackard/PowerShell-ProLiant-SDK/tree/master/HPEOSProvisioning
64 |
65 | #>
66 |
67 | #Command line parameters
68 | Param(
69 | [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [ValidatePattern('^(?:[\w]\:)(\\[A-Za-z_\-\s0-9\.]+)+\.((i|I)(s|S)(o|O))$')] [ValidateNotNullOrEmpty()] [string] $ImageFile,
70 | [Parameter(Mandatory=$true, Position = 1, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidateRange(1, 8)] [int] $ImageIndex,
71 | [Parameter(Mandatory=$true, Position = 2, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidateSet('LegacyBIOS', 'UEFI')] [ValidateNotNullOrEmpty()] [string] $DiskPartitionMode,
72 | [Parameter(Mandatory=$true, Position = 3, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidateRange(0, 100)] [int] $InstallToDiskID,
73 | [Parameter(Mandatory=$true, Position = 4, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidateLength(0, 63)] [ValidateNotNullOrEmpty()] [string] $Password,
74 | [Parameter(Mandatory=$true, Position = 5, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidateNotNullOrEmpty()] [string] $Driver,
75 | [Parameter(Mandatory=$false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidatePattern('^(?:[\w]\:)(\\[A-Za-z_\-\s0-9\.]+)+\.((i|I)(s|S)(o|O))$')] [ValidateNotNullOrEmpty()] [string] $OutputFile
76 | )
77 |
78 |
79 |
80 | #clear host
81 | Clear-Host
82 |
83 | # script execution started
84 | Write-Host "****** Script execution started ******" -ForegroundColor Yellow
85 | Write-Host ""
86 | #Decribe what script does to the user
87 |
88 | Write-Host "This script allows user to get the windows image index details in input ISO file."
89 | Write-Host ""
90 |
91 |
92 | #check powershell supported version
93 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
94 |
95 | if($PowerShellVersion -ge "4")
96 | {
97 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script."
98 | Write-Host ""
99 | }
100 | else
101 | {
102 | Write-Host "This script required PowerSehll 3 or above."
103 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)."
104 | Write-Host "Please Update PowerShell version."
105 | Write-Host ""
106 | Write-Host "Exit..."
107 | Write-Host ""
108 | exit
109 | }
110 |
111 | #Load HPEOSProvisionCmdlets module
112 |
113 | $InstalledModule = Get-Module
114 | $ModuleNames = $InstalledModule.Name
115 |
116 | if(-not($ModuleNames -like "HPEOSProvisionCmdlets"))
117 | {
118 | Write-Host "Loading module : HPEOSProvisionCmdlets"
119 | Import-Module HPEOSProvisionCmdlets
120 | if(($(Get-Module -Name "HPEOSProvisionCmdlets") -eq $null))
121 | {
122 | Write-Host ""
123 | Write-Host "HPEOSProvisionCmdlets module cannot be loaded. Please fix the problem and try again"
124 | Write-Host ""
125 | Write-Host "Exit..."
126 | exit
127 | }
128 | }
129 | elseif($ModuleNames -like "HPEOSProvisionCmdlets")
130 | {
131 | $InstalledOSPModule = Get-Module -Name "HPEOSProvisionCmdlets"
132 | Write-Host "HPEOSProvisionCmdlets Module Version : $($InstalledOSPModule.Version) is installed on your machine."
133 | Write-host ""
134 | }
135 | else
136 | {
137 | $InstalledOSPModule = Get-Module -Name "HPEOSProvisionCmdlets" -ListAvailable
138 | Write-Host "HPEOSProvisionCmdlets Module Version : $($InstalledOSPModule.Version) is installed on your machine."
139 | Write-host ""
140 | }
141 |
142 | Write-Host "Enabling HPEOSProvisioningCmdlets log"
143 | Write-Host ""
144 |
145 | Enable-HPEOSPLog -ErrorAction Stop
146 |
147 | Write-Host "Adding autounattend.xml file into ISO file '$ImageFile'."
148 | Write-Host ""
149 |
150 | if ($PSBoundParameters.ContainsKey('OutputFile'))
151 | {
152 | Use-HPEOSPWindowsUnattend -ImageFile $ImageFile -ImageIndex $ImageIndex -DiskPartitionMode $DiskPartitionMode -InstallToDiskID $InstallToDiskID -Password $Password -OutputFile $OutputFile -ErrorAction Stop
153 | }
154 | else
155 | {
156 | Use-HPEOSPWindowsUnattend -ImageFile $ImageFile -ImageIndex $ImageIndex -DiskPartitionMode $DiskPartitionMode -InstallToDiskID $InstallToDiskID -Password $Password -ErrorAction Stop
157 | }
158 |
159 | Write-Host "Adding driver(s) into ISO file '$ImageFile' at ImageIndex '$ImageIndex'."
160 | Write-Host ""
161 |
162 | if ($PSBoundParameters.ContainsKey('OutputFile'))
163 | {
164 | Add-HPEOSPWindowsDriver -ImageFile $OutputFile -Driver $Driver -ImageIndex $ImageIndex -OutputFile $OutputFile -ErrorAction Stop
165 | }
166 | else
167 | {
168 | Add-HPEOSPWindowsDriver -ImageFile $ImageFile -Driver $Driver -ImageIndex $ImageIndex -ErrorAction Stop
169 | }
170 |
171 | Write-Host "Disabling HPEOSProvisioningCmdlets log"
172 | Write-Host ""
173 |
174 | Disable-HPEOSPLog -ErrorAction Stop
175 |
176 | Write-Host "****** Script execution completed ******" -ForegroundColor Yellow
177 | exit
--------------------------------------------------------------------------------
/HPEOSProvisioning/GetWindowsImageIndex.ps1:
--------------------------------------------------------------------------------
1 | ########################################################
2 | #Get Windows Image Index
3 | ########################################################
4 |
5 | <#
6 | .Synopsis
7 | This script allows user to get the windows image index details in input ISO file.
8 |
9 | .DESCRIPTION
10 | This script allows user to get the windows image index details in input ISO file.
11 | ImageFile :- Use this option to specify the windows ISO file as input.
12 |
13 | .EXAMPLE
14 | GetWindowsImageIndex.ps1
15 | This mode of execution of script will prompt for
16 |
17 | ImageFile :- Accept windows ISO full path.
18 |
19 | .EXAMPLE
20 | ConfigureBootMode.ps1 -ImageFile "C:\TestFolder\Windows2016_Datacenter.iso"
21 |
22 | .NOTES
23 |
24 | Company : Hewlett Packard Enterprise
25 | Version : 1.0.0.1
26 | Date : 27/11/2017
27 |
28 | .INPUTS
29 | Inputs to this script file
30 | ImageFile
31 |
32 | .OUTPUTS
33 | System.Management.Automation.PSObject[]
34 |
35 | .LINK
36 | http://www.hpe.com/servers/powershell
37 | https://github.com/HewlettPackard/PowerShell-ProLiant-SDK/tree/master/HPEOSProvisioning
38 |
39 | #>
40 |
41 | #Command line parameters
42 | Param(
43 | [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^(?:[\w]\:)(\\[A-Za-z_\-\s0-9\.]+)+\.((i|I)(s|S)(o|O))$')] [ValidateNotNullOrEmpty()] [string] $ImageFile
44 | )
45 |
46 | #clear host
47 | Clear-Host
48 |
49 | # script execution started
50 | Write-Host "****** Script execution started ******" -ForegroundColor Yellow
51 | Write-Host ""
52 | #Decribe what script does to the user
53 |
54 | Write-Host "This script allows user to get the windows image index details in input ISO file."
55 | Write-Host ""
56 |
57 |
58 | #check powershell supported version
59 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
60 |
61 | if($PowerShellVersion -ge "4")
62 | {
63 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script."
64 | Write-Host ""
65 | }
66 | else
67 | {
68 | Write-Host "This script required PowerSehll 3 or above."
69 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)."
70 | Write-Host "Please Update PowerShell version."
71 | Write-Host ""
72 | Write-Host "Exit..."
73 | Write-Host ""
74 | exit
75 | }
76 |
77 | Write-Host "Mounting the image file $ImageFile."
78 | Write-Host ""
79 |
80 | $mountResult = Mount-DiskImage -ImagePath $ImageFile -Verbose -PassThru -ErrorAction Stop
81 |
82 | if($null -ne $mountResult)
83 | {
84 | $drive = ($mountResult | Get-Volume -ErrorAction Stop).DriveLetter + ':'
85 |
86 | Write-Host "Image file '$ImageFile' is successfully mounted at $drive"
87 | Write-Host ""
88 |
89 | $installWimPath = [System.IO.Path]::Combine($drive + '\', "sources\install.wim")
90 |
91 | Write-Host "Reading the windows image index in $installWimPath."
92 | Write-Host ""
93 | $WindowsImage = Get-WindowsImage -ImagePath $installWimPath -ErrorAction Stop
94 |
95 | $WindowsImage
96 |
97 | Write-Host "Dismounting the image file $ImageFile."
98 | Write-Host ""
99 | Dismount-DiskImage -ImagePath $ImageFile -ErrorAction Stop
100 | }
101 |
102 | Write-Host "****** Script execution completed ******" -ForegroundColor Yellow
103 | exit
--------------------------------------------------------------------------------
/HPEOSProvisioning/InstallWindowsOS.ps1:
--------------------------------------------------------------------------------
1 | ########################################################
2 | #Install Windows ISO file on Gen10 servers
3 | ########################################################
4 |
5 | <#
6 | .Synopsis
7 | This script allows user to install the windows OS on target server.
8 |
9 | .DESCRIPTION
10 | This script allows user to install the windows OS on target server.
11 | Address :- Use this option to specify the target server IP or hostname.
12 |
13 | Credential :- Use this option to specify the target server credentials.
14 |
15 | ImageURL :- Use this option to specify the windows ISO image URL path.
16 |
17 | .EXAMPLE
18 | InstallWindowsOS.ps1
19 | This mode of execution of script will prompt for
20 |
21 | Address :- accpet IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
22 |
23 | Credential :- it will prompt for user name and password. In case multiple server IP(s) or Hostname(s) it is recommended to use same user credentials
24 |
25 | ImageURL :- Accept the ISO image http or https URL path.
26 |
27 | .EXAMPLE
28 | $cred = Get-Credential
29 | cmdlet Get-Credential at command pipeline position 1
30 | Supply values for the following parameters:
31 | InstallWindowsOS.ps1 -Address 10.20.30.1 -Credential $cred -ImageURL http://10.20.30.40/TestImage/WindowsServer2016_datacenter.iso
32 |
33 | .EXAMPLE
34 | $cred = Get-Credential
35 | cmdlet Get-Credential at command pipeline position 1
36 | Supply values for the following parameters:
37 | InstallWindowsOS.ps1 -Address 10.20.30.1,10.20.30.2,10.20.30.3 -Credential $cred -ImageURL http://10.20.30.40/TestImage/WindowsServer2016_datacenter.iso
38 |
39 | .NOTES
40 |
41 | Company : Hewlett Packard Enterprise
42 | Version : 1.0.0.1
43 | Date : 27/11/2017
44 |
45 | .INPUTS
46 | Inputs to this script file
47 | Address
48 | Credential
49 | ImageURL
50 |
51 | .OUTPUTS
52 | System.Management.Automation.PSObject[]
53 |
54 | .LINK
55 | http://www.hpe.com/servers/powershell
56 | https://github.com/HewlettPackard/PowerShell-ProLiant-SDK/tree/master/HPEOSProvisioning
57 |
58 | #>
59 |
60 | #Command line parameters
61 | Param(
62 | [Parameter(Mandatory=$true, Position = 0, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [string[]] $Address,
63 | [Parameter(Mandatory=$true, Position = 1, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [PSCredential] $Credential,
64 | [Parameter(Mandatory=$true, Position = 2, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)] [ValidatePattern('(^$|^https?:\/\/((?:\S+(?::\S*)?@)?(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])|(([^:\-\.\/\s]([^:\.\/\s]*[^:\-\.\/\s])?\.)*[a-zA-z][a-zA-Z0-9]*))(:\d{1,5})?|\[([0-9a-fA-F]{0,4}:){2,7}(:|[0-9a-fA-F]{1,4})\])\/[^\s]+\.((i|I)(s|S)(o|O))$)')] [ValidateNotNullOrEmpty()] [string] $ImageURL
65 | )
66 |
67 |
68 | #Check for server avaibiality
69 | function CheckServerAvailability ($ListOfAddress)
70 | {
71 | [int] $pingFailureCount = 0
72 | [array] $PingedServerList = @()
73 | foreach($serverAddress in $ListOfAddress)
74 | {
75 | if(Test-Connection $serverAddress)
76 | {
77 | $PingedServerList += $serverAddress
78 | }
79 | else
80 | {
81 | Write-Host ""
82 | Write-Host "Server $serverAddress is not reachable. Please check network connectivity"
83 | $pingFailureCount ++
84 | }
85 | }
86 |
87 | if($pingFailureCount -eq $ListOfAddress.Count)
88 | {
89 | Write-Host ""
90 | Write-Host "Server(s) are not reachable please check network conectivity"
91 | exit
92 | }
93 | return $PingedServerList
94 | }
95 |
96 | #clear host
97 | Clear-Host
98 |
99 | # script execution started
100 | Write-Host "****** Script execution started ******" -ForegroundColor Yellow
101 | Write-Host ""
102 | #Decribe what script does to the user
103 |
104 | Write-Host "This script allows user to get the windows image index details in input ISO file."
105 | Write-Host ""
106 |
107 |
108 | #check powershell supported version
109 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
110 |
111 | if($PowerShellVersion -ge "4")
112 | {
113 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script."
114 | Write-Host ""
115 | }
116 | else
117 | {
118 | Write-Host "This script required PowerSehll 3 or above."
119 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)."
120 | Write-Host "Please Update PowerShell version."
121 | Write-Host ""
122 | Write-Host "Exit..."
123 | Write-Host ""
124 | exit
125 | }
126 |
127 | #Load HPEOSProvisionCmdlets module
128 |
129 | $InstalledModule = Get-Module
130 | $ModuleNames = $InstalledModule.Name
131 |
132 | if(-not($ModuleNames -like "HPEOSProvisionCmdlets"))
133 | {
134 | Write-Host "Loading module : HPEOSProvisionCmdlets"
135 | Import-Module HPEOSProvisionCmdlets
136 | if(($(Get-Module -Name "HPEOSProvisionCmdlets") -eq $null))
137 | {
138 | Write-Host ""
139 | Write-Host "HPEOSProvisionCmdlets module cannot be loaded. Please fix the problem and try again"
140 | Write-Host ""
141 | Write-Host "Exit..."
142 | exit
143 | }
144 | }
145 | elseif($ModuleNames -like "HPEOSProvisionCmdlets")
146 | {
147 | $InstalledOSPModule = Get-Module -Name "HPEOSProvisionCmdlets"
148 | Write-Host "HPEOSProvisionCmdlets Module Version : $($InstalledOSPModule.Version) is installed on your machine."
149 | Write-host ""
150 | }
151 | else
152 | {
153 | $InstalledOSPModule = Get-Module -Name "HPEOSProvisionCmdlets" -ListAvailable
154 | Write-Host "HPEOSProvisionCmdlets Module Version : $($InstalledOSPModule.Version) is installed on your machine."
155 | Write-host ""
156 | }
157 |
158 | # Check for IP(s) or Hostname(s) Input. if not available prompt for Input
159 | if($Address.Count -eq 0)
160 | {
161 | $Address = Read-Host "Enter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
162 | }
163 |
164 | [array]$ListOfAddress = ($Address.Trim().Split(','))
165 |
166 | if($ListOfAddress.Count -eq 0)
167 | {
168 | Write-Host "You have not entered IP(s) or Hostname(s)"
169 | Write-Host ""
170 | Write-Host "Exit..."
171 | exit
172 | }
173 |
174 | if($Credential -eq $null)
175 | {
176 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
177 | Write-Host ""
178 | }
179 |
180 | #Ping and test IP(s) or Hostname(s) are reachable or not
181 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
182 |
183 | Write-Host "Enabling HPEOSProvisioningCmdlets log"
184 | Write-Host ""
185 |
186 | Enable-HPEOSPLog -ErrorAction Stop
187 |
188 |
189 | # create connection object
190 | [array]$ListOfConnection = @()
191 |
192 | foreach($IPAddress in $ListOfAddress)
193 | {
194 |
195 | Write-Host ""
196 | Write-Host "Connecting to server : $IPAddress"
197 | $connection = Connect-HPEOSP -IP $IPAddress -Credential $Credential
198 |
199 | #Retry connection if it is failed because of invalid certificate with -DisableCertificateAuthentication switch parameter
200 | if($Error[0] -match "The underlying connection was closed")
201 | {
202 | $connection = Connect-HPEOSP -IP $IPAddress -Credential $Credential -DisableCertificateAuthentication
203 | }
204 |
205 | if($connection -ne $null)
206 | {
207 | Write-Host ""
208 | Write-Host "Connection established to the server $IPAddress" -ForegroundColor Green
209 | $connection
210 | if($connection.ProductName.Contains("Gen10"))
211 | {
212 | $ListOfConnection += $connection
213 | }
214 | else
215 | {
216 | Write-Host "Boot mode is not supported on Server $($connection.IP)"
217 | Disconnect-HPEOSP -Connection $connection
218 | }
219 | }
220 | else
221 | {
222 | Write-Host "Connection cannot be eastablished to the server : $IPAddress" -ForegroundColor Red
223 | }
224 | }
225 |
226 | if($ListOfConnection.Count -eq 0)
227 | {
228 | Write-Host "Exit..."
229 | Write-Host ""
230 | exit
231 | }
232 |
233 | Write-Host ""
234 | Write-Host "Invoke windows image to install on target servers" -ForegroundColor Green
235 | Write-Host ""
236 | $counter = 1
237 | foreach($serverConnection in $ListOfConnection)
238 | {
239 | $result = Install-HPEOSPWindowsImage -Connection $serverConnection -ImageURL $ImageURL
240 | Write-Host "------------------------ Server $counter ------------------------" -ForegroundColor Yellow
241 | Write-Host ""
242 | $result
243 | $counter++
244 | }
245 |
246 |
247 | Write-Host "Disabling HPEOSProvisioningCmdlets log"
248 | Write-Host ""
249 |
250 | Disable-HPEOSPLog -ErrorAction Stop
251 |
252 | Write-Host "****** Script execution completed ******" -ForegroundColor Yellow
253 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/BootModeConfigurations.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to change boot mode (UEFI / Legacy) of HPE Proliant Gen 9 servers through iLO
4 |
5 | .DESCRIPTION
6 | This script allows user to change the boot mode.
7 | BootMode :- Use this option to set the boot mode for the system through iLO. HP ProLiant Gen9 servers provide two boot mode
8 | configurations: UEFI Mode and Legacy BIOS Mode.
9 |
10 | .EXAMPLE
11 | ConfigureBootMode.ps1
12 | This mode of exetion of script will prompt for
13 | Address :- accpet IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
14 | Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
15 | BootMode :- Accepted values are Legacy_BIOS_Mode or UEFI_Mode.For multiple servers values should be separated by comma(,)
16 |
17 | .EXAMPLE
18 | ConfigureBootMode.ps1 -Address "10.20.30.40,10.20.30.1" -Credential $userCredential -BootMode "UEFI,legacy"
19 | This mode of script have input parameter for Address Credential and BootMode
20 | -Address:- Use this parameter to specify IP(s) or Hostname(s) of the server(s). In the of case multiple entries it should be separated by comma(,)
21 | -Credential :- Use this parameter to sepcify user credential.
22 | -BootMode :- Use this Parameter to specify boot mode. Accepted values are Legacy_BIOS_Mode or UEFI_Mode
23 |
24 | .NOTES
25 | Company : Hewlett Packard Enterprise
26 | Version : 1.4.0.0
27 |
28 | .INPUTS
29 | Inputs to this script file
30 | Address
31 | Credential
32 | BootMode
33 |
34 | .OUTPUTS
35 | None (by default)
36 |
37 | .LINK
38 |
39 | http://www.hpe.com/servers/powershell
40 | #>
41 |
42 | #Command line parameters
43 | Param(
44 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
45 | [PSCredential]$Credential, # all server should have same ceredntial (in case of multiple addresses)
46 | [String]$BootMode # Boot mode (UEFI or LegacyBIOS)
47 | )
48 |
49 | #Check for server avaibiality
50 | function CheckServerAvailability ($ListOfAddress)
51 | {
52 | [int]$pingFailureCount = 0
53 | [array]$PingedServerList = @()
54 | foreach($serverAddress in $ListOfAddress)
55 | {
56 | if(Test-Connection $serverAddress)
57 | {
58 | $PingedServerList += $serverAddress
59 | }
60 | else
61 | {
62 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
63 | $pingFailureCount ++
64 | }
65 | }
66 |
67 | if($pingFailureCount -eq $ListOfAddress.Count)
68 | {
69 | Write-Host ""
70 | Write-Host "Server(s) are not reachable please check network conectivity"
71 | exit
72 | }
73 | return $PingedServerList
74 | }
75 |
76 | #clear host
77 | Clear-Host
78 |
79 | # script execution started
80 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
81 | #Decribe what script does to the user
82 |
83 | Write-Host "This script allows user to change boot mode.`n"
84 |
85 | $ErrorActionPreference = "SilentlyContinue"
86 | $WarningPreference ="SilentlyContinue"
87 | #check powershell support
88 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
89 |
90 | if($PowerShellVersion -ge "3")
91 | {
92 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script"
93 | }
94 | else
95 | {
96 | Write-Host "`nThis script required PowerSehll 3 or above"
97 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
98 | Write-Host "Please Update PowerShell version`n"
99 | Write-Host "Exit...`n"
100 | exit
101 | }
102 |
103 | #Load HPiLOCmdlets module
104 | $InstalledModule = Get-Module
105 | $ModuleNames = $InstalledModule.Name
106 |
107 | if(-not($ModuleNames -like "HPiLOCmdlets"))
108 | {
109 | Write-Host "Loading module : HPiLOCmdlets"
110 | Import-Module HPiLOCmdlets
111 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
112 | {
113 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again"
114 | Write-Host "Exit..."
115 | exit
116 | }
117 | }
118 | else
119 | {
120 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
121 | Write-Host "`nHPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
122 | }
123 |
124 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
125 | if($Address -eq "")
126 | {
127 | $Address = Read-Host "`nEnter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
128 | Write-Host ""
129 | }
130 |
131 | [array]$ListOfAddress = ($Address.Trim().Split(','))
132 |
133 | if($ListOfAddress.Count -eq 0)
134 | {
135 | Write-Host "`nYou have not entered IP(s) or Hostname(s)`n"
136 | Write-Host "Exit..."
137 | exit
138 | }
139 |
140 | if($Credential -eq $null)
141 | {
142 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
143 | }
144 |
145 | # Ping and test IP(s) or Hostname(s) are reachable or not
146 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
147 |
148 | Write-Host ("`nSupported Boot Mode for the server(s)") -ForegroundColor Yellow
149 | $result= Get-HPiLOSupportedBootMode -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
150 | $result
151 |
152 | Write-Host ("`nCurrent Boot Mode for the server(s)") -ForegroundColor Yellow
153 | $result= Get-HPiLOCurrentBootMode -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
154 | $result
155 |
156 | Write-Host ("`nPending Boot Mode for the server(s)") -ForegroundColor Yellow
157 | $result= Get-HPiLOPendingBootMode -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
158 | $result
159 |
160 | $parameterMetaData = $(Get-Command -Name Set-HPiLOPendingBootMode).Parameters
161 | $bootModeValidValues = $($parameterMetaData["BootMode"].Attributes | where {$_.TypeId.Name -eq "ValidateSetAttribute"}).ValidValues
162 |
163 | #Prompt for User input if it is not given as script parameter
164 | Write-Host "`nInput Hint : For multiple server please enter parameter values seprated by comma(,)" -ForegroundColor Yellow
165 | if($BootMode -eq "")
166 | {
167 | $BootMode = Read-Host "`nEnter Boot Mode [Accepted values : ($($bootModeValidValues -join ","))]."
168 | }
169 |
170 | $inputBootModeList = ($BootMode.Trim().Split(','))
171 |
172 | if($inputBootModeList.Count -eq 0)
173 | {
174 | Write-Host "`nYou have not enterd boot mode"
175 | Write-Host "`nExit....."
176 | exit
177 | }
178 |
179 | Write-Host "`nChanging Boot mode....." -ForegroundColor Green
180 |
181 | $failureCount = 0
182 |
183 | for($i=0;$i -lt $ListOfAddress.Count;$i++)
184 | {
185 | if($ListOfAddress.Count -eq 1)
186 | {
187 | $result= Set-HPiLOPendingBootMode -Server $ListOfAddress[$i] -Credential $Credential -BootMode $BootModeToset -DisableCertificateAuthentication
188 | }
189 | else
190 | {
191 | $result= Set-HPiLOPendingBootMode -Server $ListOfAddress[$i] -Credential $Credential -BootMode $BootModeToset[$i] -DisableCertificateAuthentication
192 | }
193 | if($result.STATUS_TYPE -eq "Error")
194 | {
195 | Write-Host "`nBoot mode Cannot be changed"
196 | Write-Host "Server : $($result.IP)"
197 | Write-Host "Error : $($result.STATUS_MESSAGE)"
198 | $failureCount++
199 | }
200 | else
201 | {
202 | Write-host "`nBoot mode changed successfully" -ForegroundColor Green
203 | Write-Host "Server : $($result.IP)"
204 | Write-Host "WARNING : $($result.STATUS_MESSAGE)"
205 | }
206 | }
207 |
208 | if($failureCount -ne $ListOfAddress.Count)
209 | {
210 | Write-Host ("`nPending Boot Mode for the server(s)") -ForegroundColor Yellow
211 | $result= Get-HPiLOPendingBootMode -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
212 | $result
213 | }
214 | $ErrorActionPreference = "Continue"
215 | $WarningPreference ="Continue"
216 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
217 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/DecodeSMBIOSRecord.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to read the SMBIOS record and displays some of the record values.
4 |
5 | .DESCRIPTION
6 | This script decodes the SMBIOS records that is encoded in base64 format and displays some of the record values.
7 |
8 |
9 | .EXAMPLE
10 | DecodeSMBIOSRecord.ps1
11 | This mode of execution of script will prompt for
12 | Address :- accept IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
13 | Credential :-Use this parameter to sepcify user credential.In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
14 |
15 | .EXAMPLE
16 | DecodeSMBIOSRecord.ps1 -Address "10.20.30.40,10.20.30.1" -Credential $Credential
17 |
18 | This mode of script have input parameter for Address,Username, Password and location
19 | -Address:- Use this parameter to specify IP(s) or Hostname(s) of the server(s). In the of case multiple entries it should be separated by comma(,)
20 | -Credential :-Use this parameter to sepcify user credential.In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
21 |
22 | .NOTES
23 | Company : Hewlett Packard Enterprise
24 | Version : 1.4.0.0
25 |
26 | .INPUTS
27 | Inputs to this script file
28 | Address
29 | Username
30 | Password
31 | Location
32 |
33 | .OUTPUTS
34 | None (by default)
35 |
36 | .LINK
37 |
38 | http://www.hpe.com/servers/powershell
39 | #>
40 |
41 | #Command line parameters
42 | Param(
43 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
44 | [PSCredential]$Credential
45 |
46 | )
47 |
48 | #Check for server avaibiality
49 | function CheckServerAvailability ($ListOfAddress)
50 | {
51 | [int]$pingFailureCount = 0
52 | [array]$PingedServerList = @()
53 | foreach($serverAddress in $ListOfAddress)
54 | {
55 | if(Test-Connection $serverAddress)
56 | {
57 | #Write-Host "Server $serverAddress pinged successfully."
58 | $PingedServerList += $serverAddress
59 | }
60 | else
61 | {
62 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
63 | $pingFailureCount ++
64 | }
65 | }
66 |
67 | if($pingFailureCount -eq $ListOfAddress.Count)
68 | {
69 | Write-Host "`nServer(s) are not reachable please check network conectivity"
70 | exit
71 | }
72 | return $PingedServerList
73 | }
74 | #clear host
75 | Clear-Host
76 |
77 | # script execution started
78 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
79 | #Decribe what script does to the user
80 |
81 | Write-Host "This script displays some of the decoded SMBIOS records that is encoded in base64 format.`n"
82 |
83 | $ErrorActionPreference = "SilentlyContinue"
84 | $WarningPreference ="SilentlyContinue"
85 | #check powershell support
86 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
87 |
88 | if($PowerShellVersion -ge "3")
89 | {
90 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script`n"
91 | }
92 | else
93 | {
94 | Write-Host "This script required PowerSehll 3 or above"
95 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
96 | Write-Host "Please Update PowerShell version`n"
97 | Write-Host "Exit...`n"
98 | exit
99 | }
100 |
101 | #Load HPiLOCmdlets module
102 |
103 | $InstalledModule = Get-Module
104 | $ModuleNames = $InstalledModule.Name
105 |
106 | if(-not($ModuleNames -like "HPiLOCmdlets"))
107 | {
108 | Write-Host "Loading module : HPiLOCmdlets"
109 | Import-Module HPiLOCmdlets
110 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
111 | {
112 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again`n"
113 | Write-Host "Exit..."
114 | exit
115 | }
116 | }
117 | else
118 | {
119 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
120 | Write-Host "HPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine.`n"
121 | }
122 |
123 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
124 |
125 | if($Address -eq "")
126 | {
127 | $Address = Read-Host "Enter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
128 | }
129 |
130 | [array]$ListOfAddress = ($Address.Trim().Split(','))
131 |
132 | if($ListOfAddress.Count -eq 0)
133 | {
134 | Write-Host "`nYou have not entered IP(s) or Hostname(s)`n"
135 | Write-Host "Exit..."
136 | exit
137 | }
138 |
139 | if($Credential -eq $null)
140 | {
141 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
142 | }
143 |
144 | # Ping and test IP(s) or Hostname(s) are reachable or not
145 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
146 |
147 | foreach($IPAddress in $ListOfAddress)
148 | {
149 |
150 | $result = Get-HPiLOHostData -Server $IPAddress -Credential $Credential -DisableCertificateAuthentication
151 | Write-Host ("`nDecoding the SMBIOS Record for the server {0}" -f ($IPAddress)) -ForegroundColor Yellow
152 | $record= $result | Read-HPiLOSMBIOSRecord
153 | foreach ($field in $record) {
154 |
155 | #if ([string]::IsNullOrEmpty($field.BIOS_VERSION) -or [string]::IsNullOrEmpty($field.PRODUCT_NAME) -or [string]::IsNullOrEmpty($field.SERIAL_NUMBER) -or [string]::IsNullOrEmpty($field.PROCESSOR_MANUFACTURER) -or [string]::IsNullOrEmpty($field.BOOT_UP_STATE) -or [string]::IsNullOrEmpty($field.POWER_SUPPLY_STATE) -or [string]::IsNullOrEmpty($field.THERMAL_STATE)) {
156 | if(-Not [string]::IsNullOrEmpty($field.BIOS_VERSION))
157 | {
158 | $name="BIOS_VERSION";$value=$field.BIOS_VERSION
159 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
160 | }
161 | if(-Not [string]::IsNullOrEmpty($field.PRODUCT_NAME))
162 | {
163 | $name="PRODUCT_NAME";$value=$field.PRODUCT_NAME
164 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
165 | }
166 | if(-Not [string]::IsNullOrEmpty($field.SERIAL_NUMBER))
167 | {
168 | $name="SERIAL_NUMBER";$value=$field.SERIAL_NUMBER
169 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
170 | }
171 | if(-Not [string]::IsNullOrEmpty($field.BOOT_UP_STATE))
172 | {
173 | $name="BOOT_UP_STATE";$value=$field.BOOT_UP_STATE
174 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
175 | }
176 | if(-Not [string]::IsNullOrEmpty($field.POWER_SUPPLY_STATE))
177 | {
178 | $name="POWER_SUPPLY_STATE";$value=$field.POWER_SUPPLY_STATE
179 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
180 | }
181 | if(-Not [string]::IsNullOrEmpty($field.THERMAL_STATE))
182 | {
183 | $name="THERMAL_STATE";$value=$field.THERMAL_STATE
184 | Write-Host $("SMBIOS Record Type = " + $field.SMBIOS_RECORD_TYPE + ", " + $name + " = " + $value)
185 |
186 | }
187 |
188 | }
189 |
190 |
191 | }
192 | $WarningPreference ="Continue"
193 | $ErrorActionPreference = "Continue"
194 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
195 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/Error_Handling.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to set iLO functions for multiple iLO Servers at the same time by
4 | importing cmdlet parameter values from a CSV file, and finally gather and report the different
5 | setting results returned from iLO.
6 |
7 | You can use other HPiLOCmdlets by changing the cmdlet name and you can customize your own CSV file
8 | with the same format as Input1.csv as below.
9 |
10 | ***************************************************************************************************#>
11 |
12 | <#CSV input file(Input1.csv):
13 | Server,Username,Password,HostPower
14 | 192.168.1.1,user1,password1,Yes
15 | 192.168.1.2,user2,password2,No
16 | 192.168.1.3,user3,password3,Yes
17 | #>
18 | $path = ".\input1.csv"
19 | $csv = Import-Csv $path
20 | try{
21 | $rt = $csv | Set-HPiLOHostPower -DisableCertificateAuthentication
22 | if($rt -ne $null)
23 | {
24 | foreach ($iloreturn in $rt)
25 | {
26 | $type = 0
27 | if($iloreturn.StatusType -eq "Warning")
28 | {
29 | $type = 1
30 | $IP = $iloreturn.IP
31 | $Message = $iloreturn.StatusMessage
32 | }
33 | elseif($iloreturn.StatusType -eq "Error")
34 | {
35 | $type = 2
36 | $IP = $iloreturn.IP
37 | $Message = $iloreturn.StatusMessage
38 | }
39 | switch($type)
40 | {
41 | #OK status is not returned in a Set cmdlet
42 | #but you can get a warning or error
43 | 1 { Write-Host "I have been warned by $IP : $Message" -ForegroundColor Yellow}
44 | 2 { Write-Host "Something bad returned by $IP : $Message" -ForegroundColor Red}
45 | default {Write-Host "Success returned by $IP : $Message" -ForegroundColor Green}
46 | }
47 | }
48 | }
49 | $rt = $csv | Get-HPiLOHostPower -DisableCertificateAuthentication
50 | $rt | Format-List
51 | }
52 | catch{
53 | #code for however you want to handle a PowerShell error in the try block
54 | exit
55 | }
--------------------------------------------------------------------------------
/HPEiLO/1.5/Generate_CertificateSigningRequest.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to generate CertificateSigningRequest by using
4 | Get-HPILOCertificateSigningRequest and then importing the signed certificate by the
5 | Import-HPILOCertificate cmdlet.
6 |
7 | ***************************************************************************************************#>
8 |
9 | ##Target ILO IP
10 | #The ILO which needs to generate the CertificateSigningRequest by invoking 'Get-HPILOCertificateSigningRequest'
11 | $targetILO = "1.1.1.1"
12 | #Target ILO login username and password
13 | $targetILOUsername = ""
14 | $targetILOPassword = ""
15 |
16 | #Customized paramters for Get-HPILOCertificateSigningRequest
17 | #If user needs to generate customized CertificateSigningRequest
18 | #Please modify below paramters as needed, and add them during '1st time generate CertificateSigningRequest'
19 | #Important!!! CommonName (CN) value should be the iLO Hostname in iLO Web -> Information -> Overview page.
20 | $state = ""
21 | $country = ""
22 | $locality = ""
23 | $organization = ""
24 | $organizationalUnit = ""
25 | $commonName = ""
26 |
27 | #Waittime after 1st time 'Get-HPILOCertificateSigningRequest' is invoked
28 | #Value is being set as 120 sec as ILO might take 2-10 min to generate the CertificateSigningRequest.
29 | #If needed, please increase the $waitTime based on local ILO condition.
30 | $waitTime = 120
31 |
32 | # 1st time, the cmdlet is called to generate CertificateSigningRequest
33 | # Used example will only generate ILO CertificateSigningRequest with default value
34 | # If you need ILO to generate a customized CertificateSigningRequest, customized paramters of Get-HPILOCertificateSigningRequest are needed.
35 | # Please modify parameters in
36 | # $state = ""
37 | # $country = ""
38 | # $locality = ""
39 | # $organization = ""
40 | # $organizationalUnit = ""
41 | # $commonName = ""
42 | #
43 | # Then use generate cmd example as shown below
44 | # e.g.
45 | # Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -state $state -country $country -locality $locality -organization $organization
46 | # Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -state $state -country $country
47 | # ...
48 | $cer = Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -DisableCertificateAuthentication
49 |
50 | #Sleep for the time ILO must wait to execute the command agin to retrieve the certificateSigningRequest
51 | Start-Sleep -Seconds $waitTime
52 |
53 | # The cmdlet is executed for the 2nd time to load generated CertificateSigningRequest by running “Get-HPiLOCertificateSigningRequest” with the same parameter values as the 1st time.
54 | # e.g.
55 | # Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -state $state -country $country -locality $locality -organization $organization
56 | # Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -state $state -country $country
57 | # ...
58 | $cer = Get-HPILOCertificateSigningRequest -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -DisableCertificateAuthentication
59 |
60 | if($cer.STATUS_TYPE -ieq "ERROR" -and $cer.STATUS_MESSAGE -like "The ILO subsystem is currently generating a Certificate Signing Request(CSR), run script after 10 minutes or more to receive the CSR."){
61 | #If this status type is returned, it means that 1st time generation was not completed or it was not successful
62 | #Please increase the $waitTime and re-run the script.
63 | #If the $waitTime is increased to more than 10 mins and the same error is displayed, please contact HP support to check the ILO status
64 | Write-host "1st time generating was not finished or failed."
65 | return
66 | }
67 | elseif($cer.STATUS_TYPE -ieq "OK"){
68 | #CertificateSigningRequest generated succefully.
69 | Write-host "Successful generated CertificateSigningRequest, please check var `$certificateSigningRequest"
70 | $certificateSigningRequest = $cer.CERTIFICATE_SIGNING_REQUEST
71 | }
72 |
73 | # If there are no errors and the CertificateSigningRequest is gernerated, it is not signed
74 | # You need to use a 3rd party sign tool to sign this request in $certificateSigningRequest.
75 | #
76 | #e.g.
77 | # 1. Export generated $certificateSigningRequest to a txt file
78 | # Set-Content -Path .\cert.txt -Value $certificateSigningRequest.Split("`n")
79 | #
80 | # 2. Use a 3rd party tool to sign $certificateSigningRequest
81 | #
82 | # 3. Import signed $certificateSigningRequest from a txt file
83 | # $signedCert = get-content .\signedCert.txt -Raw
84 | #
85 | # 4. Import signed certifiacte into targetILO
86 | # Import-HPILOCertificate -Server $targetILO -Username $targetILOUsername -Password $targetILOPassword -Certificate $signedCert
--------------------------------------------------------------------------------
/HPEiLO/1.5/Import_Parameters_From_CSV_File.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to add Cmdlet parameter values into a CSV file, and import these
4 | values from this CSV file into the Cmdlet.
5 |
6 | You can change the cmdlet name to other ones and customize your own CSV file with the same format as
7 | Input1.csv or Input2.csv as below.
8 |
9 | ***************************************************************************************************#>
10 |
11 |
12 | #Example 1: CSV file has different Server, Username, Password, and other parameter values
13 | <#CSV input file(Input1.csv):
14 | Server,Username,Password,HostPower
15 | 192.168.1.1,user1,password1,Yes
16 | 192.168.1.2,user2,password2,No
17 | 192.168.1.3,user3,password3,Yes
18 | #>
19 | $path = ".\input1.csv"
20 | $csv = Import-Csv $path
21 | $rt = Set-HPiLOHostPower -Server $csv.Server -Username $csv.Username -Password $csv.Password -HostPower $csv.HostPower -DisableCertificateAuthentication
22 | $rt | Format-List
23 | $rt = Get-HPiLOHostPower -Server $csv.Server -Username $csv.Username -Password $csv.Password -DisableCertificateAuthentication
24 | $rt | Format-List
25 |
26 | #Piping the imported object from CSV file into the cmdlet
27 | $path = ".\input1.csv"
28 | $csv = Import-Csv $path
29 | $rt = $csv | Set-HPiLOHostPower -DisableCertificateAuthentication
30 | $rt | Format-List
31 | $rt = $csv | Get-HPiLOHostPower -DisableCertificateAuthentication
32 | $rt | Format-List
33 |
34 | #Example 2: CSV file has only iLO IP or hostname and there is a common username and password for logging in
35 | <#CSV input file(Input2.csv):
36 | Server
37 | 192.168.1.1
38 | 192.168.1.2
39 | 192.168.1.3
40 | #>
41 | $path = ".\input2.csv"
42 | $csv = Import-Csv $path
43 | $rt = Set-HPiLOHostPower -Server $csv.Server -Username "username" -Password "password" -HostPower "Yes" -DisableCertificateAuthentication
44 | $rt | Format-List
45 | $rt = Get-HPiLOHostPower -Server $csv.Server -Username "username" -Password "password" -DisableCertificateAuthentication
46 | $rt | Format-List
--------------------------------------------------------------------------------
/HPEiLO/1.5/Input_Named_Or_Pipeline_Parameters.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to input named or pipeline parameter values for a cmdlet.
4 |
5 | ***************************************************************************************************#>
6 |
7 |
8 | ###---------------------------------------------Examples of Using Named Parameters---------------------------------------------###
9 | #Example 1: single iLO
10 | Get-HPiLOStorageController -Server 192.168.1.1 -Username user1 -Password pwd1
11 |
12 | #Example 2: multiple iLO with same username and password / Credential
13 | $server1 = "192.168.1.1"
14 | $server2 = "192.168.1.3"
15 | $username = "user"
16 | $password = "pwd"
17 | $credential = Get-Credential -Message "Please enter the username and password"
18 | Get-HPiLOStorageController -Server @($server1, $server2) -Username $username -Password $password -DisableCertificateAuthentication
19 | Get-HPiLOStorageController -Server @($server1, $server2) -Credential $credential -DisableCertificateAuthentication
20 |
21 | #Example 3: multiple iLO with different username and password / Credential
22 | $server1 = "192.168.1.1"
23 | $server2 = "192.168.1.3"
24 | $user1 = "user1"
25 | $user2 = "user2"
26 | $pwd1 = "pwd1"
27 | $pwd2 = "pwd2"
28 | $credential1 = Get-Credential -Message "Please enter the username and password for $server1"
29 | $credential2 = Get-Credential -Message "Please enter the username and password for $server2"
30 | Get-HPiLOStorageController -Server @($server1, $server2) -Username @($user1,$user2) -Password @($pwd1,$pwd2) -DisableCertificateAuthentication
31 | Get-HPiLOStorageController -Server @($server1, $server2) -Credential @($credential1,$credential2) -DisableCertificateAuthentication
32 |
33 |
34 | ###---------------------------------------------Examples of Using Piped Parameters---------------------------------------------###
35 | #Example 1: Pipe only server parameter. Username and Password parameters are provided using the commandline
36 | "192.168.1.1" | Get-HPiLOStorageController -Username user -Password pwd -DisableCertificateAuthentication
37 | @("192.168.1.1", "192.168.1.3") | Get-HPiLOStorageController -Username @("user1","user2") -Password @("pwd1","pwd2") -DisableCertificateAuthentication
38 |
39 | #Example 2: Pipe a PSObject with multiple servers. All the servers have the same username and password
40 | $p = New-Object -TypeName PSObject -Property @{ "Server"= @("192.168.1.1","192.168.1.3");"Username"="user"; "Password"="pwd" }
41 | $p | Get-HPiLOStorageController -DisableCertificateAuthentication
42 |
43 | #Example 3: Pipe a PSObject with multiple servers. All the servers have different username and password
44 | $p = New-Object -TypeName PSObject -Property @{ "Server"= @("192.168.1.1","192.168.1.3");"Username"=@("user1","user2"); "Password"=@("pwd1","pwd2") }
45 | $p | Get-HPiLOStorageController -DisableCertificateAuthentication
46 |
47 | #Example 4: Pipe multiple PSObject with multiple servers with different parameters
48 | $p1 = New-Object -TypeName PSObject -Property @{
49 | Server = "192.168.1.1"
50 | username = "user1"
51 | password = "pwd1"
52 | }
53 | $p2 = New-Object -TypeName PSObject -Property @{
54 | IP = "192.168.1.3"
55 | Credential = Get-Credential -Message "Please enter the password" -UserName "user2"
56 | }
57 | $list = @($p1,$p2)
58 | $list | Get-HPiLOStorageController -DisableCertificateAuthentication
59 |
60 |
61 | ###---------------------------------------------Examples of Interactive Input for Mandatory Parameters---------------------------------------------###
62 | #Example1: Pipe multiple servers but the username and password is provided for only one server
63 | # You will be asked to input values for mandatory parameters which do not have default values. For example, username and password for servers 192.168.1.2 and 192.168.1.3
64 | # You will NOT be asked to input values for mandatoty parameters with default values, such as "Category"
65 | $p0 = New-Object -TypeName PSObject -Property @{
66 | Server = "192.168.1.1"
67 | username = "user1"
68 | password = "pwd1"
69 | Category = "MemoryInfo"
70 | }
71 | $p1 = New-Object -TypeName PSObject -Property @{
72 | Server = "192.168.1.2"
73 | }
74 | $p2 = New-Object -TypeName PSObject -Property @{
75 | Server = "192.168.1.3"
76 | }
77 | $list = @($p0,$p1,$p2)
78 | $list | get-hpiloserverinfo -DisableCertificateAuthentication
79 |
--------------------------------------------------------------------------------
/HPEiLO/1.5/InvokeRIBCL.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to executes any RIBCL command and return the RIBCL response.
4 |
5 | .DESCRIPTION
6 | This script allows user to enter the RIBCL command and returns RIBCL response as PSObject for read operations and does not return anything for write operations.
7 | -RIBCLCommand :- Use this option to input the RIBCL command.
8 |
9 | .EXAMPLE
10 | InvokeRIBCL.ps1 -RIBCLCommand $xml
11 | $xml = ([string](get-content " C:\Program Files\Hewlett-Packard\RIBCL_XML\Get_AHS_Status.xml"))
12 | This mode of execution of script will prompt for
13 | -Address :- accpet IP(s) or Hostname(s). For multiple iLO IP(s) or Hostname(s) should be separated by comma(,)
14 | -Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
15 |
16 | .EXAMPLE
17 | InvokeRIBCL.ps1 -Address "10.20.30.40,10.20.30.1" -Credential $Credential -RIBCLCommand $xml
18 |
19 | This mode of script have input parameter for Address,Username, Password and location
20 | -Address :- accpet IP(s) or Hostname(s). For multiple iLO IP(s) or Hostname(s) should be separated by comma(,)
21 | -Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
22 | -RIBCLCommand :- Use this option to input the RIBCL command.
23 |
24 | .NOTES
25 | Company : Hewlett Packard Enterprise
26 | Version : 1.4.0.0
27 |
28 | .INPUTS
29 | Inputs to this script file
30 | Address
31 | Username
32 | Password
33 | Location
34 |
35 | .OUTPUTS
36 | None (by default)
37 |
38 | .LINK
39 |
40 | http://www.hpe.com/servers/powershell
41 | #>
42 |
43 | #Command line parameters
44 | Param(
45 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
46 | [PSCredential]$Credential,
47 | $RIBCLCommand
48 | )
49 |
50 | #Check for server avaibiality
51 |
52 | function CheckServerAvailability ($ListOfAddress)
53 | {
54 | [int]$pingFailureCount = 0
55 | [array]$PingedServerList = @()
56 | foreach($serverAddress in $ListOfAddress)
57 | {
58 | if(Test-Connection $serverAddress)
59 | {
60 | #Write-Host "Server $serverAddress pinged successfully."
61 | $PingedServerList += $serverAddress
62 | }
63 | else
64 | {
65 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
66 | $pingFailureCount ++
67 | }
68 | }
69 |
70 | if($pingFailureCount -eq $ListOfAddress.Count)
71 | {
72 | Write-Host "`nServer(s) are not reachable please check network conectivity"
73 | exit
74 | }
75 | return $PingedServerList
76 | }
77 |
78 | #clear host
79 | Clear-Host
80 |
81 | # script execution started
82 | Write-Host "`n****** Script execution started ******" -ForegroundColor Yellow
83 | #Decribe what script does to the user
84 |
85 | Write-Host "`nThis script allows user to executes any RIBCL command and get the RIBCL response"
86 |
87 | $ErrorActionPreference = "SilentlyContinue"
88 | $WarningPreference ="SilentlyContinue"
89 |
90 | #check powershell support
91 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
92 |
93 | if($PowerShellVersion -ge "3")
94 | {
95 | Write-Host "`nYour powershell version : $($PSVersionTable.PSVersion) is valid to execute this script"
96 | }
97 | else
98 | {
99 | Write-Host "`nThis script required PowerSehll 3 or above"
100 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
101 | Write-Host "Please Update PowerShell version`n"
102 | Write-Host "Exit...`n"
103 | exit
104 | }
105 |
106 | #Load HPiLOCmdlets module
107 |
108 | $InstalledModule = Get-Module
109 | $ModuleNames = $InstalledModule.Name
110 |
111 | if(-not($ModuleNames -like "HPiLOCmdlets"))
112 | {
113 | Write-Host "`nLoading module : HPiLOCmdlets"
114 | Import-Module HPiLOCmdlets
115 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
116 | {
117 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again"
118 | Write-Host "Exit..."
119 | exit
120 | }
121 | }
122 | else
123 | {
124 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
125 | Write-Host "`nHPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
126 | }
127 |
128 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
129 |
130 | if($Address -eq "")
131 | {
132 | $Address = Read-Host "`nEnter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
133 | }
134 |
135 | [array]$ListOfAddress = ($Address.Trim().Split(','))
136 |
137 | if($ListOfAddress.Count -eq 0)
138 | {
139 | Write-Host "You have not entered IP(s) or Hostname(s)`n"
140 | Write-Host "Exit..."
141 | exit
142 | }
143 |
144 | if($Credential -eq $null)
145 | {
146 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
147 | }
148 |
149 | if($null -eq $RIBCLCommand)
150 | {
151 | Write-Host "`nYou have not provided the RIBCL command"
152 | Write-Host "`nExit..."
153 | exit
154 | }
155 |
156 | # Ping and test IP(s) or Hostname(s) are reachable or not
157 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
158 |
159 | for($i=0 ;$i -lt $ListOfAddress.Count;$i++)
160 | {
161 | $RIBCLCommand =$RIBCLCommand -replace '',''
162 | if($ListOfAddress.Count -eq 1 -or $RIBCLCommand.Count -eq 1)
163 | {
164 | $result = Invoke-HPiLORIBCLCommand -Server $ListOfAddress -Credential $Credential -RIBCLCommand $RIBCLCommand -DisableCertificateAuthentication
165 | $flag=$true
166 | }
167 | else
168 | {
169 | $result = Invoke-HPiLORIBCLCommand -Server $ListOfAddress[$i] -Credential $Credential -RIBCLCommand $RIBCLCommand[$i] -DisableCertificateAuthentication
170 | }
171 |
172 | if($null -ne $result)
173 | {
174 | $result
175 | }
176 | elseif($Error[0].ToString() -match "Invalid RIBCL file" -or $Error[0].ToString() -match "Current RIBCL command is not supported.\n Use Update-HPiLOiLOFirmware/Update-HPiLOServerFirmware/Install-HPiLOLanguagePack cmdlet for firmware upgrade/language pack installation")
177 | {
178 | $result = New-Object PSObject
179 | $result | Add-Member NoteProperty "IP" $result.IP
180 | $result | Add-Member NoteProperty "STATUS_TYPE" "Error"
181 | $result | Add-Member NoteProperty "STATUS_MESSAGE" $Error[0].ToString()
182 | $result
183 | }
184 | else
185 | {
186 | Write-Host "`nThe value has been set successfully"
187 | }
188 | if($flag)
189 | {
190 | break
191 | }
192 | }
193 |
194 | $ErrorActionPreference = "Continue"
195 | $WarningPreference ="Continue"
196 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
197 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/LanguagePackInstallation.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to install the language pack on servers with iLO 4.
4 |
5 | .DESCRIPTION
6 | This script allows user to install the language pack.
7 | location :- Use this option to set the location of the langugage pack.
8 |
9 | .EXAMPLE
10 | LanguagePackInstallation.ps1
11 | This mode of execution of script will prompt for
12 | Address :- accpet IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
13 | Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
14 | location :- file with extension .lpk.
15 |
16 | .EXAMPLE
17 | LanguagePackInstallation.ps1 -Address "10.20.30.40,10.20.30.1" -Credential $Credential -Location "C:\Program Files\HewletPAckard\OA401-20130823-ja.lpk","C:\Program Files\HewletPAckard\OA401-20130823-ja.lpk"
18 |
19 | This mode of script have input parameter for Address,Username, Password and location
20 | -Address:- Use this parameter to specify IP(s) or Hostname(s) of the server(s). In the of case multiple entries it should be separated by comma(,)
21 | -Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
22 | -Location :- Use this parameter to specify the location.
23 |
24 | .NOTES
25 | Company : Hewlett Packard Enterprise
26 | Version : 1.4.0.0
27 |
28 | .INPUTS
29 | Inputs to this script file
30 | Address
31 | Username
32 | Password
33 | Location
34 |
35 | .OUTPUTS
36 | None (by default)
37 |
38 | .LINK
39 |
40 | http://www.hpe.com/servers/powershell
41 | #>
42 |
43 | #Command line parameters
44 | Param(
45 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
46 | [PSCredential]$Credential,
47 | $Location
48 |
49 | )
50 |
51 | #Check for server avaibiality
52 | function CheckServerAvailability ($ListOfAddress)
53 | {
54 | [int]$pingFailureCount = 0
55 | [array]$PingedServerList = @()
56 | foreach($serverAddress in $ListOfAddress)
57 | {
58 | if(Test-Connection $serverAddress)
59 | {
60 | #Write-Host "Server $serverAddress pinged successfully."
61 | $PingedServerList += $serverAddress
62 | }
63 | else
64 | {
65 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
66 | $pingFailureCount ++
67 | }
68 | }
69 |
70 | if($pingFailureCount -eq $ListOfAddress.Count)
71 | {
72 | Write-Host "`nServer(s) are not reachable please check network conectivity"
73 | exit
74 | }
75 | return $PingedServerList
76 | }
77 | #clear host
78 | Clear-Host
79 |
80 | # script execution started
81 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
82 | #Decribe what script does to the user
83 |
84 | Write-Host "This script allows user to Install the language pack on the server`n"
85 |
86 | $ErrorActionPreference = "SilentlyContinue"
87 | $WarningPreference="SilentlyContinue"
88 | #check powershell support
89 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
90 |
91 | if($PowerShellVersion -ge "3")
92 | {
93 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script`n"
94 | }
95 | else
96 | {
97 | Write-Host "This script required PowerSehll 3 or above"
98 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
99 | Write-Host "Please Update PowerShell version`n"
100 | Write-Host "Exit...`n"
101 | exit
102 | }
103 |
104 | #Load HPiLOCmdlets module
105 |
106 | $InstalledModule = Get-Module
107 | $ModuleNames = $InstalledModule.Name
108 |
109 | if(-not($ModuleNames -like "HPiLOCmdlets"))
110 | {
111 | Write-Host "Loading module : HPiLOCmdlets"
112 | Import-Module HPiLOCmdlets
113 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
114 | {
115 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again`n"
116 | Write-Host "Exit..."
117 | exit
118 | }
119 | }
120 | else
121 | {
122 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
123 | Write-Host "HPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine.`n"
124 | }
125 |
126 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
127 |
128 | if($Address -eq "")
129 | {
130 | $Address = Read-Host "Enter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
131 | }
132 |
133 | [array]$ListOfAddress = ($Address.Trim().Split(','))
134 |
135 | if($ListOfAddress.Count -eq 0)
136 | {
137 | Write-Host "`nYou have not entered IP(s) or Hostname(s)`n"
138 | Write-Host "Exit..."
139 | exit
140 | }
141 | if($Credential -eq $null)
142 | {
143 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
144 | }
145 |
146 | # Ping and test IP(s) or Hostname(s) are reachable or not
147 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
148 |
149 | Write-Host ("`nLanguages available for the server") -ForegroundColor Yellow
150 | $result = Get-HPiLOLanguage -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
151 | $result
152 |
153 | if([string]::IsNullOrEmpty($Location))
154 | {
155 | $Location = Read-Host "`nEnter language pack location"
156 | }
157 |
158 | $inputLocationList = ($Location.Trim().Split(','))
159 |
160 | if($inputLocationList.Count -eq 0)
161 | {
162 | Write-Host "`nYou have not enterd location"
163 | Write-Host "Exit....."
164 | exit
165 | }
166 |
167 | Write-Host "`nInstalling the Language Pack. This might take some time" -ForegroundColor Green
168 |
169 | $failureCount = 0
170 |
171 | for($i=0;$i -lt $ListOfAddress.Count;$i++)
172 | {
173 | $inputLocationList[$i]=$inputLocationList[$i].replace('"',"")
174 | if( -not (Test-Path $inputLocationList[$i] -PathType Leaf)){
175 | $tmpObj = New-Object PSObject
176 | $tmpObj | Add-Member NoteProperty "IP" $result.IP
177 | $tmpObj | Add-Member NoteProperty "STATUS_TYPE" "Error"
178 | $tmpObj | Add-Member NoteProperty "STATUS_MESSAGE" "Invalid image location."
179 | $tmpObj
180 | }
181 |
182 |
183 | elseif(([System.IO.Path]::GetExtension($inputLocationList[$i]) -ne ".lpk")){
184 | $tmpObj = New-Object PSObject
185 | $tmpObj | Add-Member NoteProperty "IP" $result.IP
186 | $tmpObj | Add-Member NoteProperty "STATUS_TYPE" "Error"
187 | $tmpObj | Add-Member NoteProperty "STATUS_MESSAGE" "Firmware image must be `"lpk`" file"
188 | $tmpObj
189 | }
190 | else
191 | {
192 | $result= Install-HPiLOLanguagePack -Server $ListOfAddress[$i] -Credential $Credential -Location $inputLocationList[$i] -DisableCertificateAuthentication
193 | Start-Sleep -Seconds 120
194 | }
195 |
196 | if($result.STATUS_TYPE -eq "Error")
197 | {
198 | Write-Host "`nLanguage pack installation failed`n"
199 | $result
200 | $failureCount++
201 | }
202 | else
203 | {
204 | Write-host "`nLanguage pack successfully installed" -ForegroundColor Green
205 | }
206 |
207 | }
208 |
209 | if($failureCount -ne $ListOfAddress.Count)
210 | {
211 | Write-Host ("`nLanguages available for the server") -ForegroundColor Yellow
212 | $result = Get-HPiLOLanguage -Server $ListOfAddress -Credential $Credential -DisableCertificateAuthentication
213 | $result
214 |
215 | }
216 | $ErrorActionPreference = "Continue"
217 | $WarningPreference ="Continue"
218 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
219 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/Log_Processing.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to get and categorize the types of events in the iLO logs or
4 | Integrated Management Log (IML).
5 |
6 | ***************************************************************************************************#>
7 |
8 |
9 | <#CSV input file(Input3.csv):
10 | Server,Username,Password
11 | 192.168.1.9,user1,pwd1
12 | 192.168.1.14,user2,pwd2
13 | #>
14 | $ErrorActionPreference = "SilentlyContinue"
15 | $WarningPreference="SilentlyContinue"
16 | #Example 1: Get and categorize the types of events in the iLO logs
17 | $path = ".\input3.csv"
18 | $csv = Import-Csv $path
19 | $rt = $csv | Get-HPiLOEventLog -DisableCertificateAuthentication
20 | #Process the iLO event log returned from each iLO
21 | foreach ($ilo in $rt) {
22 | Write-Host $ilo.IP + " has " + $ilo.EVENT.Count + " iLO log entries."
23 | $sevs = $(foreach ($event in $ilo.EVENT) {$event.SEVERITY})
24 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
25 | $sevcnts = $ilo.EVENT | group-object -property SEVERITY –noelement
26 | Write-Host "There are " + $uniqsev.Count + " type(s) of events in the iLO log."
27 | $sevcnts | Format-Table
28 | }
29 |
30 | #Example 2: Get and categorize the types of events in the Integrated Management Log (IML)
31 | $path = ".\input3.csv"
32 | $csv = Import-Csv $path
33 | $rt = $csv | Get-HPiLOIML -DisableCertificateAuthentications
34 | #Process the system IML returned from each iLO
35 | foreach ($ilo in $rt) {
36 | Write-Host $ilo.IP + " has " + $ilo.EVENT.Count + " IML entries."
37 | $sevs = $(foreach ($event in $ilo.EVENT) {$event.SEVERITY})
38 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
39 | $sevcnts = $ilo.EVENT | group-object -property SEVERITY –noelement
40 | Write-Host "There are " + $uniqsev.Count + " type(s) of events in the IML."
41 | $sevcnts | Format-Table
42 | }
43 |
44 | $ErrorActionPreference = "Continue"
45 | $WarningPreference ="Continue"
--------------------------------------------------------------------------------
/HPEiLO/1.5/ServerFirmwareUpdate.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to update the ROM/CPLD/Power PIC firmware on servers with iLO 4.
4 |
5 | .DESCRIPTION
6 | This script allows user to update the ROM/CPLD/Power PIC firmware on servers with iLO 4.
7 | location :- Use this option to set the location of the firmware.
8 |
9 | .EXAMPLE
10 | ServerFirmwareUpdate.ps1
11 | This mode of execution of script will prompt for
12 | Address :- accpet IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
13 | Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
14 | location :- file with extension .full/.flash/.vme/.hex.
15 |
16 | .EXAMPLE
17 | ServerFirmwareUpdate.ps1 -Address "10.20.30.40,10.20.30.40.1" -Credential $Credential -Location $location
18 |
19 | This mode of script have input parameter for Address,Username, Password and location
20 | -Address:- Use this parameter to specify IP(s) or Hostname(s) of the server(s). In the of case multiple entries it should be separated by comma(,)
21 | -Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
22 | -Location :- Use this parameter to specify the location.
23 |
24 | .NOTES
25 | Company : Hewlett Packard Enterprise
26 | Version : 1.4.0.0
27 |
28 |
29 | .INPUTS
30 | Inputs to this script file
31 | Address
32 | Username
33 | Password
34 | Location
35 |
36 | .OUTPUTS
37 | None (by default)
38 |
39 | .LINK
40 |
41 | http://www.hpe.com/servers/powershell
42 | #>
43 |
44 | #Command line parameters
45 | Param(
46 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
47 | [PSCredential]$Credential,
48 | $Location
49 |
50 | )
51 |
52 |
53 | #Check for server avaibiality
54 |
55 | function CheckServerAvailability ($ListOfAddress)
56 | {
57 | [int]$pingFailureCount = 0
58 | [array]$PingedServerList = @()
59 | foreach($serverAddress in $ListOfAddress)
60 | {
61 | if(Test-Connection $serverAddress)
62 | {
63 | #Write-Host "Server $serverAddress pinged successfully."
64 | $PingedServerList += $serverAddress
65 | }
66 | else
67 | {
68 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
69 | $pingFailureCount ++
70 | }
71 | }
72 |
73 | if($pingFailureCount -eq $ListOfAddress.Count)
74 | {
75 | Write-Host "`nServer(s) are not reachable please check network conectivity"
76 | exit
77 | }
78 | return $PingedServerList
79 | }
80 |
81 | #clear host
82 | Clear-Host
83 |
84 | # script execution started
85 | Write-Host "`n****** Script execution started ******" -ForegroundColor Yellow
86 | #Decribe what script does to the user
87 |
88 | Write-Host "`nThis script allows user to update the firmware of the server"
89 |
90 | #$ErrorActionPreference = "SilentlyContinue"
91 | $WarningPreference="SilentlyContinue"
92 | #check powershell support
93 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
94 |
95 | if($PowerShellVersion -ge "3")
96 | {
97 | Write-Host "`nYour powershell version : $($PSVersionTable.PSVersion) is valid to execute this script`n"
98 | }
99 | else
100 | {
101 | Write-Host "`nThis script required PowerSehll 3 or above"
102 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
103 | Write-Host "Please Update PowerShell version`n"
104 | Write-Host "Exit...`n"
105 | exit
106 | }
107 |
108 | #Load HPiLOCmdlets module
109 |
110 | $InstalledModule = Get-Module
111 | $ModuleNames = $InstalledModule.Name
112 |
113 | if(-not($ModuleNames -like "HPiLOCmdlets"))
114 | {
115 | Write-Host "Loading module : HPiLOCmdlets"
116 | Import-Module HPiLOCmdlets
117 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
118 | {
119 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again`n"
120 | Write-Host "Exit..."
121 | exit
122 | }
123 | }
124 | else
125 | {
126 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
127 | Write-Host "HPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
128 | }
129 |
130 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
131 |
132 | if($Address -eq "")
133 | {
134 | $Address = Read-Host "`nEnter Server address (IP or Hostname). Multiple entries seprated by comma(,)"
135 | }
136 |
137 | [array]$ListOfAddress = ($Address.Trim().Split(','))
138 |
139 | if($ListOfAddress.Count -eq 0)
140 | {
141 | Write-Host "You have not entered IP(s) or Hostname(s)`n"
142 | Write-Host "Exit..."
143 | exit
144 | }
145 | if($Credential -eq $null)
146 | {
147 | $Credential = Get-Credential -Message "Enter username and Password(Use same credential for multiple servers)"
148 | }
149 | # Ping and test IP(s) or Hostname(s) are reachable or not
150 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
151 |
152 | foreach($IPAddress in $ListOfAddress)
153 | {
154 | $result = Get-HPiLOFirmwareInfo -Server $IPAddress -Credential $Credential -DisableCertificateAuthentication
155 |
156 | Write-Host ("Current Firmware Version information for the server {0}" -f ($IPAddress)) -ForegroundColor Yellow
157 | if($null -ne $result)
158 | {
159 | $tmpObj = New-Object PSObject
160 | $tmpObj | Add-Member NoteProperty "IP" $result.IP
161 | $tmpObj | Add-Member NoteProperty "HOSTNAME" $result.Hostname
162 | $tmpObj | Add-Member NoteProperty "STATUS_TYPE" "OK"
163 | for($i=0;$i -lt $result.FirmwareInfo.Count ;$i++)
164 | {
165 | if($result.FirmwareInfo[$i].FIRMWARE_NAME -match "System ROM" -or $result.FirmwareInfo[$i].FIRMWARE_NAME -match "Redundant System ROM" -or $result.FirmwareInfo[$i].FIRMWARE_NAME -match "Power Management Controller Firmware" -or $result.FirmwareInfo[$i].FIRMWARE_NAME -match "System Programmable Logic Device")
166 | {
167 | $tmpObj | Add-Member NoteProperty $result.FirmwareInfo[$i].FIRMWARE_NAME $result.FirmwareInfo[$i].FIRMWARE_VERSION
168 | }
169 | }
170 | $tmpObj
171 | }
172 | else
173 | {
174 | Write-Host "`nUnable to retrieve Server Firmware information"
175 | Write-Host "Server : $($result.IP)"
176 | Write-Host "Error : $($result.STATUS_MESSAGE)"
177 | }
178 | }
179 |
180 | if([string]::IsNullOrEmpty($Location))
181 | {
182 | $Location = Read-Host "`nEnter firmware file location"
183 | }
184 |
185 | $inputLocationList = ($Location.Trim().Split(','))
186 |
187 | if($inputLocationList.Count -eq 0)
188 | {
189 | Write-Host "You have not enterd location"
190 | Write-Host "Exit....."
191 | exit
192 | }
193 |
194 | $failureCount = 0
195 |
196 | for($i=0;$i -lt $ListOfAddress.Count;$i++)
197 | {
198 |
199 | $inputLocationList[$i]=$inputLocationList[$i].replace('"',"")
200 | $Extension=[System.IO.Path]::GetExtension($inputLocationList[$i])
201 |
202 | if( -not (Test-Path $inputLocationList[$i] -PathType Leaf)){
203 | $tmpObj = New-Object PSObject
204 | $tmpObj | Add-Member NoteProperty "IP" $result.IP
205 | $tmpObj | Add-Member NoteProperty "STATUS_TYPE" "ERROR"
206 | $tmpObj | Add-Member NoteProperty "STATUS_MESSAGE" "Invalid image location."
207 | $tmpObj
208 | }
209 |
210 | elseif(($Extension -eq ".full" -or $Extension -eq ".flash" -or $Extension -eq ".vme" -or $Extension -eq ".hex"))
211 | {
212 | Write-Host ("`nFirmware Upgrade for server {0} In Progress, this might take some time" -f $ListOfAddress[$i]) -ForegroundColor Green
213 | $result= Update-HPiLOServerFirmware -Server $ListOfAddress[$i] -Credential $Credential -Location $inputLocationList[$i] -DisableCertificateAuthentication
214 | $result
215 | }
216 | else
217 | {
218 | $tmpObj = New-Object PSObject
219 | $tmpObj | Add-Member NoteProperty "IP" $result.IP
220 | $tmpObj | Add-Member NoteProperty "STATUS_TYPE" "ERROR"
221 | $tmpObj | Add-Member NoteProperty "STATUS_MESSAGE" "Firmware image must be `".full/.flash/.vme/.hex`" file."
222 | $tmpObj
223 | }
224 |
225 | }
226 | $ErrorActionPreference = "Continue"
227 | $WarningPreference ="Continue"
228 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
229 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/Using_Find-HPiLO.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to use Find-HPiLO to find all the iLO servers
4 | within a server IP Range.
5 |
6 | ***************************************************************************************************#>
7 |
8 | #Example 1: Find-HPiLO with a single IP address:
9 | Find-HPiLO 192.168.1.1
10 |
11 | #Example 2: Find-HPiLO with a search range
12 | #(if a comma is included in the range, double quotes are required)
13 | Find-HPiLO 192.168.1.1-11
14 | Find-HPiLO -Range “192.168.1.1,15"
15 | Find-HPiLO -Range “192.168.217,216.93,103”
16 | Find-HPiLO -Range “192.168.1.1,15"
17 |
18 | #Example 3: Piping output from Find-HPiLO to another cmdlet
19 | Find-HPiLO 192.168.217.97-103 -Verbose |
20 | % {Add-Member -PassThru -InputObject $_ Username "username"}|
21 | % {Add-Member -PassThru -InputObject $_ Password "password"}|
22 | Get-HPiLOFirmwareVersion -Verbose
--------------------------------------------------------------------------------
/HPEiLO/1.5/Using_Get-HPiLOMemoryInfo.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script allows user to get Memory information of HPE Proliant Gen7, Gen8 and Gen9 servers through iLO
4 |
5 | .DESCRIPTION
6 | This script allows user to get Memory information.
7 |
8 | .EXAMPLE
9 | Using_Get-HPiLOMemoryInfo.ps1
10 | This mode of exetion of script will prompt for
11 | Address :- accpet IP(s) or Hostname(s). For multiple servers IP(s) or Hostname(s) should be separated by comma(,)
12 | Credential :- prompts for username and password. In case of multiple iLO IP(s) or Hostname(s) it is recommended to use same user credentials
13 |
14 | .EXAMPLE
15 | Using_Get-HPiLOMemoryInfo.ps1 -Address "10.20.30.40,10.20.30.1" -Credential $userCredential
16 | This mode of script have input parameter for Address Credential
17 | -Address:- Use this parameter to specify IP(s) or Hostname(s) of the server(s). In the of case multiple entries it should be separated by comma(,)
18 | -Credential :- Use this parameter to sepcify user credential.
19 |
20 | .NOTES
21 | Company : Hewlett Packard Enterprise
22 | Version : 1.5.0.0
23 |
24 | .INPUTS
25 | Inputs to this script file
26 | Address
27 | Credential
28 |
29 | .OUTPUTS
30 | None (by default)
31 |
32 | .LINK
33 |
34 | http://www.hpe.com/servers/powershell
35 | #>
36 |
37 | #Command line parameters
38 | Param(
39 | [string]$Address, # IP(s) or Hostname(s).If multiple addresses seperated by comma (,)
40 | [PSCredential]$Credential # all server should have same ceredntial (in case of multiple addresses)
41 | )
42 |
43 | #Check for server avaibiality
44 | function CheckServerAvailability ($ListOfAddress)
45 | {
46 | [int]$pingFailureCount = 0
47 | [array]$PingedServerList = @()
48 | foreach($serverAddress in $ListOfAddress)
49 | {
50 | if(Test-Connection $serverAddress)
51 | {
52 | $PingedServerList += $serverAddress
53 | }
54 | else
55 | {
56 | Write-Host "`nServer $serverAddress is not reachable. Please check network connectivity"
57 | $pingFailureCount ++
58 | }
59 | }
60 |
61 | if($pingFailureCount -eq $ListOfAddress.Count)
62 | {
63 | Write-Host ""
64 | Write-Host "Server(s) are not reachable please check network conectivity"
65 | exit
66 | }
67 | return $PingedServerList
68 | }
69 |
70 | #clear host
71 | Clear-Host
72 |
73 | # script execution started
74 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
75 | #Decribe what script does to the user
76 |
77 | Write-Host "This script allows user to retrieve memory information of the server.`n"
78 |
79 | $ErrorActionPreference = "SilentlyContinue"
80 | $WarningPreference ="SilentlyContinue"
81 | #check powershell support
82 | $PowerShellVersion = $PSVersionTable.PSVersion.Major
83 |
84 | if($PowerShellVersion -ge "3")
85 | {
86 | Write-Host "Your powershell version : $($PSVersionTable.PSVersion) is valid to execute this script"
87 | }
88 | else
89 | {
90 | Write-Host "`nThis script required PowerSehll 3 or above"
91 | Write-Host "Current installed PowerShell version is $($PSVersionTable.PSVersion)"
92 | Write-Host "Please Update PowerShell version`n"
93 | Write-Host "Exit...`n"
94 | exit
95 | }
96 |
97 | #Load HPiLOCmdlets module
98 | $InstalledModule = Get-Module
99 | $ModuleNames = $InstalledModule.Name
100 |
101 | if(-not($ModuleNames -like "HPiLOCmdlets"))
102 | {
103 | Write-Host "Loading module : HPiLOCmdlets"
104 | Import-Module HPiLOCmdlets
105 | if(($(Get-Module -Name "HPiLOCmdlets") -eq $null))
106 | {
107 | Write-Host "`nHPiLOCmdlets module cannot be loaded. Please fix the problem and try again"
108 | Write-Host "Exit..."
109 | exit
110 | }
111 | }
112 | else
113 | {
114 | $InstallediLOModule = Get-Module -Name "HPiLOCmdlets"
115 | Write-Host "`nHPiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
116 | }
117 |
118 | # check for IP(s) or Hostname(s) Input. if not available prompt for Input
119 | if($Address -eq "")
120 | {
121 | $Address = Read-Host "`nEnter Server address (IP or Hostname). Multiple entries separated by comma(,)"
122 | Write-Host ""
123 | }
124 |
125 | [array]$ListOfAddress = ($Address.Trim().Split(','))
126 |
127 | if($ListOfAddress.Count -eq 0)
128 | {
129 | Write-Host "`nYou have not entered IP(s) or Hostname(s)`n"
130 | Write-Host "Exit..."
131 | exit
132 | }
133 |
134 | if($Credential -eq $null)
135 | {
136 | $Credential = Get-Credential -Message "Enter username and Password"
137 | }
138 |
139 | $failureCount = 0
140 |
141 | # Ping and test IP(s) or Hostname(s) are reachable or not
142 | $ListOfAddress = CheckServerAvailability($ListOfAddress)
143 |
144 | Write-Host ("`nThis script will do a serial processing of the input IP's") -ForegroundColor Green
145 |
146 | for($i=0;$i -lt $ListOfAddress.Count; $i++)
147 | {
148 | Write-Host ("`nMemory Info for the server - $($ListOfAddress[$i])") -ForegroundColor Yellow
149 | $result = Get-HPiLOMemoryInfo -Server $ListOfAddress[$i] -Credential $Credential -DisableCertificateAuthentication
150 | $result | fl
151 |
152 | if($result -ne $null -and $result.STATUS_TYPE -ne "Error")
153 | {
154 | if($result.MEMORY_COMPONENTS -eq $null)
155 | {
156 | Write-Host ("`nAdvanced Memory Protection details for the server - $($ListOfAddress[$i])") -ForegroundColor Yellow
157 | Write-Host ("`n`$result.ADVANCED_MEMORY_PROTECTION | ft **")
158 | $result.ADVANCED_MEMORY_PROTECTION | ft **
159 |
160 | for($a=0; $a -lt $result.MEMORY_DETAILS.Count; $a++)
161 | {
162 | Write-Host ("`nMemory details of CPU $($a+1) for the server - $($ListOfAddress[$i])") -ForegroundColor Yellow
163 | Write-Host ("`n`$result.MEMORY_DETAILS[$($a)].MemoryData | ft **")
164 | $result.MEMORY_DETAILS[$a].MemoryData | ft **
165 | }
166 | for($a=0; $a -lt $result.MEMORY_DETAILS_SUMMARY.Count; $a++)
167 | {
168 | Write-Host ("`nMemory details summary of CPU $($a+1) for the server - $($ListOfAddress[$i])") -ForegroundColor Yellow
169 | Write-Host ("`n`$result.MEMORY_DETAILS[$($a+1)].MemoryData | ft **")
170 | $result.MEMORY_DETAILS[$a].MemoryData | ft **
171 | }
172 | }
173 | else
174 | {
175 | Write-Host ("`nMemory components of CPU for the server - $($ListOfAddress[$i])") -ForegroundColor Yellow
176 | Write-Host ("`n`$result.MEMORY_COMPONENTS | ft **")
177 | $result.MEMORY_COMPONENTS | ft **
178 | }
179 | Write-host "`nMemory Info retrieved successfully" -ForegroundColor Green
180 | Write-Host "Server : $($result.IP)"
181 | Write-Host "Status : $($result.STATUS_MESSAGE)"
182 | }
183 | else
184 | {
185 | Write-Host "`nMemory Info Cannot be retrieved"
186 | Write-Host "Server : $($ListOfAddress[$i])"
187 | $failureCount++
188 | }
189 | }
190 |
191 |
192 | $ErrorActionPreference = "Continue"
193 | $WarningPreference ="Continue"
194 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
195 | exit
--------------------------------------------------------------------------------
/HPEiLO/1.5/Using_Invoke-HPOAiLOCommand.ps1:
--------------------------------------------------------------------------------
1 | <#********************************************Description********************************************
2 |
3 | This script is an example of how to use Invoke-HPOAiLOCommand to get or set the iLO configurations
4 | for iLO servers inside the target OA.
5 |
6 | ***************************************************************************************************#>
7 |
8 | #Create an OA connection (Cmdlet Invoke-HPOAiLOCommand is supported in HPOACmdlet 1.1 or later)
9 | $c = Connect-HPOA -OA 192.168.242.62 -username "username" -password "password"
10 |
11 | #Get the RIBCL to send
12 | $ribcl = Get-HPiLODefaultLanguage -Server 192.168.242.62 -Username "username" -Password "password" –OutputType ExternalCommand -DisableCertificateAuthentication
13 |
14 | #Use the connection to OA and the RIBCL command and send it to Bay 2
15 | $c | Invoke-HPOAiLOCommand –iLOCommand $ribcl –Bay 2
--------------------------------------------------------------------------------
/HPEiLO/2.0/InstallSetInput.csv:
--------------------------------------------------------------------------------
1 | Name,Description,Filename,Command,ComponentName,UpdatableBy
2 | TestInstallSet1,Test InstallSet Feature,ilo5_120.bin,ResetServer,Component1,Bmc
3 | ,,cp033330.exe,ApplyUpdate,Component2,Uefi;RuntimeAgent
4 |
--------------------------------------------------------------------------------
/HPEiLO/2.0/iLOInput.csv:
--------------------------------------------------------------------------------
1 | IP,Username,Password
2 | 192.168.10.36,admin,admin123
3 | 192.168.10.15,admin,admin123
4 |
--------------------------------------------------------------------------------
/HPEiLO/2.1/DecodeSMBIOSRecord.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Decodes the SMBIOS Record
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This script gets the SMBIOS data and decodes it.
8 |
9 | .DESCRIPTION
10 | This script gets the SMBIOS data, decodes and displays the some of the information.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOHostData, Read-HPEiLOSMBIOSRecord, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .EXAMPLE
16 |
17 | PS C:\HPEiLOCmdlets\Samples\> .\DecodeSMBIOSData
18 |
19 | This script does not take any parameter.
20 |
21 | .INPUTS
22 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
23 |
24 | .OUTPUTS
25 | None (by default)
26 |
27 | .NOTES
28 | Always run the PowerShell in administrator mode to execute the script.
29 |
30 | Company : Hewlett Packard Enterprise
31 | Version : 2.1.0.0
32 | Date : 04/10/2018
33 |
34 | .LINK
35 | http://www.hpe.com/servers/powershell
36 | #>
37 |
38 | try
39 | {
40 | $path = Split-Path -Parent $PSCommandPath
41 | $path = join-Path $path "\iLOInput.csv"
42 | $inputcsv = Import-Csv $path
43 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
44 | {
45 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
46 | exit
47 | }
48 |
49 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
50 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
51 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
53 | {
54 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
55 | exit
56 | }
57 | }
58 | catch
59 | {
60 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
61 | Write-Host "iLOInput.csv file path: $path"
62 | exit
63 | }
64 |
65 | Clear-Host
66 |
67 | # script execution started
68 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
69 | #Decribe what script does to the user
70 |
71 | Write-Host "This script gets the Event log and IML log information.`n"
72 |
73 | #Load HPEiLOCmdlets module
74 | $InstalledModule = Get-Module
75 | $ModuleNames = $InstalledModule.Name
76 |
77 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
78 | {
79 | Write-Host "Loading module : HPEiLOCmdlets"
80 | Import-Module HPEiLOCmdlets
81 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
82 | {
83 | Write-Host ""
84 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
85 | Write-Host ""
86 | Write-Host "Exit..."
87 | exit
88 | }
89 | }
90 | else
91 | {
92 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
93 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
94 | Write-host ""
95 | }
96 |
97 | $Error.Clear()
98 | #Enable logging feature
99 | Write-Host "Enabling logging feature" -ForegroundColor Green
100 | $log = Enable-HPEiLOLog
101 | $log | fl
102 |
103 | if($Error.Count -ne 0)
104 | {
105 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
106 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
107 | exit
108 | }
109 |
110 | try
111 | {
112 |
113 | $ErrorActionPreference = "SilentlyContinue"
114 | $WarningPreference ="SilentlyContinue"
115 |
116 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
117 |
118 | $Error.Clear()
119 |
120 | if($Connection -eq $null)
121 | {
122 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
123 | $inputcsv.IP | fl
124 | exit;
125 | }
126 | else
127 | {
128 | $Connection | fl
129 | }
130 |
131 | #List of IP's that could not be connected
132 | if($Connection.count -ne $inputcsv.IP.count)
133 | {
134 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
135 | foreach($item in $inputcsv.IP)
136 | {
137 | if($Connection.IP -notcontains $item)
138 | {
139 | $item | fl
140 | }
141 | }
142 | }
143 |
144 | if($connection -ne $null)
145 | {
146 |
147 | Write-Host "`nGetting Host data information." -ForegroundColor Green
148 |
149 | $hostData = Get-HPEiLOHostData -Connection $connection
150 |
151 | Write-Host "`nDecoding the host data information." -ForegroundColor Green
152 |
153 | $result = Read-HPEiLOSMBIOSRecord $hostData
154 |
155 | foreach($output in $result)
156 | {
157 | $recordInfo = New-Object PSObject
158 | Write-Host "`nSMBIOS data for $($output.IP) is:" -ForegroundColor Green
159 | foreach($field in $output.SMBIOSRecord)
160 | {
161 |
162 | switch ( $field.StructureName )
163 | {
164 | SystemInformation
165 | {
166 | $recordInfo | Add-Member NoteProperty "SystemManufacturer" $field.Manufacturer
167 | $recordInfo | Add-Member NoteProperty "SystemSerialNumber" $field.SerialNumber
168 | $recordInfo | Add-Member NoteProperty "ProductName" $field.ProductName
169 | }
170 | BaseboardInformation
171 | {
172 | $recordInfo | Add-Member NoteProperty "AssetTag" $field.AssetTag
173 |
174 | }
175 | ProcessorInformation
176 | {
177 | $recordInfo | Add-Member NoteProperty ("ProcessorManufacturer"+($field.SocketDesignation).replace(' ','')) $field.ProcessorManufacturer
178 | $recordInfo | Add-Member NoteProperty ("ProcessorVersion"+($field.SocketDesignation).replace(' ','')) $field.ProcessorVersion
179 | $recordInfo | Add-Member NoteProperty ("CoreCount"+($field.SocketDesignation).replace(' ','')) $field.CoreCount
180 | $recordInfo | Add-Member NoteProperty ("ThreadCount"+($field.SocketDesignation).replace(' ','')) $field.ThreadCount
181 | }
182 | BIOSInformation
183 | {
184 | $recordInfo | Add-Member NoteProperty "BIOSVersion" $field.BIOSVersion
185 | $recordInfo | Add-Member NoteProperty "BIOSReleaseDate" $field.BIOSReleaseDate
186 | $recordInfo | Add-Member NoteProperty "BIOSROMSize" $field.BIOSROMSize
187 |
188 | }
189 |
190 | }
191 |
192 | }
193 | $recordInfo | fl
194 | }
195 |
196 |
197 | }
198 |
199 | else
200 | {
201 | Write-Host "`nThe given list of IP's are not reachable" -ForegroundColor Red
202 | }
203 | }
204 | catch
205 | {
206 | }
207 | finally
208 | {
209 | if($connection -ne $null)
210 | {
211 | #Disconnect
212 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
213 | $disconnect = Disconnect-HPEiLO -Connection $Connection
214 | $disconnect | fl
215 | Write-Host "All connections disconnected successfully.`n"
216 | }
217 |
218 | #Disable logging feature
219 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
220 | $log = Disable-HPEiLOLog
221 | $log | fl
222 |
223 | if($Error.Count -ne 0 )
224 | {
225 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
226 | }
227 |
228 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
229 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/EstablishingConnection.ps1:
--------------------------------------------------------------------------------
1 | ########################################################
2 | #Connecting to iLO using Connection cmdlets
3 | ########################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script allows user to connect to the iLO for HPE ProLiant servers.
8 |
9 | .DESCRIPTION
10 | This Script allows user to connect to the iLO.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Find-HPEiLO, Connect-HPEiLO, Test-HPEiLOConnection, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER ThreadLimit
16 | Specifies the maximum number of threads that can be spawned by the cmdlets.
17 |
18 | .EXAMPLE
19 | PS C:\HPEiLOCmdlets\Samples\> .\EstablishingConnection.ps1
20 |
21 | This script does not take any parameter.
22 |
23 | .INPUTS
24 | iLOInput.csv file in the script folder location having iLO IPv4/IPv6/Hostname address, iLO Username and iLO Password.
25 |
26 | .OUTPUTS
27 | None (by default)
28 |
29 | .NOTES
30 | Always run the PowerShell in administrator mode to execute the script.
31 |
32 | Company : Hewlett Packard Enterprise
33 | Version : 2.1.0.0
34 | Date : 04/15/2018
35 |
36 | .LINK
37 | http://www.hpe.com/servers/powershell
38 | https://github.com/HewlettPackard/PowerShell-ProLiant-SDK/tree/master/HPEiLO
39 | #>
40 |
41 | param(
42 | [ValidateNotNullorEmpty()]
43 | [Parameter(Mandatory=$false)]
44 | [UInt32[]]$ThreadLimit = 128
45 |
46 | )
47 |
48 | try
49 | {
50 | $path = Split-Path -Parent $PSCommandPath
51 | $path = join-Path $path "\iLOInput.csv"
52 | $inputcsv = Import-Csv $path
53 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
54 | {
55 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
56 | exit
57 | }
58 |
59 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
60 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
61 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
62 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
63 | {
64 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 | }
68 | catch
69 | {
70 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
71 | Write-Host "iLOInput.csv file path: $path"
72 | exit
73 | }
74 |
75 | Clear-Host
76 |
77 | #Load HPEiLOCmdlets module
78 | $InstalledModule = Get-Module
79 | $ModuleNames = $InstalledModule.Name
80 |
81 | function ConvertTo-IPAddressCompressedForm($target,$outIP) {
82 | $out = [System.Net.IPAddress]::TryParse($target,[ref]$outIP)
83 | $out
84 | $outIP
85 | }
86 |
87 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
88 | {
89 | Write-Host "Loading module : HPEiLOCmdlets"
90 | Import-Module HPEiLOCmdlets
91 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
92 | {
93 | Write-Host ""
94 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
95 | Write-Host ""
96 | Write-Host "Exit..."
97 | exit
98 | }
99 | }
100 | else
101 | {
102 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
103 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
104 | Write-host ""
105 | }
106 |
107 | $Error.Clear()
108 |
109 | #Enable logging feature
110 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
111 | $log = Enable-HPEiLOLog
112 | $log | fl
113 |
114 | if($Error.Count -ne 0)
115 | {
116 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
117 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
118 | exit
119 | }
120 |
121 | try
122 | {
123 | $ErrorActionPreference = "SilentlyContinue"
124 | $WarningPreference ="SilentlyContinue"
125 |
126 | $reachableIPList = Find-HPEiLO $inputcsv.IP -WarningAction SilentlyContinue
127 | Write-Host "The below list of IP's are reachable."
128 | $reachableIPList.IP
129 |
130 | #Connect to the reachable IP's using the credential
131 | $reachableData = @()
132 | foreach($ip in $reachableIPList.IP)
133 | {
134 | $index = $inputcsv.IP.IndexOf($ip)
135 | $inputObject = New-Object System.Object
136 |
137 | $inputObject | Add-Member -type NoteProperty -name IP -Value $ip
138 | $inputObject | Add-Member -type NoteProperty -name Username -Value $inputcsv[$index].Username
139 | $inputObject | Add-Member -type NoteProperty -name Password -Value $inputcsv[$index].Password
140 |
141 | $reachableData += $inputObject
142 | }
143 | $threadCount = Get-HPEiLOMaxThreadLimit
144 |
145 | Write-Host "`nThread count that can be spawned are $threadCount." -ForegroundColor Yellow
146 |
147 | #You can change the count values from 64 to 128,256 till 4096
148 | Write-Host "`nChanging the thread count value to $ThreadLimit." -ForegroundColor Yellow
149 |
150 | Set-HPEiLOMaxThreadLimit -MaxThreadLimit 128
151 |
152 | Write-Host ("`nThread limit set to $ThreadLimit." -f (Get-HPEiLOMaxThreadLimit)) -ForegroundColor Yellow
153 |
154 | Write-Host ("`nConnecting to the given target using Connect-HPEiLO." -f (Get-HPEiLOMaxThreadLimit)) -ForegroundColor Yellow
155 | $Connection = Connect-HPEiLO -IP $reachableData.IP -Username $reachableData.Username -Password $reachableData.Password -DisableCertificateAuthentication -WarningAction SilentlyContinue
156 |
157 | $Error.Clear()
158 |
159 | if($Connection -eq $null)
160 | {
161 | Write-Host "`nConnection could not be established to any target iLO." -ForegroundColor Red
162 | $inputcsv.IP | fl
163 | exit;
164 | }
165 | else
166 | {
167 | $Connection | fl
168 | }
169 |
170 | #List of IP's that could not be connected
171 | if($Connection.count -ne $inputcsv.IP.count)
172 | {
173 | $connectionIndex = 0;
174 | Write-Host "`nConnection failed for below set of targets." -ForegroundColor Red
175 | foreach($item in $inputcsv.IP)
176 | {
177 | $outref = $null
178 | $csvout = ConvertTo-IPAddressCompressedForm $item $outref
179 | #Validate for compressed IPv6
180 | if($true -eq $csvout[0])
181 | {
182 | $outref = $null
183 | $connectionout = ConvertTo-IPAddressCompressedForm $Connection.IP[$connectionIndex] $outref
184 | if( $connectionout[1].IPAddressToString -ne $csvout[1].IPAddressToString)
185 | {
186 | $item | fl
187 | }
188 | else
189 | {
190 | $connectionIndex = $connectionIndex+1
191 | }
192 | }
193 | #Validate for Hostname
194 | else
195 | {
196 | if($Connection.Hostname[$connectionIndex] -notcontains $item)
197 | {
198 | $item | fl
199 | }
200 | else
201 | {
202 | $connectionIndex = $connectionIndex+1
203 | }
204 | }
205 | }
206 | }
207 |
208 | #TestConnection
209 | Write-Host "Test connection using Test-HPEiLOConnection." -ForegroundColor Yellow
210 | $testConnection = Test-HPEiLOConnection -Connection $Connection
211 | $testConnection | fl
212 | }
213 | catch
214 | {
215 | }
216 | finally
217 | {
218 | if($connection -ne $null)
219 | {
220 | #Disconnect
221 | Write-Host "Disconnect using Disconnect-HPEiLO." -ForegroundColor Yellow
222 | $disconnect = Disconnect-HPEiLO -Connection $Connection
223 | $disconnect | fl
224 | Write-Host "`nAll connections disconnected successfully."
225 | }
226 |
227 | #Disable logging feature
228 | Write-Host "`nDisabling logging feature.`n" -ForegroundColor Yellow
229 | $log = Disable-HPEiLOLog
230 | $log | fl
231 |
232 | if($Error.Count -ne 0 )
233 | {
234 | Write-Host "`nScript executed with few errors. Check the log files for more information." -ForegroundColor Red
235 | }
236 |
237 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
238 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/InstallSetInput.csv:
--------------------------------------------------------------------------------
1 | Name,Description,Filename,Command,ComponentName,UpdatableBy
2 | TestInstallSet1,Test InstallSet Feature,ilo5_120.bin,ResetServer,Component1,Bmc
3 | ,,cp033330.exe,ApplyUpdate,Component2,Uefi;RuntimeAgent
4 |
--------------------------------------------------------------------------------
/HPEiLO/2.1/LanguagePackInstallation.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #iLO Language pack installation
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script gets the existing language details and adds the language pack.
8 |
9 | .DESCRIPTION
10 | This Script gets the existing language details and adds the language pack.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOLanguage, Add-HPEiLOLanguagePack, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER Location
16 | Specifies the location of the language pack file.
17 |
18 | .PARAMETER UploadTimeout
19 | Specifies the time required to upload the language pack.
20 |
21 | .PARAMETER TPMEnabled
22 | SwitchParameter to enables the language pack to continue updating when the option ROM measuring is enabled.
23 |
24 | .EXAMPLE
25 |
26 | PS C:\HPEiLOCmdlets\Samples\> .\LanguagePackInstallation.ps1 -Location "C:\iLO\Firmwares\lang_ja_110_p04.lpk" -UploadTimeout 180 -TPMEnabled
27 |
28 | This script takes input parameter for Location, UploadTimeout and TPMEnabled.
29 |
30 | .INPUTS
31 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
32 |
33 | .OUTPUTS
34 | None (by default)
35 |
36 | .NOTES
37 | Always run the PowerShell in administrator mode to execute the script.
38 |
39 | Company : Hewlett Packard Enterprise
40 | Version : 2.1.0.0
41 | Date : 04/15/2018
42 |
43 | .LINK
44 | http://www.hpe.com/servers/powershell
45 | #>
46 |
47 | #Command line parameters
48 | Param(
49 |
50 | [Parameter(Mandatory=$true)]
51 | [string[]]$Location,
52 | [int[]]$UploadTimeout,
53 | [Switch]$TPMEnabled
54 |
55 | )
56 |
57 | try
58 | {
59 | $path = Split-Path -Parent $PSCommandPath
60 | $path = join-Path $path "\iLOInput.csv"
61 | $inputcsv = Import-Csv $path
62 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
63 | {
64 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 |
68 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
69 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
70 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
71 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
72 | {
73 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
74 | exit
75 | }
76 | }
77 | catch
78 | {
79 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
80 | Write-Host "iLOInput.csv file path: $path"
81 | exit
82 | }
83 |
84 | Clear-Host
85 |
86 | # script execution started
87 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
88 | #Decribe what script does to the user
89 |
90 | Write-Host "This script adds the language pack to the given server.`n"
91 |
92 | #Load HPEiLOCmdlets module
93 | $InstalledModule = Get-Module
94 | $ModuleNames = $InstalledModule.Name
95 |
96 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
97 | {
98 | Write-Host "Loading module : HPEiLOCmdlets"
99 | Import-Module HPEiLOCmdlets
100 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
101 | {
102 | Write-Host ""
103 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
104 | Write-Host ""
105 | Write-Host "Exit..."
106 | exit
107 | }
108 | }
109 | else
110 | {
111 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
112 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
113 | Write-host ""
114 | }
115 |
116 | $Error.Clear()
117 |
118 | #Enable logging feature
119 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
120 | $log = Enable-HPEiLOLog
121 | $log | fl
122 |
123 | if($Error.Count -ne 0)
124 | {
125 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
126 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
127 | exit
128 | }
129 |
130 | try
131 | {
132 | $ErrorActionPreference = "SilentlyContinue"
133 | $WarningPreference ="SilentlyContinue"
134 |
135 | [bool]$isParameterCountEQOne = $false;
136 |
137 | foreach ($key in $MyInvocation.BoundParameters.keys)
138 | {
139 | $count = $($MyInvocation.BoundParameters[$key]).Count
140 | if($count -ne 1 -and $count -ne $inputcsv.Count)
141 | {
142 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
143 | exit;
144 | }
145 | elseif($count -eq 1)
146 | {
147 | $isParameterCountEQOne = $true;
148 | }
149 |
150 | }
151 |
152 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
153 |
154 | $Error.Clear()
155 |
156 | if($Connection -eq $null)
157 | {
158 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
159 | $inputcsv.IP | fl
160 | exit;
161 | }
162 |
163 | if($Connection.count -ne $inputcsv.IP.count)
164 | {
165 | #List of IP's that could not be connected
166 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
167 | foreach($item in $inputcsv.IP)
168 | {
169 | if($Connection.IP -notcontains $item)
170 | {
171 | $item | fl
172 | }
173 | }
174 |
175 | #Prompt for user input
176 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
177 | if($mismatchinput -ne 'Y')
178 | {
179 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
180 | exit;
181 | }
182 | }
183 |
184 | foreach($connect in $connection)
185 | {
186 | Write-Host "`nGetting existing language details for $($connect.IP)." -ForegroundColor Green
187 |
188 | $output = Get-HPEiLOLanguage -Connection $connect
189 |
190 | if($output.Status -eq "OK")
191 | {
192 | Write-Host "`nDefaultLanguage: $($output.DefaultLanguage)"
193 | $output.Languages | out-string
194 | }
195 | else
196 | {
197 | if($output.StatusInfo -ne $null)
198 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get language details for $($output.IP): "$message -ForegroundColor Red }
199 | }
200 |
201 | Start-Sleep -Seconds 2
202 |
203 | $confirmValue = $false
204 |
205 | Write-Host "`nAdding language pack for $($connect.IP)." -ForegroundColor Green
206 |
207 | if($isParameterCountEQOne)
208 | {
209 | $appendText= " -Location $Location"
210 |
211 | if($UploadTimeout -ne $null)
212 | {
213 | $appendText += " -UploadTimeout $UploadTimeout"
214 | }
215 | }
216 | else
217 | {
218 | $index = $inputcsv.IP.IndexOf($connect.IP)
219 | $appendText= " -Location " +$Location[$index]
220 |
221 | if($UploadTimeout -ne $null)
222 | {
223 | $appendText += " -UploadTimeout " +$UploadTimeout[$index]
224 | }
225 | }
226 |
227 | if($TPMEnabled)
228 | {
229 | $appendText += " -TPMEnabled:$"+"true"
230 | }
231 |
232 | #Executing cmdlet
233 | $cmdletName = "Add-HPEiLOLanguagePack"
234 | $expression = $cmdletName + " -connection $" + "connect" +$appendText
235 | $output = Invoke-Expression $expression
236 |
237 | if($output.StatusInfo -ne $null)
238 | {
239 | $message = $output.StatusInfo.Message;
240 | if($output.Status -eq "ERROR")
241 | {
242 | Write-Host "`nLanguage pack update failed for $($output.IP): "$message -ForegroundColor red
243 | }
244 | }
245 | }
246 | }
247 | catch
248 | {
249 | }
250 | finally
251 | {
252 | if($connection -ne $null)
253 | {
254 | #Disconnect
255 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
256 | $disconnect = Disconnect-HPEiLO -Connection $Connection
257 | $disconnect | fl
258 | Write-Host "All connections disconnected successfully.`n"
259 | }
260 |
261 | #Disable logging feature
262 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
263 | $log = Disable-HPEiLOLog
264 | $log | fl
265 |
266 | if($Error.Count -ne 0 )
267 | {
268 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
269 | }
270 |
271 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
272 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/LicenseKey.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #iLO License Key
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script sets the license key to the given value and retrieves the same.
8 |
9 | .DESCRIPTION
10 | This Script sets the license key to the given value and retrieves the same.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Set-HPEiLOLicense, Get-HPEiLOLicense, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER Key
16 | Specifies the License key to be updated in iLO.
17 |
18 | .EXAMPLE
19 |
20 | PS C:\HPEiLOCmdlets\Samples\> .\LicenseKey.ps1 -Key "12345-M3X2X-12345-ASDGD-12345"
21 |
22 | This script takes the required input and updates the iLO license key.
23 |
24 | .INPUTS
25 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
26 |
27 | .OUTPUTS
28 | None (by default)
29 |
30 | .NOTES
31 | Always run the PowerShell in administrator mode to execute the script.
32 |
33 | Company : Hewlett Packard Enterprise
34 | Version : 2.1.0.0
35 | Date : 04/15/2018
36 |
37 | .LINK
38 | http://www.hpe.com/servers/powershell
39 | #>
40 |
41 | #Command line parameters
42 | Param(
43 |
44 | [Parameter(Mandatory=$true)]
45 | [string[]]$Key
46 | )
47 |
48 | try
49 | {
50 | $path = Split-Path -Parent $PSCommandPath
51 | $path = join-Path $path "\iLOInput.csv"
52 | $inputcsv = Import-Csv $path
53 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
54 | {
55 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
56 | exit
57 | }
58 |
59 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
60 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
61 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
62 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
63 | {
64 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 | }
68 | catch
69 | {
70 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
71 | Write-Host "iLOInput.csv file path: $path"
72 | exit
73 | }
74 |
75 | Clear-Host
76 |
77 | # script execution started
78 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
79 | #Decribe what script does to the user
80 |
81 | Write-Host "This script sets the license key to the given value and gets the same.`n"
82 |
83 | #Load HPEiLOCmdlets module
84 | $InstalledModule = Get-Module
85 | $ModuleNames = $InstalledModule.Name
86 |
87 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
88 | {
89 | Write-Host "Loading module : HPEiLOCmdlets"
90 | Import-Module HPEiLOCmdlets
91 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
92 | {
93 | Write-Host ""
94 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
95 | Write-Host ""
96 | Write-Host "Exit..."
97 | exit
98 | }
99 | }
100 | else
101 | {
102 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
103 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
104 | Write-host ""
105 | }
106 |
107 | $Error.Clear()
108 |
109 | #Enable logging feature
110 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
111 | $log = Enable-HPEiLOLog
112 | $log | fl
113 |
114 | if($Error.Count -ne 0)
115 | {
116 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
117 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
118 | exit
119 | }
120 |
121 | try
122 | {
123 | $ErrorActionPreference = "SilentlyContinue"
124 | $WarningPreference ="SilentlyContinue"
125 |
126 | [bool]$isParameterCountEQOne = $false;
127 |
128 | foreach ($Key in $MyInvocation.BoundParameters.keys)
129 | {
130 | $count = $($MyInvocation.BoundParameters[$Key]).Count
131 | if($count -ne 1 -and $count -ne $inputcsv.Count)
132 | {
133 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
134 | exit;
135 | }
136 | elseif($count -eq 1)
137 | {
138 | $isParameterCountEQOne = $true;
139 | }
140 |
141 | }
142 | Write-Host "`nConnecting using Connect-HPEiLO`n" -ForegroundColor Yellow
143 |
144 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
145 |
146 | $Error.Clear()
147 |
148 | if($Connection -eq $null)
149 | {
150 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
151 | $inputcsv.IP | fl
152 | exit;
153 | }
154 |
155 | if($Connection.count -ne $inputcsv.IP.count)
156 | {
157 | #List of IP's that could not be connected
158 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
159 | foreach($item in $inputcsv.IP)
160 | {
161 | if($Connection.IP -notcontains $item)
162 | {
163 | $item | fl
164 | }
165 | }
166 |
167 | #Prompt for user input
168 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
169 | if($mismatchinput -ne 'Y')
170 | {
171 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
172 | exit;
173 | }
174 | }
175 |
176 | foreach($connect in $connection)
177 | {
178 |
179 | Write-Host "`nSetting the license key to the given value for $($connect.IP)." -ForegroundColor Green
180 | if($isParameterCountEQOne)
181 | {
182 | $result = Set-HPEiLOLicense -Connection $connect -Key $($MyInvocation.BoundParameters[$Key])
183 | }
184 | else
185 | {
186 | $index = $inputcsv.IP.IndexOf($connect.IP)
187 | $result = Set-HPEiLOLicense -Connection $connect -Key $Key[$index]
188 | }
189 |
190 | if($null -ne $result -and $result.Status -eq "ERROR")
191 | {
192 | Write-Host "`nSetting the license key failed for $($connect.IP)." -ForegroundColor Red
193 | $result.StatusInfo | fl
194 | }
195 | else
196 | {
197 | Write-Host "`nGetting License information for $($connect.IP)." -ForegroundColor Green
198 | $result = Get-HPEiLOLicense -Connection $connect
199 | $result | Out-String
200 | }
201 | }
202 | }
203 | catch
204 | {
205 | }
206 | finally
207 | {
208 | if($connection -ne $null)
209 | {
210 | #Disconnect
211 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
212 | $disconnect = Disconnect-HPEiLO -Connection $Connection
213 | $disconnect | fl
214 | Write-Host "All connections disconnected successfully.`n"
215 | }
216 |
217 | #Disable logging feature
218 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
219 | $log = Disable-HPEiLOLog
220 | $log | fl
221 |
222 | if($Error.Count -ne 0 )
223 | {
224 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
225 | }
226 |
227 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
228 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/LogProcessing.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Get Event Log details from iLO
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script gets the log Information.
8 |
9 | .DESCRIPTION
10 | This Script gets Event Log and IML log information.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOIML, Get-HPEiLOEventLog, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .EXAMPLE
16 |
17 | PS C:\HPEiLOCmdlets\Samples\> LogProcessing.ps1
18 |
19 | This script does not take any parameter.
20 |
21 | .INPUTS
22 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
23 |
24 | .OUTPUTS
25 | None (by default)
26 |
27 | .NOTES
28 | Always run the PowerShell in administrator mode to execute the script.
29 |
30 | Company : Hewlett Packard Enterprise
31 | Version : 2.1.0.0
32 | Date : 04/15/2018
33 |
34 | .LINK
35 | http://www.hpe.com/servers/powershell
36 | #>
37 |
38 | try
39 | {
40 | $path = Split-Path -Parent $PSCommandPath
41 | $path = join-Path $path "\iLOInput.csv"
42 | $inputcsv = Import-Csv $path
43 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
44 | {
45 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
46 | exit
47 | }
48 |
49 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
50 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
51 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
53 | {
54 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
55 | exit
56 | }
57 | }
58 | catch
59 | {
60 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
61 | Write-Host "iLOInput.csv file path: $path"
62 | exit
63 | }
64 |
65 | Clear-Host
66 |
67 | # script execution started
68 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
69 | #Decribe what script does to the user
70 |
71 | Write-Host "This script gets the Event log and IML log information.`n"
72 |
73 | #Load HPEiLOCmdlets module
74 | $InstalledModule = Get-Module
75 | $ModuleNames = $InstalledModule.Name
76 |
77 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
78 | {
79 | Write-Host "Loading module : HPEiLOCmdlets"
80 | Import-Module HPEiLOCmdlets
81 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
82 | {
83 | Write-Host ""
84 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
85 | Write-Host ""
86 | Write-Host "Exit..."
87 | exit
88 | }
89 | }
90 | else
91 | {
92 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
93 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
94 | Write-host ""
95 | }
96 |
97 | $Error.Clear()
98 | #Enable logging feature
99 | Write-Host "Enabling logging feature" -ForegroundColor Green
100 | $log = Enable-HPEiLOLog
101 | $log | fl
102 |
103 | if($Error.Count -ne 0)
104 | {
105 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
106 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
107 | exit
108 | }
109 |
110 | try
111 | {
112 |
113 | $ErrorActionPreference = "SilentlyContinue"
114 | $WarningPreference ="SilentlyContinue"
115 |
116 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
117 |
118 | $Error.Clear()
119 |
120 | if($Connection -eq $null)
121 | {
122 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
123 | $inputcsv.IP | fl
124 | exit;
125 | }
126 | else
127 | {
128 | $Connection | fl
129 | }
130 |
131 | #List of IP's that could not be connected
132 | if($Connection.count -ne $inputcsv.IP.count)
133 | {
134 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
135 | foreach($item in $inputcsv.IP)
136 | {
137 | if($Connection.IP -notcontains $item)
138 | {
139 | $item | fl
140 | }
141 | }
142 | }
143 |
144 | if($connection -ne $null)
145 | {
146 |
147 | Write-Host "`nGetting IML Entry information." -ForegroundColor Green
148 |
149 | $result = Get-HPEiLOIML -Connection $connection
150 |
151 | foreach($output in $result)
152 | {
153 |
154 | if($output.Status -eq "OK")
155 | {
156 | Write-Host "`nProcessing IML log information for $($output.IP)." -ForegroundColor Green
157 |
158 | Write-Host "`n$($output.IP) has $($output.IMLLog.Count) IML entries." -ForegroundColor Cyan
159 | $sevs = $(foreach ($event in $output.IMLLog) {$event.Severity})
160 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
161 | $sevcnts = $output.IMLLog | group-object -property Severity –noelement
162 | Write-Host "There are $($uniqsev.Count) type(s) of events in the IML." -ForegroundColor Cyan
163 | $sevcnts | Format-Table
164 | $message = $(foreach ($event in $output.IMLLog) {if($event.Severity -eq "Critical") {$event.Message}})
165 | $uniqmessage = $($message | Sort-Object | Get-Unique)
166 | if($uniqmessage -ne $null)
167 | {
168 | $allMessage = [string]::Join("`n",$uniqmessage)
169 | Write-Host "The critical entry description are: `n$allMessage" -ForegroundColor Cyan
170 | }
171 |
172 | }
173 |
174 | else
175 | {
176 | if($output.StatusInfo -ne $null)
177 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get IML log information: "$message -ForegroundColor Red }
178 | }
179 |
180 | }
181 |
182 |
183 | Write-Host "`nGetting Event Log Entry information." -ForegroundColor Green
184 |
185 | $result = Get-HPEiLOEventLog -Connection $connection
186 |
187 | foreach($output in $result)
188 | {
189 |
190 | if($output.Status -eq "OK")
191 | {
192 | Write-Host "`nProcessing Event log information for $($output.IP)." -ForegroundColor Green
193 |
194 | Write-Host "`n$($output.IP) has $($output.EventLog.Count) log entries." -ForegroundColor Cyan
195 | $sevs = $(foreach ($event in $output.EventLog) {$event.Severity})
196 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
197 | $sevcnts = $output.EventLog | group-object -property Severity –noelement
198 | Write-Host "There are $($uniqsev.Count) type(s) of events in the Event Log." -ForegroundColor Cyan
199 | $sevcnts | Format-Table
200 | $message = $(foreach ($event in $output.EventLog) {if($event.Severity -eq "Critical") {$event.Message}})
201 | $uniqmessage = $($message | Sort-Object | Get-Unique)
202 | if($uniqmessage -ne $null)
203 | {
204 | $allMessage = [string]::Join("`n",$uniqmessage)
205 | Write-Host "The critical entry description are: `n$allMessage" -ForegroundColor Cyan
206 | }
207 |
208 | }
209 |
210 | else
211 | {
212 | if($output.StatusInfo -ne $null)
213 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get Event log information: "$message -ForegroundColor Red }
214 | }
215 |
216 | }
217 | }
218 | else
219 | {
220 | Write-Host "`nThe given list of IP's are not reachable" -ForegroundColor Red
221 | }
222 | }
223 | catch
224 | {
225 | }
226 | finally
227 | {
228 | if($connection -ne $null)
229 | {
230 | #Disconnect
231 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
232 | $disconnect = Disconnect-HPEiLO -Connection $Connection
233 | $disconnect | fl
234 | Write-Host "All connections disconnected successfully.`n"
235 | }
236 |
237 | #Disable logging feature
238 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
239 | $log = Disable-HPEiLOLog
240 | $log | fl
241 |
242 | if($Error.Count -ne 0 )
243 | {
244 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
245 | }
246 |
247 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
248 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/SaveAHSLog.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Download AHS log.
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This script saves the AHS Log.
8 |
9 | .DESCRIPTION
10 | This script saves the AHS Log at the specified location for the given number of days.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Save-HPEiLOAHSLog, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER FileLocation
16 | The directory location where AHS log file gets created.
17 |
18 | .PARAMETER ContactName
19 | Specifies the contact person name that gets inserted in the AHS log header.
20 |
21 | .PARAMETER CompanyName
22 | Specifies the company name that gets inserted in the AHS log header.
23 |
24 | .PARAMETER CaseNumber
25 | Specifies the case number that gets inserted in the AHS log header. Accepts upto 14 characters.
26 |
27 | .PARAMETER Days
28 | This parameter when given downloads the most recent N days of the AHS log. The default value is 1.
29 |
30 | .PARAMETER Email
31 | Specifies the email id of the contact person that gets inserted in the AHS log header.
32 |
33 | .PARAMETER PhoneNumber
34 | Specifies the phone number of the contact person that gets inserted in the AHS log header. Accepts upto 39 characters.
35 |
36 | .EXAMPLE
37 |
38 | PS C:\HPEiLOCmdlets\Samples\> .\SaveAHSLog.ps1 -FileLocation "C:\iLO" -Days 2 -CompanyName "HPE"
39 |
40 | This script takes input parameter for FileLocation, Days and the Company Name.
41 |
42 | .INPUTS
43 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
44 |
45 | .OUTPUTS
46 | None (by default)
47 |
48 | .NOTES
49 | Always run the PowerShell in administrator mode to execute the script.
50 |
51 | Company : Hewlett Packard Enterprise
52 | Version : 2.1.0.0
53 | Date : 04/10/2018
54 |
55 | .LINK
56 | http://www.hpe.com/servers/powershell
57 | #>
58 |
59 | #Command line parameters
60 | Param(
61 |
62 | [Parameter(Mandatory=$true)]
63 | [string[]]$FileLocation,
64 | [Parameter(Mandatory=$true)]
65 | [UInt32[]]$Days,
66 | [string[]]$CaseNumber,
67 | [string[]]$CompanyName,
68 | [string[]]$ContactName,
69 | [string[]]$Email,
70 | [string[]]$PhoneNumber
71 | )
72 |
73 | try
74 | {
75 | $path = Split-Path -Parent $PSCommandPath
76 | $path = join-Path $path "\iLOInput.csv"
77 | $inputcsv = Import-Csv $path
78 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
79 | {
80 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
81 | exit
82 | }
83 |
84 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
85 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
86 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
87 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
88 | {
89 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
90 | exit
91 | }
92 | }
93 | catch
94 | {
95 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
96 | Write-Host "iLOInput.csv file path: $path"
97 | exit
98 | }
99 |
100 | Clear-Host
101 |
102 | # script execution started
103 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
104 | #Decribe what script does to the user
105 |
106 | Write-Host "This script downloads the AHS log in the given location for the given server.`n"
107 |
108 | #Load HPEiLOCmdlets module
109 | $InstalledModule = Get-Module
110 | $ModuleNames = $InstalledModule.Name
111 |
112 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
113 | {
114 | Write-Host "Loading module : HPEiLOCmdlets"
115 | Import-Module HPEiLOCmdlets
116 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
117 | {
118 | Write-Host ""
119 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
120 | Write-Host ""
121 | Write-Host "Exit..."
122 | exit
123 | }
124 | }
125 | else
126 | {
127 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
128 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
129 | Write-host ""
130 | }
131 |
132 | $Error.Clear()
133 |
134 | #Enable logging feature
135 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
136 | $log = Enable-HPEiLOLog
137 | $log | fl
138 |
139 | if($Error.Count -ne 0)
140 | {
141 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
142 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
143 | exit
144 | }
145 |
146 | try
147 | {
148 | $ErrorActionPreference = "SilentlyContinue"
149 | $WarningPreference ="SilentlyContinue"
150 |
151 | [bool]$isParameterCountEQOne = $false;
152 |
153 | foreach ($key in $MyInvocation.BoundParameters.keys)
154 | {
155 | $count = $($MyInvocation.BoundParameters[$key]).Count
156 | if($count -ne 1 -and $count -ne $inputcsv.Count)
157 | {
158 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
159 | exit;
160 | }
161 | elseif($count -eq 1)
162 | {
163 | $isParameterCountEQOne = $true;
164 | }
165 |
166 | }
167 |
168 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
169 |
170 | $Error.Clear()
171 |
172 | if($Connection -eq $null)
173 | {
174 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
175 | $inputcsv.IP | fl
176 | exit;
177 | }
178 |
179 | if($Connection.count -ne $inputcsv.IP.count)
180 | {
181 | #List of IP's that could not be connected
182 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
183 | foreach($item in $inputcsv.IP)
184 | {
185 | if($Connection.IP -notcontains $item)
186 | {
187 | $item | fl
188 | }
189 | }
190 |
191 | #Prompt for user input
192 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
193 | if($mismatchinput -ne 'Y')
194 | {
195 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
196 | exit;
197 | }
198 | }
199 |
200 | foreach($connect in $connection)
201 | {
202 | $index = $inputcsv.IP.IndexOf($connect.IP)
203 | Write-Host "`nDownloading AHS log for $($connect.IP) at the specified location." -ForegroundColor green
204 | $appendText = [string]::Empty
205 | foreach ($key in $MyInvocation.BoundParameters.keys)
206 | {
207 | $value = $($MyInvocation.BoundParameters[$key])
208 | if($value.Count -ne 1){
209 | $appendText +=" -"+$($key)+" "+$value[$index] }
210 | else
211 | { $appendText +=" -"+$($key)+" "+$value }
212 | }
213 | $cmdletName = "Save-HPEiLOAHSLog"
214 | $expression = $cmdletName + " -connection $" + "connect" +$appendText
215 | $output = Invoke-Expression $expression
216 |
217 | if($output.StatusInfo -ne $null)
218 | {
219 | $message = $output.StatusInfo.Message;
220 | if($output.Status -eq "ERROR")
221 | {
222 | Write-Host "`nDownloading AHS failed for $($output.IP): "$message -ForegroundColor red
223 | }
224 | }
225 | }
226 |
227 | }
228 | catch
229 | {
230 | }
231 | finally
232 | {
233 | if($connection -ne $null)
234 | {
235 | #Disconnect
236 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
237 | $disconnect = Disconnect-HPEiLO -Connection $Connection
238 | $disconnect | fl
239 | Write-Host "All connections disconnected successfully.`n"
240 | }
241 | if($Error.Count -ne 0 )
242 | {
243 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
244 | }
245 |
246 | #Disable logging feature
247 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
248 | $log = Disable-HPEiLOLog
249 | $log | fl
250 |
251 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
252 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/UsingFindHPEiLO.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #This script is an example of how to use Find-HPEiLO to find all the iLO servers
3 | #within a server IP Range.
4 | ####################################################################
5 |
6 | <#
7 | .Synopsis
8 | This Script scans over the given IP input and establishes connection.
9 |
10 | .DESCRIPTION
11 | This Script scans over the given IP input and gets the basic information of the reachable IP's and establishes connection to the same.
12 |
13 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
14 | Enable-HPEiLOLog, Find-HPEiLO, Connect-HPEiLO, Disconnect-HPEiLO, Disable-HPEiLOLog
15 |
16 | .EXAMPLE
17 |
18 | PS C:\HPEiLOCmdlets\Samples\> .\UsingFindHPEiLO.ps1
19 |
20 | This script does not take any parameter and gets the iLO information and establishes the connection to the given iLO's.
21 |
22 | .INPUTS
23 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
24 |
25 | .OUTPUTS
26 | None (by default)
27 |
28 | .NOTES
29 | Always run the PowerShell in administrator mode to execute the script.
30 |
31 | Company : Hewlett Packard Enterprise
32 | Version : 2.1.0.0
33 | Date : 04/15/2018
34 |
35 |
36 | .LINK
37 | http://www.hpe.com/servers/powershell
38 | #>
39 |
40 | try
41 | {
42 | $path = Split-Path -Parent $PSCommandPath
43 | $path = join-Path $path "\iLOInput.csv"
44 | $inputcsv = Import-Csv $path
45 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
46 | {
47 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
48 | exit
49 | }
50 |
51 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
53 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
54 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
55 | {
56 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
57 | exit
58 | }
59 | }
60 | catch
61 | {
62 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
63 | Write-Host "iLOInput.csv file path: $path"
64 | exit
65 | }
66 |
67 | Clear-Host
68 |
69 | # script execution started
70 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
71 | #Decribe what script does to the user
72 |
73 | Write-Host "This script gets iLO information and establishes connection to the servers.`n" -ForegroundColor Green
74 |
75 | #Load HPEiLOCmdlets module
76 | $InstalledModule = Get-Module
77 | $ModuleNames = $InstalledModule.Name
78 |
79 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
80 | {
81 | Write-Host "Loading module : HPEiLOCmdlets"
82 | Import-Module HPEiLOCmdlets
83 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
84 | {
85 | Write-Host ""
86 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
87 | Write-Host ""
88 | Write-Host "Exit..."
89 | exit
90 | }
91 | }
92 | else
93 | {
94 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
95 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
96 | Write-host ""
97 | }
98 |
99 | $Error.Clear()
100 |
101 | #Enable logging feature
102 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
103 | $log = Enable-HPEiLOLog
104 | $log | fl
105 |
106 | if($Error.Count -ne 0)
107 | {
108 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
109 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
110 | exit
111 | }
112 |
113 | try
114 | {
115 | $ErrorActionPreference = "SilentlyContinue"
116 | $WarningPreference ="SilentlyContinue"
117 |
118 | Write-Host "Getting iLO information for the given IP input." -ForegroundColor Green
119 |
120 | $output = Find-HPEiLO -Range $inputcsv.IP
121 |
122 | Write-Host "`nThe iLO's that are reachable are" -ForegroundColor Green
123 |
124 | $output | Out-String
125 |
126 | Write-Host "`nEstablishing connection to the reachable IP's." -ForegroundColor Green
127 |
128 | $connection = Find-HPEiLO $inputcsv.IP |
129 |
130 | %{Add-Member -PassThru -InputObject $_ Username $inputcsv[$inputcsv.IP.IndexOf($_.IP)].Username}|
131 |
132 | % {Add-Member -PassThru -InputObject $_ Password $inputcsv[$inputcsv.IP.IndexOf($_.IP)].Password }| Connect-HPEiLO -DisableCertificateAuthentication
133 |
134 | $Error.Clear()
135 |
136 | if($Connection -eq $null)
137 | {
138 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
139 | $inputcsv.IP | fl
140 | exit;
141 | }
142 | else
143 | {
144 | $Connection | fl
145 | }
146 |
147 | #List of IP's that could not be connected
148 | if($Connection.count -ne $inputcsv.IP.count)
149 | {
150 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
151 | foreach($item in $inputcsv.IP)
152 | {
153 | if($Connection.IP -notcontains $item)
154 | {
155 | $item | fl
156 | }
157 | }
158 | }
159 | }
160 | catch
161 | {
162 | }
163 | finally
164 | {
165 | if($connection -ne $null)
166 | {
167 | #Disconnect
168 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
169 | $disconnect = Disconnect-HPEiLO -Connection $Connection
170 | $disconnect | fl
171 | Write-Host "All connections disconnected successfully.`n"
172 | }
173 |
174 | #Disable logging feature
175 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
176 | $log = Disable-HPEiLOLog
177 | $log | fl
178 |
179 | if($Error.Count -ne 0 )
180 | {
181 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
182 | }
183 |
184 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
185 | }
--------------------------------------------------------------------------------
/HPEiLO/2.1/iLOInput.csv:
--------------------------------------------------------------------------------
1 | IP,Username,Password
2 | 192.168.10.36,admin,admin123
3 | 192.168.10.15,admin,admin123
4 |
--------------------------------------------------------------------------------
/HPEiLO/2.2/iLOInput.csv:
--------------------------------------------------------------------------------
1 | IP,Username,Password
2 |
3 | 192.168.10.36,admin,admin123
4 | 192.168.10.15,admin,admin123
5 |
--------------------------------------------------------------------------------
/HPEiLO/3.0/DecodeSMBIOSRecord.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Decodes the SMBIOS Record
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This script gets the SMBIOS data and decodes it.
8 |
9 | .DESCRIPTION
10 | This script gets the SMBIOS data, decodes and displays the some of the information.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOHostData, Read-HPEiLOSMBIOSRecord, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .EXAMPLE
16 |
17 | PS C:\HPEiLOCmdlets\Samples\> .\DecodeSMBIOSData
18 |
19 | This script does not take any parameter.
20 |
21 | .INPUTS
22 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
23 |
24 | .OUTPUTS
25 | None (by default)
26 |
27 | .NOTES
28 | Always run the PowerShell in administrator mode to execute the script.
29 |
30 | Company : Hewlett Packard Enterprise
31 | Version : 3.0.0.0
32 | Date : 01/15/2020
33 |
34 | .LINK
35 | http://www.hpe.com/servers/powershell
36 | #>
37 |
38 | try
39 | {
40 | $path = Split-Path -Parent $PSCommandPath
41 | $path = join-Path $path "\iLOInput.csv"
42 | $inputcsv = Import-Csv $path
43 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
44 | {
45 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
46 | exit
47 | }
48 |
49 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
50 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
51 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
53 | {
54 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
55 | exit
56 | }
57 | }
58 | catch
59 | {
60 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
61 | Write-Host "iLOInput.csv file path: $path"
62 | exit
63 | }
64 |
65 | Clear-Host
66 |
67 | # script execution started
68 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
69 | #Decribe what script does to the user
70 |
71 | Write-Host "This script gets the Event log and IML log information.`n"
72 |
73 | #Load HPEiLOCmdlets module
74 | $InstalledModule = Get-Module
75 | $ModuleNames = $InstalledModule.Name
76 |
77 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
78 | {
79 | Write-Host "Loading module : HPEiLOCmdlets"
80 | Import-Module HPEiLOCmdlets
81 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
82 | {
83 | Write-Host ""
84 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
85 | Write-Host ""
86 | Write-Host "Exit..."
87 | exit
88 | }
89 | }
90 | else
91 | {
92 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
93 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
94 | Write-host ""
95 | }
96 |
97 | $Error.Clear()
98 | #Enable logging feature
99 | Write-Host "Enabling logging feature" -ForegroundColor Green
100 | $log = Enable-HPEiLOLog
101 | $log | fl
102 |
103 | if($Error.Count -ne 0)
104 | {
105 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
106 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
107 | exit
108 | }
109 |
110 | try
111 | {
112 |
113 | $ErrorActionPreference = "SilentlyContinue"
114 | $WarningPreference ="SilentlyContinue"
115 |
116 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
117 |
118 | $Error.Clear()
119 |
120 | if($Connection -eq $null)
121 | {
122 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
123 | $inputcsv.IP | fl
124 | exit;
125 | }
126 |
127 |
128 | #List of IP's that could not be connected
129 | if($Connection.count -ne $inputcsv.IP.count)
130 | {
131 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
132 | foreach($item in $inputcsv.IP)
133 | {
134 | if($Connection.IP -notcontains $item)
135 | {
136 | $item | fl
137 | }
138 | }
139 | }
140 |
141 | if($connection -ne $null)
142 | {
143 |
144 | Write-Host "`nGetting Host data information." -ForegroundColor Green
145 |
146 | $hostData = Get-HPEiLOHostData -Connection $connection
147 |
148 | Write-Host "`nDecoding the host data information." -ForegroundColor Green
149 |
150 | $result = Read-HPEiLOSMBIOSRecord -SMBIOSRecord $hostData
151 |
152 | foreach($output in $result)
153 | {
154 | $recordInfo = New-Object PSObject
155 | Write-Host "`nSMBIOS data for $($output.IP) is:" -ForegroundColor Green
156 | foreach($field in $output.SMBIOSRecord)
157 | {
158 |
159 | switch ( $field.StructureName )
160 | {
161 | SystemInformation
162 | {
163 | $recordInfo | Add-Member NoteProperty "SystemManufacturer" $field.Manufacturer
164 | $recordInfo | Add-Member NoteProperty "SystemSerialNumber" $field.SerialNumber
165 | $recordInfo | Add-Member NoteProperty "ProductName" $field.ProductName
166 | }
167 | BaseboardInformation
168 | {
169 | $recordInfo | Add-Member NoteProperty "AssetTag" $field.AssetTag
170 |
171 | }
172 | ProcessorInformation
173 | {
174 | $recordInfo | Add-Member NoteProperty ("ProcessorManufacturer"+($field.SocketDesignation).replace(' ','')) $field.ProcessorManufacturer
175 | $recordInfo | Add-Member NoteProperty ("ProcessorVersion"+($field.SocketDesignation).replace(' ','')) $field.ProcessorVersion
176 | $recordInfo | Add-Member NoteProperty ("CoreCount"+($field.SocketDesignation).replace(' ','')) $field.CoreCount
177 | $recordInfo | Add-Member NoteProperty ("ThreadCount"+($field.SocketDesignation).replace(' ','')) $field.ThreadCount
178 | }
179 | BIOSInformation
180 | {
181 | $recordInfo | Add-Member NoteProperty "BIOSVersion" $field.BIOSVersion
182 | $recordInfo | Add-Member NoteProperty "BIOSReleaseDate" $field.BIOSReleaseDate
183 | $recordInfo | Add-Member NoteProperty "BIOSROMSize" $field.BIOSROMSize
184 |
185 | }
186 |
187 | }
188 |
189 | }
190 | $recordInfo | fl
191 | }
192 |
193 |
194 | }
195 |
196 | else
197 | {
198 | Write-Host "`nThe given list of IP's are not reachable" -ForegroundColor Red
199 | }
200 | }
201 | catch
202 | {
203 | }
204 | finally
205 | {
206 | if($connection -ne $null)
207 | {
208 | #Disconnect
209 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
210 | $disconnect = Disconnect-HPEiLO -Connection $Connection
211 | $disconnect | fl
212 | Write-Host "All connections disconnected successfully.`n"
213 | }
214 |
215 | #Disable logging feature
216 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
217 | $log = Disable-HPEiLOLog
218 | $log | fl
219 |
220 | if($Error.Count -ne 0 )
221 | {
222 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
223 | }
224 |
225 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
226 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/EstablishingConnection.ps1:
--------------------------------------------------------------------------------
1 | ########################################################
2 | #Connecting to iLO using Connection cmdlets
3 | ########################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script allows user to connect to the iLO for HPE ProLiant servers.
8 |
9 | .DESCRIPTION
10 | This Script allows user to connect to the iLO.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Find-HPEiLO, Connect-HPEiLO, Test-HPEiLOConnection, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER ThreadLimit
16 | Specifies the maximum number of threads that can be spawned by the cmdlets.
17 |
18 | .EXAMPLE
19 | PS C:\HPEiLOCmdlets\Samples\> .\EstablishingConnection.ps1
20 |
21 | This script does not take any parameter.
22 |
23 | .INPUTS
24 | iLOInput.csv file in the script folder location having iLO IPv4/IPv6/Hostname address, iLO Username and iLO Password.
25 |
26 | .OUTPUTS
27 | None (by default)
28 |
29 | .NOTES
30 | Always run the PowerShell in administrator mode to execute the script.
31 |
32 | Company : Hewlett Packard Enterprise
33 | Version : 3.0.0.0
34 | Date : 01/15/2020
35 |
36 | .LINK
37 | http://www.hpe.com/servers/powershell
38 | https://github.com/HewlettPackard/PowerShell-ProLiant-SDK/tree/master/HPEiLO
39 | #>
40 |
41 | param(
42 | [ValidateNotNullorEmpty()]
43 | [Parameter(Mandatory=$false)]
44 | [UInt32[]]$ThreadLimit = 128
45 |
46 | )
47 |
48 | try
49 | {
50 | $path = Split-Path -Parent $PSCommandPath
51 | $path = join-Path $path "\iLOInput.csv"
52 | $inputcsv = Import-Csv $path
53 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
54 | {
55 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
56 | exit
57 | }
58 |
59 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
60 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
61 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
62 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
63 | {
64 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 | }
68 | catch
69 | {
70 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
71 | Write-Host "iLOInput.csv file path: $path"
72 | exit
73 | }
74 |
75 | Clear-Host
76 |
77 | #Load HPEiLOCmdlets module
78 | $InstalledModule = Get-Module
79 | $ModuleNames = $InstalledModule.Name
80 |
81 | function ConvertTo-IPAddressCompressedForm($target,$outIP) {
82 | $out = [System.Net.IPAddress]::TryParse($target,[ref]$outIP)
83 | $out
84 | $outIP
85 | }
86 |
87 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
88 | {
89 | Write-Host "Loading module : HPEiLOCmdlets"
90 | Import-Module HPEiLOCmdlets
91 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
92 | {
93 | Write-Host ""
94 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
95 | Write-Host ""
96 | Write-Host "Exit..."
97 | exit
98 | }
99 | }
100 | else
101 | {
102 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
103 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
104 | Write-host ""
105 | }
106 |
107 | $Error.Clear()
108 |
109 | #Enable logging feature
110 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
111 | $log = Enable-HPEiLOLog
112 | $log | fl
113 |
114 | if($Error.Count -ne 0)
115 | {
116 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
117 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
118 | exit
119 | }
120 |
121 | try
122 | {
123 | $ErrorActionPreference = "SilentlyContinue"
124 | $WarningPreference ="SilentlyContinue"
125 |
126 | $reachableIPList = Find-HPEiLO $inputcsv.IP -WarningAction SilentlyContinue
127 | Write-Host "The below list of IP's are reachable."
128 | $reachableIPList.IP
129 |
130 | #Connect to the reachable IP's using the credential
131 | $reachableData = @()
132 | foreach($ip in $reachableIPList.IP)
133 | {
134 | $index = $inputcsv.IP.IndexOf($ip)
135 | $inputObject = New-Object System.Object
136 |
137 | $inputObject | Add-Member -type NoteProperty -name IP -Value $ip
138 | $inputObject | Add-Member -type NoteProperty -name Username -Value $inputcsv[$index].Username
139 | $inputObject | Add-Member -type NoteProperty -name Password -Value $inputcsv[$index].Password
140 |
141 | $reachableData += $inputObject
142 | }
143 | $threadCount = Get-HPEiLOMaxThreadLimit
144 |
145 | Write-Host "`nThread count that can be spawned are $threadCount." -ForegroundColor Yellow
146 |
147 | #You can change the count values from 64 to 128,256 till 4096
148 | Write-Host "`nChanging the thread count value to $ThreadLimit." -ForegroundColor Yellow
149 |
150 | Set-HPEiLOMaxThreadLimit -MaxThreadLimit 128
151 |
152 | Write-Host ("`nThread limit set to $ThreadLimit." -f (Get-HPEiLOMaxThreadLimit)) -ForegroundColor Yellow
153 |
154 | Write-Host ("`nConnecting to the given target using Connect-HPEiLO." -f (Get-HPEiLOMaxThreadLimit)) -ForegroundColor Yellow
155 | $Connection = Connect-HPEiLO -IP $reachableData.IP -Username $reachableData.Username -Password $reachableData.Password -DisableCertificateAuthentication -WarningAction SilentlyContinue
156 |
157 | $Error.Clear()
158 |
159 | if($Connection -eq $null)
160 | {
161 | Write-Host "`nConnection could not be established to any target iLO." -ForegroundColor Red
162 | $inputcsv.IP | fl
163 | exit;
164 | }
165 | else
166 | {
167 | foreach($object in $Connection)
168 | {
169 | $object | fl
170 |
171 | Write-Host "`nTarget info for $($object.IP):" -ForegroundColor Green
172 | $object.TargetInfo | fl
173 |
174 | Write-Host "`nExtended info for $($object.IP):" -ForegroundColor Green
175 | $object.ExtendedInfo | fl
176 | }
177 | }
178 |
179 | #List of IP's that could not be connected
180 | if($Connection.count -ne $inputcsv.IP.count)
181 | {
182 | $connectionIndex = 0;
183 | Write-Host "`nConnection failed for below set of targets." -ForegroundColor Red
184 | foreach($item in $inputcsv.IP)
185 | {
186 | $outref = $null
187 | $csvout = ConvertTo-IPAddressCompressedForm $item $outref
188 | #Validate for compressed IPv6
189 | if($true -eq $csvout[0])
190 | {
191 | $outref = $null
192 | $connectionout = ConvertTo-IPAddressCompressedForm $Connection.IP[$connectionIndex] $outref
193 | if( $connectionout[1].IPAddressToString -ne $csvout[1].IPAddressToString)
194 | {
195 | $item | fl
196 | }
197 | else
198 | {
199 | $connectionIndex = $connectionIndex+1
200 | }
201 | }
202 | #Validate for Hostname
203 | else
204 | {
205 | if($Connection.Hostname[$connectionIndex] -notcontains $item)
206 | {
207 | $item | fl
208 | }
209 | else
210 | {
211 | $connectionIndex = $connectionIndex+1
212 | }
213 | }
214 | }
215 | }
216 |
217 | #TestConnection
218 | Write-Host "Test connection using Test-HPEiLOConnection." -ForegroundColor Yellow
219 | $testConnection = Test-HPEiLOConnection -Connection $Connection
220 | foreach($data in $testConnection)
221 | {
222 | $data | fl
223 | Write-Host "`nTest connection details for $($data.IP):" -ForegroundColor Green
224 | $data.TestConnectionDetail |fl
225 | }
226 | }
227 | catch
228 | {
229 | }
230 | finally
231 | {
232 | if($connection -ne $null)
233 | {
234 | #Disconnect
235 | Write-Host "Disconnect using Disconnect-HPEiLO." -ForegroundColor Yellow
236 | $disconnect = Disconnect-HPEiLO -Connection $Connection
237 | $disconnect | fl
238 | Write-Host "`nAll connections disconnected successfully."
239 | }
240 |
241 | #Disable logging feature
242 | Write-Host "`nDisabling logging feature.`n" -ForegroundColor Yellow
243 | $log = Disable-HPEiLOLog
244 | $log | fl
245 |
246 | if($Error.Count -ne 0 )
247 | {
248 | Write-Host "`nScript executed with few errors. Check the log files for more information." -ForegroundColor Red
249 | }
250 |
251 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
252 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/InstallSetInput.csv:
--------------------------------------------------------------------------------
1 | Name,Description,Filename,Command,ComponentName,UpdatableBy
2 | TestInstallSet1,Test InstallSet Feature,ilo5_120.bin,ApplyUpdate,Component1,Bmc
3 |
--------------------------------------------------------------------------------
/HPEiLO/3.0/LanguagePackInstallation.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #iLO Language pack installation
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script gets the existing language details and adds the language pack.
8 |
9 | .DESCRIPTION
10 | This Script gets the existing language details and adds the language pack.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOLanguage, Add-HPEiLOLanguagePack, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER Location
16 | Specifies the location of the language pack file.
17 |
18 | .PARAMETER UploadTimeout
19 | Specifies the time required to upload the language pack.
20 |
21 | .PARAMETER TPMEnabled
22 | SwitchParameter to enables the language pack to continue updating when the option ROM measuring is enabled.
23 |
24 | .EXAMPLE
25 |
26 | PS C:\HPEiLOCmdlets\Samples\> .\LanguagePackInstallation.ps1 -Location "C:\iLO\Firmwares\lang_ja_110_p04.lpk" -UploadTimeout 180 -TPMEnabled
27 |
28 | This script takes input parameter for Location, UploadTimeout and TPMEnabled.
29 |
30 | .INPUTS
31 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
32 |
33 | .OUTPUTS
34 | None (by default)
35 |
36 | .NOTES
37 | Always run the PowerShell in administrator mode to execute the script.
38 |
39 | Company : Hewlett Packard Enterprise
40 | Version : 3.0.0.0
41 | Date : 01/15/2020
42 |
43 | .LINK
44 | http://www.hpe.com/servers/powershell
45 | #>
46 |
47 | #Command line parameters
48 | Param(
49 |
50 | [Parameter(Mandatory=$true)]
51 | [string[]]$Location,
52 | [int[]]$UploadTimeout,
53 | [Switch]$TPMEnabled
54 |
55 | )
56 |
57 | try
58 | {
59 | $path = Split-Path -Parent $PSCommandPath
60 | $path = join-Path $path "\iLOInput.csv"
61 | $inputcsv = Import-Csv $path
62 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
63 | {
64 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 |
68 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
69 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
70 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
71 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
72 | {
73 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
74 | exit
75 | }
76 | }
77 | catch
78 | {
79 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
80 | Write-Host "iLOInput.csv file path: $path"
81 | exit
82 | }
83 |
84 | Clear-Host
85 |
86 | # script execution started
87 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
88 | #Decribe what script does to the user
89 |
90 | Write-Host "This script adds the language pack to the given server.`n"
91 |
92 | #Load HPEiLOCmdlets module
93 | $InstalledModule = Get-Module
94 | $ModuleNames = $InstalledModule.Name
95 |
96 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
97 | {
98 | Write-Host "Loading module : HPEiLOCmdlets"
99 | Import-Module HPEiLOCmdlets
100 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
101 | {
102 | Write-Host ""
103 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
104 | Write-Host ""
105 | Write-Host "Exit..."
106 | exit
107 | }
108 | }
109 | else
110 | {
111 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
112 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
113 | Write-host ""
114 | }
115 |
116 | $Error.Clear()
117 |
118 | #Enable logging feature
119 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
120 | $log = Enable-HPEiLOLog
121 | $log | fl
122 |
123 | if($Error.Count -ne 0)
124 | {
125 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
126 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
127 | exit
128 | }
129 |
130 | try
131 | {
132 | $ErrorActionPreference = "SilentlyContinue"
133 | $WarningPreference ="SilentlyContinue"
134 |
135 | [bool]$isParameterCountEQOne = $false;
136 |
137 | foreach ($key in $MyInvocation.BoundParameters.keys)
138 | {
139 | $count = $($MyInvocation.BoundParameters[$key]).Count
140 | if($count -ne 1 -and $count -ne $inputcsv.Count)
141 | {
142 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
143 | exit;
144 | }
145 | elseif($count -eq 1)
146 | {
147 | $isParameterCountEQOne = $true;
148 | }
149 |
150 | }
151 |
152 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
153 |
154 | $Error.Clear()
155 |
156 | if($Connection -eq $null)
157 | {
158 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
159 | $inputcsv.IP | fl
160 | exit;
161 | }
162 |
163 | if($Connection.count -ne $inputcsv.IP.count)
164 | {
165 | #List of IP's that could not be connected
166 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
167 | foreach($item in $inputcsv.IP)
168 | {
169 | if($Connection.IP -notcontains $item)
170 | {
171 | $item | fl
172 | }
173 | }
174 |
175 | #Prompt for user input
176 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
177 | if($mismatchinput -ne 'Y')
178 | {
179 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
180 | exit;
181 | }
182 | }
183 |
184 | foreach($connect in $connection)
185 | {
186 | Write-Host "`nGetting existing language details for $($connect.IP)." -ForegroundColor Green
187 |
188 | $output = Get-HPEiLOLanguage -Connection $connect
189 |
190 | if($output.Status -eq "OK")
191 | {
192 | Write-Host "`nDefaultLanguage: $($output.DefaultLanguage)"
193 | $output.Languages | out-string
194 | }
195 | else
196 | {
197 | if($output.StatusInfo -ne $null)
198 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get language details for $($output.IP): "$message -ForegroundColor Red }
199 | }
200 |
201 | Start-Sleep -Seconds 2
202 |
203 | $confirmValue = $false
204 |
205 | Write-Host "`nAdding language pack for $($connect.IP)." -ForegroundColor Green
206 |
207 | if($isParameterCountEQOne)
208 | {
209 | $appendText= " -Location $Location"
210 |
211 | if($UploadTimeout -ne $null)
212 | {
213 | $appendText += " -UploadTimeout $UploadTimeout"
214 | }
215 | }
216 | else
217 | {
218 | $index = $inputcsv.IP.IndexOf($connect.IP)
219 | $appendText= " -Location " +$Location[$index]
220 |
221 | if($UploadTimeout -ne $null)
222 | {
223 | $appendText += " -UploadTimeout " +$UploadTimeout[$index]
224 | }
225 | }
226 |
227 | if($TPMEnabled)
228 | {
229 | $appendText += " -TPMEnabled:$"+"true"
230 | }
231 |
232 | #Executing cmdlet
233 | $cmdletName = "Add-HPEiLOLanguagePack"
234 | $expression = $cmdletName + " -connection $" + "connect" +$appendText
235 | $output = Invoke-Expression $expression
236 |
237 | if($output.StatusInfo -ne $null)
238 | {
239 | $message = $output.StatusInfo.Message;
240 | if($output.Status -eq "ERROR")
241 | {
242 | Write-Host "`nLanguage pack update failed for $($output.IP): "$message -ForegroundColor red
243 | }
244 | }
245 | }
246 | }
247 | catch
248 | {
249 | }
250 | finally
251 | {
252 | if($connection -ne $null)
253 | {
254 | #Disconnect
255 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
256 | $disconnect = Disconnect-HPEiLO -Connection $Connection
257 | $disconnect | fl
258 | Write-Host "All connections disconnected successfully.`n"
259 | }
260 |
261 | #Disable logging feature
262 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
263 | $log = Disable-HPEiLOLog
264 | $log | fl
265 |
266 | if($Error.Count -ne 0 )
267 | {
268 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
269 | }
270 |
271 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
272 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/LicenseKey.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #iLO License Key
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script sets the license key to the given value and retrieves the same.
8 |
9 | .DESCRIPTION
10 | This Script sets the license key to the given value and retrieves the same.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Set-HPEiLOLicense, Get-HPEiLOLicense, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER Key
16 | Specifies the License key to be updated in iLO.
17 |
18 | .EXAMPLE
19 |
20 | PS C:\HPEiLOCmdlets\Samples\> .\LicenseKey.ps1 -Key "12345-M3X2X-12345-ASDGD-12345"
21 |
22 | This script takes the required input and updates the iLO license key.
23 |
24 | .INPUTS
25 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
26 |
27 | .OUTPUTS
28 | None (by default)
29 |
30 | .NOTES
31 | Always run the PowerShell in administrator mode to execute the script.
32 |
33 | Company : Hewlett Packard Enterprise
34 | Version : 3.0.0.0
35 | Date : 01/15/2020
36 |
37 | .LINK
38 | http://www.hpe.com/servers/powershell
39 | #>
40 |
41 | #Command line parameters
42 | Param(
43 |
44 | [Parameter(Mandatory=$true)]
45 | [string[]]$Key
46 | )
47 |
48 | try
49 | {
50 | $path = Split-Path -Parent $PSCommandPath
51 | $path = join-Path $path "\iLOInput.csv"
52 | $inputcsv = Import-Csv $path
53 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
54 | {
55 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
56 | exit
57 | }
58 |
59 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
60 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
61 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
62 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
63 | {
64 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
65 | exit
66 | }
67 | }
68 | catch
69 | {
70 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
71 | Write-Host "iLOInput.csv file path: $path"
72 | exit
73 | }
74 |
75 | Clear-Host
76 |
77 | # script execution started
78 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
79 | #Decribe what script does to the user
80 |
81 | Write-Host "This script sets the license key to the given value and gets the same.`n"
82 |
83 | #Load HPEiLOCmdlets module
84 | $InstalledModule = Get-Module
85 | $ModuleNames = $InstalledModule.Name
86 |
87 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
88 | {
89 | Write-Host "Loading module : HPEiLOCmdlets"
90 | Import-Module HPEiLOCmdlets
91 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
92 | {
93 | Write-Host ""
94 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
95 | Write-Host ""
96 | Write-Host "Exit..."
97 | exit
98 | }
99 | }
100 | else
101 | {
102 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
103 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
104 | Write-host ""
105 | }
106 |
107 | $Error.Clear()
108 |
109 | #Enable logging feature
110 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
111 | $log = Enable-HPEiLOLog
112 | $log | fl
113 |
114 | if($Error.Count -ne 0)
115 | {
116 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
117 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
118 | exit
119 | }
120 |
121 | try
122 | {
123 | $ErrorActionPreference = "SilentlyContinue"
124 | $WarningPreference ="SilentlyContinue"
125 |
126 | [bool]$isParameterCountEQOne = $false;
127 |
128 | foreach ($Key in $MyInvocation.BoundParameters.keys)
129 | {
130 | $count = $($MyInvocation.BoundParameters[$Key]).Count
131 | if($count -ne 1 -and $count -ne $inputcsv.Count)
132 | {
133 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
134 | exit;
135 | }
136 | elseif($count -eq 1)
137 | {
138 | $isParameterCountEQOne = $true;
139 | }
140 |
141 | }
142 | Write-Host "`nConnecting using Connect-HPEiLO`n" -ForegroundColor Yellow
143 |
144 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
145 |
146 | $Error.Clear()
147 |
148 | if($Connection -eq $null)
149 | {
150 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
151 | $inputcsv.IP | fl
152 | exit;
153 | }
154 |
155 | if($Connection.count -ne $inputcsv.IP.count)
156 | {
157 | #List of IP's that could not be connected
158 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
159 | foreach($item in $inputcsv.IP)
160 | {
161 | if($Connection.IP -notcontains $item)
162 | {
163 | $item | fl
164 | }
165 | }
166 |
167 | #Prompt for user input
168 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
169 | if($mismatchinput -ne 'Y')
170 | {
171 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
172 | exit;
173 | }
174 | }
175 |
176 | foreach($connect in $connection)
177 | {
178 |
179 | Write-Host "`nSetting the license key to the given value for $($connect.IP)." -ForegroundColor Green
180 | if($isParameterCountEQOne)
181 | {
182 | $result = Set-HPEiLOLicense -Connection $connect -Key $($MyInvocation.BoundParameters[$Key])
183 | }
184 | else
185 | {
186 | $index = $inputcsv.IP.IndexOf($connect.IP)
187 | $result = Set-HPEiLOLicense -Connection $connect -Key $Key[$index]
188 | }
189 |
190 | if($null -ne $result -and $result.Status -eq "ERROR")
191 | {
192 | Write-Host "`nSetting the license key failed for $($connect.IP)." -ForegroundColor Red
193 | $result.StatusInfo | fl
194 | }
195 | else
196 | {
197 | Write-Host "`nGetting License information for $($connect.IP)." -ForegroundColor Green
198 | $result = Get-HPEiLOLicense -Connection $connect
199 | $result | Out-String
200 | }
201 | }
202 | }
203 | catch
204 | {
205 | }
206 | finally
207 | {
208 | if($connection -ne $null)
209 | {
210 | #Disconnect
211 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
212 | $disconnect = Disconnect-HPEiLO -Connection $Connection
213 | $disconnect | fl
214 | Write-Host "All connections disconnected successfully.`n"
215 | }
216 |
217 | #Disable logging feature
218 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
219 | $log = Disable-HPEiLOLog
220 | $log | fl
221 |
222 | if($Error.Count -ne 0 )
223 | {
224 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
225 | }
226 |
227 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
228 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/LogProcessing.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Get Event Log details from iLO
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This Script gets the log Information.
8 |
9 | .DESCRIPTION
10 | This Script gets Event Log and IML log information.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Get-HPEiLOIML, Get-HPEiLOEventLog, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .EXAMPLE
16 |
17 | PS C:\HPEiLOCmdlets\Samples\> LogProcessing.ps1
18 |
19 | This script does not take any parameter.
20 |
21 | .INPUTS
22 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
23 |
24 | .OUTPUTS
25 | None (by default)
26 |
27 | .NOTES
28 | Always run the PowerShell in administrator mode to execute the script.
29 |
30 | Company : Hewlett Packard Enterprise
31 | Version : 3.0.0.0
32 | Date : 01/15/2020
33 |
34 | .LINK
35 | http://www.hpe.com/servers/powershell
36 | #>
37 |
38 | try
39 | {
40 | $path = Split-Path -Parent $PSCommandPath
41 | $path = join-Path $path "\iLOInput.csv"
42 | $inputcsv = Import-Csv $path
43 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
44 | {
45 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
46 | exit
47 | }
48 |
49 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
50 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
51 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
53 | {
54 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
55 | exit
56 | }
57 | }
58 | catch
59 | {
60 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
61 | Write-Host "iLOInput.csv file path: $path"
62 | exit
63 | }
64 |
65 | Clear-Host
66 |
67 | # script execution started
68 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
69 | #Decribe what script does to the user
70 |
71 | Write-Host "This script gets the Event log and IML log information.`n"
72 |
73 | #Load HPEiLOCmdlets module
74 | $InstalledModule = Get-Module
75 | $ModuleNames = $InstalledModule.Name
76 |
77 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
78 | {
79 | Write-Host "Loading module : HPEiLOCmdlets"
80 | Import-Module HPEiLOCmdlets
81 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
82 | {
83 | Write-Host ""
84 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
85 | Write-Host ""
86 | Write-Host "Exit..."
87 | exit
88 | }
89 | }
90 | else
91 | {
92 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
93 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
94 | Write-host ""
95 | }
96 |
97 | $Error.Clear()
98 | #Enable logging feature
99 | Write-Host "Enabling logging feature" -ForegroundColor Green
100 | $log = Enable-HPEiLOLog
101 | $log | fl
102 |
103 | if($Error.Count -ne 0)
104 | {
105 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
106 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
107 | exit
108 | }
109 |
110 | try
111 | {
112 |
113 | $ErrorActionPreference = "SilentlyContinue"
114 | $WarningPreference ="SilentlyContinue"
115 |
116 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
117 |
118 | $Error.Clear()
119 |
120 | if($Connection -eq $null)
121 | {
122 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
123 | $inputcsv.IP | fl
124 | exit;
125 | }
126 |
127 | #List of IP's that could not be connected
128 | if($Connection.count -ne $inputcsv.IP.count)
129 | {
130 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
131 | foreach($item in $inputcsv.IP)
132 | {
133 | if($Connection.IP -notcontains $item)
134 | {
135 | $item | fl
136 | }
137 | }
138 | }
139 |
140 | if($connection -ne $null)
141 | {
142 |
143 | Write-Host "`nGetting IML Entry information." -ForegroundColor Green
144 |
145 | $result = Get-HPEiLOIML -Connection $connection
146 |
147 | foreach($output in $result)
148 | {
149 |
150 | if($output.Status -eq "OK")
151 | {
152 | Write-Host "`nProcessing IML log information for $($output.IP)." -ForegroundColor Green
153 |
154 | Write-Host "`n$($output.IP) has $($output.IMLLog.Count) IML entries." -ForegroundColor Cyan
155 | $sevs = $(foreach ($event in $output.IMLLog) {$event.Severity})
156 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
157 | $sevcnts = $output.IMLLog | group-object -property Severity –noelement
158 | Write-Host "There are $($uniqsev.Count) type(s) of events in the IML." -ForegroundColor Cyan
159 | $sevcnts | Format-Table
160 | $message = $(foreach ($event in $output.IMLLog) {if($event.Severity -eq "Critical") {$event.Message}})
161 | $uniqmessage = $($message | Sort-Object | Get-Unique)
162 | if($uniqmessage -ne $null)
163 | {
164 | $allMessage = [string]::Join("`n",$uniqmessage)
165 | Write-Host "The critical entry description are: `n$allMessage" -ForegroundColor Cyan
166 | }
167 |
168 | }
169 |
170 | else
171 | {
172 | if($output.StatusInfo -ne $null)
173 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get IML log information: "$message -ForegroundColor Red }
174 | }
175 |
176 | }
177 |
178 |
179 | Write-Host "`nGetting Event Log Entry information." -ForegroundColor Green
180 |
181 | $result = Get-HPEiLOEventLog -Connection $connection
182 |
183 | foreach($output in $result)
184 | {
185 |
186 | if($output.Status -eq "OK")
187 | {
188 | Write-Host "`nProcessing Event log information for $($output.IP)." -ForegroundColor Green
189 |
190 | Write-Host "`n$($output.IP) has $($output.EventLog.Count) log entries." -ForegroundColor Cyan
191 | $sevs = $(foreach ($event in $output.EventLog) {$event.Severity})
192 | $uniqsev = $($sevs | Sort-Object | Get-Unique)
193 | $sevcnts = $output.EventLog | group-object -property Severity –noelement
194 | Write-Host "There are $($uniqsev.Count) type(s) of events in the Event Log." -ForegroundColor Cyan
195 | $sevcnts | Format-Table
196 | $message = $(foreach ($event in $output.EventLog) {if($event.Severity -eq "Critical") {$event.Message}})
197 | $uniqmessage = $($message | Sort-Object | Get-Unique)
198 | if($uniqmessage -ne $null)
199 | {
200 | $allMessage = [string]::Join("`n",$uniqmessage)
201 | Write-Host "The critical entry description are: `n$allMessage" -ForegroundColor Cyan
202 | }
203 |
204 | }
205 |
206 | else
207 | {
208 | if($output.StatusInfo -ne $null)
209 | { $message = $output.StatusInfo.Message; Write-Host "`nFailed to get Event log information: "$message -ForegroundColor Red }
210 | }
211 |
212 | }
213 | }
214 | else
215 | {
216 | Write-Host "`nThe given list of IP's are not reachable" -ForegroundColor Red
217 | }
218 | }
219 | catch
220 | {
221 | }
222 | finally
223 | {
224 | if($connection -ne $null)
225 | {
226 | #Disconnect
227 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
228 | $disconnect = Disconnect-HPEiLO -Connection $Connection
229 | $disconnect | fl
230 | Write-Host "All connections disconnected successfully.`n"
231 | }
232 |
233 | #Disable logging feature
234 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
235 | $log = Disable-HPEiLOLog
236 | $log | fl
237 |
238 | if($Error.Count -ne 0 )
239 | {
240 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
241 | }
242 |
243 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
244 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/SaveAHSLog.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #Download AHS log.
3 | ####################################################################
4 |
5 | <#
6 | .Synopsis
7 | This script saves the AHS Log.
8 |
9 | .DESCRIPTION
10 | This script saves the AHS Log at the specified location for the given number of days.
11 |
12 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
13 | Enable-HPEiLOLog, Connect-HPEiLO, Save-HPEiLOAHSLog, Disconnect-HPEiLO, Disable-HPEiLOLog
14 |
15 | .PARAMETER FileLocation
16 | The directory location where AHS log file gets created.
17 |
18 | .PARAMETER ContactName
19 | Specifies the contact person name that gets inserted in the AHS log header.
20 |
21 | .PARAMETER CompanyName
22 | Specifies the company name that gets inserted in the AHS log header.
23 |
24 | .PARAMETER CaseNumber
25 | Specifies the case number that gets inserted in the AHS log header. Accepts upto 14 characters.
26 |
27 | .PARAMETER Days
28 | This parameter when given downloads the most recent N days of the AHS log. The default value is 1.
29 |
30 | .PARAMETER Email
31 | Specifies the email id of the contact person that gets inserted in the AHS log header.
32 |
33 | .PARAMETER PhoneNumber
34 | Specifies the phone number of the contact person that gets inserted in the AHS log header. Accepts upto 39 characters.
35 |
36 | .EXAMPLE
37 |
38 | PS C:\HPEiLOCmdlets\Samples\> .\SaveAHSLog.ps1 -FileLocation "C:\iLO" -Days 2 -CompanyName "HPE"
39 |
40 | This script takes input parameter for FileLocation, Days and the Company Name.
41 |
42 | .INPUTS
43 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
44 |
45 | .OUTPUTS
46 | None (by default)
47 |
48 | .NOTES
49 | Always run the PowerShell in administrator mode to execute the script.
50 |
51 | Company : Hewlett Packard Enterprise
52 | Version : 3.0.0.0
53 | Date : 01/15/2020
54 |
55 | .LINK
56 | http://www.hpe.com/servers/powershell
57 | #>
58 |
59 | #Command line parameters
60 | Param(
61 |
62 | [Parameter(Mandatory=$true)]
63 | [string[]]$FileLocation,
64 | [Parameter(Mandatory=$true)]
65 | [UInt32[]]$Days,
66 | [string[]]$CaseNumber,
67 | [string[]]$CompanyName,
68 | [string[]]$ContactName,
69 | [string[]]$Email,
70 | [string[]]$PhoneNumber
71 | )
72 |
73 | try
74 | {
75 | $path = Split-Path -Parent $PSCommandPath
76 | $path = join-Path $path "\iLOInput.csv"
77 | $inputcsv = Import-Csv $path
78 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
79 | {
80 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
81 | exit
82 | }
83 |
84 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
85 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
86 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
87 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
88 | {
89 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
90 | exit
91 | }
92 | }
93 | catch
94 | {
95 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
96 | Write-Host "iLOInput.csv file path: $path"
97 | exit
98 | }
99 |
100 | Clear-Host
101 |
102 | # script execution started
103 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
104 | #Decribe what script does to the user
105 |
106 | Write-Host "This script downloads the AHS log in the given location for the given server.`n"
107 |
108 | #Load HPEiLOCmdlets module
109 | $InstalledModule = Get-Module
110 | $ModuleNames = $InstalledModule.Name
111 |
112 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
113 | {
114 | Write-Host "Loading module : HPEiLOCmdlets"
115 | Import-Module HPEiLOCmdlets
116 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
117 | {
118 | Write-Host ""
119 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
120 | Write-Host ""
121 | Write-Host "Exit..."
122 | exit
123 | }
124 | }
125 | else
126 | {
127 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
128 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
129 | Write-host ""
130 | }
131 |
132 | $Error.Clear()
133 |
134 | #Enable logging feature
135 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
136 | $log = Enable-HPEiLOLog
137 | $log | fl
138 |
139 | if($Error.Count -ne 0)
140 | {
141 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
142 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
143 | exit
144 | }
145 |
146 | try
147 | {
148 | $ErrorActionPreference = "SilentlyContinue"
149 | $WarningPreference ="SilentlyContinue"
150 |
151 | [bool]$isParameterCountEQOne = $false;
152 |
153 | foreach ($key in $MyInvocation.BoundParameters.keys)
154 | {
155 | $count = $($MyInvocation.BoundParameters[$key]).Count
156 | if($count -ne 1 -and $count -ne $inputcsv.Count)
157 | {
158 | Write-Host "The input paramter value count and the input csv IP count does not match. Provide equal number of IP's and parameter values." -ForegroundColor Red
159 | exit;
160 | }
161 | elseif($count -eq 1)
162 | {
163 | $isParameterCountEQOne = $true;
164 | }
165 |
166 | }
167 |
168 | $connection = Connect-HPEiLO -IP $inputcsv.IP -Username $inputcsv.Username -Password $inputcsv.Password -DisableCertificateAuthentication
169 |
170 | $Error.Clear()
171 |
172 | if($Connection -eq $null)
173 | {
174 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
175 | $inputcsv.IP | fl
176 | exit;
177 | }
178 |
179 | if($Connection.count -ne $inputcsv.IP.count)
180 | {
181 | #List of IP's that could not be connected
182 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
183 | foreach($item in $inputcsv.IP)
184 | {
185 | if($Connection.IP -notcontains $item)
186 | {
187 | $item | fl
188 | }
189 | }
190 |
191 | #Prompt for user input
192 | $mismatchinput = Read-Host -Prompt 'Connection object count and parameter value count does not match. Do you want to continue? Enter Y to continue with script execution. Enter N to cancel.'
193 | if($mismatchinput -ne 'Y')
194 | {
195 | Write-Host "`n****** Script execution stopped ******" -ForegroundColor Yellow
196 | exit;
197 | }
198 | }
199 |
200 | foreach($connect in $connection)
201 | {
202 | $index = $inputcsv.IP.IndexOf($connect.IP)
203 | Write-Host "`nDownloading AHS log for $($connect.IP) at the specified location." -ForegroundColor green
204 | $appendText = [string]::Empty
205 | foreach ($key in $MyInvocation.BoundParameters.keys)
206 | {
207 | $value = $($MyInvocation.BoundParameters[$key])
208 | if($value.Count -ne 1){
209 | $appendText +=" -"+$($key)+" "+$value[$index] }
210 | else
211 | { $appendText +=" -"+$($key)+" "+$value }
212 | }
213 | $cmdletName = "Save-HPEiLOAHSLog"
214 | $expression = $cmdletName + " -connection $" + "connect" +$appendText
215 | $output = Invoke-Expression $expression
216 |
217 | if($output.StatusInfo -ne $null)
218 | {
219 | $message = $output.StatusInfo.Message;
220 | if($output.Status -eq "ERROR")
221 | {
222 | Write-Host "`nDownloading AHS failed for $($output.IP): "$message -ForegroundColor red
223 | }
224 | }
225 | }
226 |
227 | }
228 | catch
229 | {
230 | }
231 | finally
232 | {
233 | if($connection -ne $null)
234 | {
235 | #Disconnect
236 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
237 | $disconnect = Disconnect-HPEiLO -Connection $Connection
238 | $disconnect | fl
239 | Write-Host "All connections disconnected successfully.`n"
240 | }
241 | if($Error.Count -ne 0 )
242 | {
243 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
244 | }
245 |
246 | #Disable logging feature
247 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
248 | $log = Disable-HPEiLOLog
249 | $log | fl
250 |
251 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
252 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/UsingFindHPEiLO.ps1:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | #This script is an example of how to use Find-HPEiLO to find all the iLO servers
3 | #within a server IP Range.
4 | ####################################################################
5 |
6 | <#
7 | .Synopsis
8 | This Script scans over the given IP input and establishes connection.
9 |
10 | .DESCRIPTION
11 | This Script scans over the given IP input and gets the basic information of the reachable IP's and establishes connection to the same.
12 |
13 | The cmdlets used from HPEiLOCmdlets module in the script are as stated below:
14 | Enable-HPEiLOLog, Find-HPEiLO, Connect-HPEiLO, Disconnect-HPEiLO, Disable-HPEiLOLog
15 |
16 | .EXAMPLE
17 |
18 | PS C:\HPEiLOCmdlets\Samples\> .\UsingFindHPEiLO.ps1
19 |
20 | This script does not take any parameter and gets the iLO information and establishes the connection to the given iLO's.
21 |
22 | .INPUTS
23 | iLOInput.csv file in the script folder location having iLO IPv4 address, iLO Username and iLO Password.
24 |
25 | .OUTPUTS
26 | None (by default)
27 |
28 | .NOTES
29 | Always run the PowerShell in administrator mode to execute the script.
30 |
31 | Company : Hewlett Packard Enterprise
32 | Version : 3.0.0.0
33 | Date : 01/15/2020
34 |
35 |
36 | .LINK
37 | http://www.hpe.com/servers/powershell
38 | #>
39 |
40 | try
41 | {
42 | $path = Split-Path -Parent $PSCommandPath
43 | $path = join-Path $path "\iLOInput.csv"
44 | $inputcsv = Import-Csv $path
45 | if($inputcsv.IP.count -eq $inputcsv.Username.count -eq $inputcsv.Password.count -eq 0)
46 | {
47 | Write-Host "Provide values for IP, Username and Password columns in the iLOInput.csv file and try again."
48 | exit
49 | }
50 |
51 | $notNullIP = $inputcsv.IP | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
52 | $notNullUsername = $inputcsv.Username | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
53 | $notNullPassword = $inputcsv.Password | Where-Object {-Not [string]::IsNullOrWhiteSpace($_)}
54 | if(-Not($notNullIP.Count -eq $notNullUsername.Count -eq $notNullPassword.Count))
55 | {
56 | Write-Host "Provide equal number of values for IP, Username and Password columns in the iLOInput.csv file and try again."
57 | exit
58 | }
59 | }
60 | catch
61 | {
62 | Write-Host "iLOInput.csv file import failed. Please check the file path of the iLOInput.csv file and try again."
63 | Write-Host "iLOInput.csv file path: $path"
64 | exit
65 | }
66 |
67 | Clear-Host
68 |
69 | # script execution started
70 | Write-Host "****** Script execution started ******`n" -ForegroundColor Yellow
71 | #Decribe what script does to the user
72 |
73 | Write-Host "This script gets iLO information and establishes connection to the servers.`n" -ForegroundColor Green
74 |
75 | #Load HPEiLOCmdlets module
76 | $InstalledModule = Get-Module
77 | $ModuleNames = $InstalledModule.Name
78 |
79 | if(-not($ModuleNames -like "HPEiLOCmdlets"))
80 | {
81 | Write-Host "Loading module : HPEiLOCmdlets"
82 | Import-Module HPEiLOCmdlets
83 | if(($(Get-Module -Name "HPEiLOCmdlets") -eq $null))
84 | {
85 | Write-Host ""
86 | Write-Host "HPEiLOCmdlets module cannot be loaded. Please fix the problem and try again"
87 | Write-Host ""
88 | Write-Host "Exit..."
89 | exit
90 | }
91 | }
92 | else
93 | {
94 | $InstallediLOModule = Get-Module -Name "HPEiLOCmdlets"
95 | Write-Host "HPEiLOCmdlets Module Version : $($InstallediLOModule.Version) is installed on your machine."
96 | Write-host ""
97 | }
98 |
99 | $Error.Clear()
100 |
101 | #Enable logging feature
102 | Write-Host "Enabling logging feature" -ForegroundColor Yellow
103 | $log = Enable-HPEiLOLog
104 | $log | fl
105 |
106 | if($Error.Count -ne 0)
107 | {
108 | Write-Host "`nPlease launch the PowerShell in administrator mode and run the script again." -ForegroundColor Yellow
109 | Write-Host "`n****** Script execution terminated ******" -ForegroundColor Red
110 | exit
111 | }
112 |
113 | try
114 | {
115 | $ErrorActionPreference = "SilentlyContinue"
116 | $WarningPreference ="SilentlyContinue"
117 |
118 | Write-Host "Getting iLO information for the given IP input." -ForegroundColor Green
119 |
120 | $output = Find-HPEiLO -Range $inputcsv.IP
121 |
122 | Write-Host "`nThe iLO's that are reachable are" -ForegroundColor Green
123 |
124 | $output | Out-String
125 |
126 | Write-Host "`nEstablishing connection to the reachable IP's." -ForegroundColor Green
127 |
128 | $connection = Find-HPEiLO $inputcsv.IP
129 | $reachableData = @()
130 | foreach($ip in $connection.IP)
131 | {
132 | $index = $inputcsv.IP.IndexOf($ip)
133 | $inputObject = New-Object System.Object
134 |
135 | $inputObject | Add-Member -type NoteProperty -name IP -Value $ip
136 | $inputObject | Add-Member -type NoteProperty -name Username -Value $inputcsv[$index].Username
137 | $inputObject | Add-Member -type NoteProperty -name Password -Value $inputcsv[$index].Password
138 |
139 | $reachableData += $inputObject
140 | }
141 |
142 | $connection = $reachableData | Connect-HPEiLO -DisableCertificateAuthentication
143 |
144 |
145 | $Error.Clear()
146 |
147 | if($Connection -eq $null)
148 | {
149 | Write-Host "`nConnection could not be established to any target iLO.`n" -ForegroundColor Red
150 | $inputcsv.IP | fl
151 | exit;
152 | }
153 | else
154 | {
155 | $Connection | fl
156 | }
157 |
158 | #List of IP's that could not be connected
159 | if($Connection.count -ne $inputcsv.IP.count)
160 | {
161 | Write-Host "`nConnection failed for below set of targets" -ForegroundColor Red
162 | foreach($item in $inputcsv.IP)
163 | {
164 | if($Connection.IP -notcontains $item)
165 | {
166 | $item | fl
167 | }
168 | }
169 | }
170 | }
171 | catch
172 | {
173 | }
174 | finally
175 | {
176 | if($connection -ne $null)
177 | {
178 | #Disconnect
179 | Write-Host "Disconnect using Disconnect-HPEiLO `n" -ForegroundColor Yellow
180 | $disconnect = Disconnect-HPEiLO -Connection $Connection
181 | $disconnect | fl
182 | Write-Host "All connections disconnected successfully.`n"
183 | }
184 |
185 | #Disable logging feature
186 | Write-Host "Disabling logging feature`n" -ForegroundColor Yellow
187 | $log = Disable-HPEiLOLog
188 | $log | fl
189 |
190 | if($Error.Count -ne 0 )
191 | {
192 | Write-Host "`nScript executed with few errors. Check the log files for more information.`n" -ForegroundColor Red
193 | }
194 |
195 | Write-Host "`n****** Script execution completed ******" -ForegroundColor Yellow
196 | }
--------------------------------------------------------------------------------
/HPEiLO/3.0/iLOInput.csv:
--------------------------------------------------------------------------------
1 | IP,Username,Password
2 | 192.168.10.22,admin,admin123
3 | 192.168.8.24,admin,admin123
4 |
--------------------------------------------------------------------------------