Skip to content

Commit

Permalink
Release 3.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
U-AMERICAS\Trevor_Squillario authored and U-AMERICAS\Trevor_Squillario committed Sep 8, 2023
1 parent cdd42bb commit 1e5da32
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 58 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.6.2]() - 2023-09-08
### Fixed
- Issue with Set-OMETemplateNetwork when not specifing the -Mode parameter
- Issue with Update-OMEFirmware when -DeviceFilter is specified but no device is found. The null return value will select all devices in baseline. ([Issue #15](https://github.com/dell/OpenManage-PowerShell-Modules/issues/15))

### Changed
- Get-OMEFirmwareCompliance and Update-OMEFirmware to allow multiple values for -ComponentFilter ([Issue #12](https://github.com/dell/OpenManage-PowerShell-Modules/issues/12))

## [3.6.1]() - 2023-07-11
### Fixed
- Issue with Get-OMEJob not listing all execution histories when using the -Detail parameter
Expand Down
4 changes: 2 additions & 2 deletions DellOpenManage/DellOpenManage.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Trevor Squillario <Trevor.Squillario@Dell.com>
#
# Generated on: 7/11/2023
# Generated on: 9/8/2023
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'DellOpenManage.psm1'

# Version number of this module.
ModuleVersion = '3.6.1'
ModuleVersion = '3.6.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
110 changes: 71 additions & 39 deletions DellOpenManage/Public/OME/Get-OMEFirmwareCompliance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ using module ..\..\Classes\Device.psm1
using module ..\..\Classes\FirmwareBaseline.psm1
using module ..\..\Classes\ComponentCompliance.psm1

function Get-FirmwareComplianceObject($UpdateActionSet, $Component, $ComplianceDevice) {
# Check for UpdateAction to allow for downgrade of firmware
if ($UpdateActionSet.ToUpper().Contains($Component.UpdateAction)) {
# Create object for display to user
$ReportObject = [ComponentCompliance]@{
DeviceId = $ComplianceDevice.DeviceId
ServiceTag = $ComplianceDevice.ServiceTag
DeviceModel = $ComplianceDevice.DeviceModel
DeviceName = $ComplianceDevice.DeviceName
Id = $Component.Id
Version = $Component.Version
CurrentVersion = $Component.CurrentVersion
Path = $Component.Path
Name = $Component.Name
Criticality = $Component.Criticality
UniqueIdentifier = $Component.UniqueIdentifier
TargetIdentifier = $Component.TargetIdentifier
UpdateAction = $Component.UpdateAction
SourceName = $Component.SourceName
PrerequisiteInfo = $Component.PrerequisiteInfo
ImpactAssessment = $Component.ImpactAssessment
Uri = $Component.Uri
RebootRequired = $Component.RebootRequired
ComplianceStatus = $Component.ComplianceStatus
ComponentType = $Component.ComponentType
}
return $ReportObject
}
}

function Get-OMEFirmwareCompliance {
<#
Copyright (c) 2018 Dell EMC Corporation
Expand Down Expand Up @@ -31,7 +61,7 @@ limitations under the License.
.PARAMETER DeviceFilter
Array of type Device returned from Get-OMEDevice function. Used to limit the devices updated within the baseline.
.PARAMETER ComponentFilter
String to represent component name. Used to limit the components updated within the baseline. Supports regex via Powershell -match
Array of Strings that represent component name. Used to limit the components updated within the baseline. Supports regex via Powershell -match
.PARAMETER UpdateAction
Determines what type of updates will be performed. (Default="Upgrade", "Downgrade", "All")
.PARAMETER Output
Expand All @@ -49,6 +79,10 @@ limitations under the License.
"AllLatest" | Get-OMEFirmwareBaseline | Get-OMEFirmwareCompliance -ComponentFilter "iDRAC" | Format-Table
Filter report by component in baseline
.EXAMPLE
"AllLatest" | Get-OMEFirmwareBaseline | Get-OMEFirmwareCompliance -ComponentFilter -ComponentFilter "iDRAC", "BIOS" | Format-Table
Filter report by multiple components in baseline
#>

[CmdletBinding()]
Expand All @@ -60,7 +94,7 @@ param(
[Device[]]$DeviceFilter,

[Parameter(Mandatory=$false)]
[String]$ComponentFilter,
[String[]]$ComponentFilter,

[Parameter(Mandatory=$false)]
[ValidateSet("Upgrade", "Downgrade", "All")]
Expand Down Expand Up @@ -88,6 +122,7 @@ Process {
} else {
$BaselineId = $Id
}

$ComplURL = $BaseUri + "/api/UpdateService/Baselines($($BaselineId))/DeviceComplianceReports"
$Response = Invoke-WebRequest -Uri $ComplURL -UseBasicParsing -Headers $Headers -ContentType $Type -Method GET
$DeviceComplianceReport = @()
Expand Down Expand Up @@ -135,50 +170,49 @@ Process {
# Check if the device is in the provided Devices list. Only return results for devices in the list, if a list was provided
if (($DeviceFilter.Count -gt 0 -and $DeviceFilter.Id -contains $ComplianceDevice.DeviceId) -or $DeviceFilter.Count -eq 0) {
$sourcesString = $null
$DeviceComplianceReportPerDevice = @()
$CompList = $ComplianceDevice.'ComponentComplianceReports'
if ($CompList.Length -gt 0) {
# Loop through components
foreach ($Component in $CompList) {
if (($ComponentFilter -ne "" -and $Component -match $ComponentFilter) -or $ComponentFilter -eq "") {
# Check for UpdateAction to allow for downgrade of firmware
if ($UpdateActionSet.ToUpper().Contains($Component.UpdateAction)) {
# Create string to be used in payload
$sourceName = $Component.'SourceName'
if ($sourcesString.Length -eq 0) {
$sourcesString += $sourceName
}
else {
$sourcesString += ';' + $sourceName
}
# Create object for display to user
$DeviceComplianceReport += [ComponentCompliance]@{
DeviceId = $ComplianceDevice.DeviceId
ServiceTag = $ComplianceDevice.ServiceTag
DeviceModel = $ComplianceDevice.DeviceModel
DeviceName = $ComplianceDevice.DeviceName
Id = $Component.Id
Version = $Component.Version
CurrentVersion = $Component.CurrentVersion
Path = $Component.Path
Name = $Component.Name
Criticality = $Component.Criticality
UniqueIdentifier = $Component.UniqueIdentifier
TargetIdentifier = $Component.TargetIdentifier
UpdateAction = $Component.UpdateAction
SourceName = $Component.SourceName
PrerequisiteInfo = $Component.PrerequisiteInfo
ImpactAssessment = $Component.ImpactAssessment
Uri = $Component.Uri
RebootRequired = $Component.RebootRequired
ComplianceStatus = $Component.ComplianceStatus
ComponentType = $Component.ComponentType
$DeviceComplianceComponentReportObject = $null
# No Component filter set
if ($ComponentFilter.Length -eq 0) {
$DeviceComplianceComponentReportObject = Get-FirmwareComplianceObject -UpdateActionSet $UpdateActionSet -Component $Component -ComplianceDevice $ComplianceDevice
if ($null -ne $DeviceComplianceComponentReportObject) {
$DeviceComplianceReportPerDevice += $DeviceComplianceComponentReportObject
$DeviceComplianceReport += $DeviceComplianceComponentReportObject
}
} else {
foreach ($Filter in $ComponentFilter) {
if (($Filter -ne "" -and $Component.Name -match $Filter)) {
$DeviceComplianceComponentReportObject = Get-FirmwareComplianceObject -UpdateActionSet $UpdateActionSet -Component $Component -ComplianceDevice $ComplianceDevice
if ($null -ne $DeviceComplianceComponentReportObject) {
$DeviceComplianceReportPerDevice += $DeviceComplianceComponentReportObject
$DeviceComplianceReport += $DeviceComplianceComponentReportObject
}
}
}
}
}
}

# Now what we have the filtered list of updatable components, let's build the sourceString
foreach ($DeviceComplianceComponentReport in $DeviceComplianceReportPerDevice) {
# Create string to be used in payload
if ($null -ne $DeviceComplianceComponentReport) {
$sourceName = $DeviceComplianceComponentReport.'SourceName'
if ($sourcesString.Length -eq 0) {
$sourcesString += $sourceName
}
else {
$sourcesString += ';' + $sourceName
}
}
}

# Create object to be used in payload
if ( $null -ne $sourcesString) {
if ($null -ne $sourcesString) {
$DeviceComplianceReportTargetList += @{
Data = $sourcesString
Id = $ComplianceDevice.'DeviceId'
Expand All @@ -202,9 +236,7 @@ Process {
}
}
Catch {
Write-Error ($_.ErrorDetails)
Write-Error ($_.Exception | Format-List -Force | Out-String)
Write-Error ($_.InvocationInfo | Format-List -Force | Out-String)
Resolve-Error $_
}
}

Expand Down
1 change: 1 addition & 0 deletions DellOpenManage/Public/OME/Get-OMETemplateNetwork.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function Get-OMETemplateNetwork {
$Headers."X-Auth-Token" = $SessionAuth.Token

$TemplateVlanUrl = $BaseUri + "/api/TemplateService/Templates($($Template.Id))/Views(4)/AttributeViewDetails"
Write-Verbose $TemplateVlanUrl
$TemplateVlanResponse = Invoke-WebRequest -UseBasicParsing -Uri $TemplateVlanUrl -Headers $Headers -Method Get -ContentType $ContentType
if ($TemplateVlanResponse.StatusCode -eq 200) {
$TemplateVlanInfo = $TemplateVlanResponse.Content | ConvertFrom-Json
Expand Down
6 changes: 2 additions & 4 deletions DellOpenManage/Public/OME/Set-OMETemplateNetwork.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ param(

[Parameter(Mandatory=$false)]
[ValidateSet("Append", "Replace", "Remove")]
[String] $Mode
[String] $Mode = "Append"
)

Begin {}
Expand All @@ -187,9 +187,6 @@ Process {
} else {
$UnTaggedNetworkId = $UnTaggedNetwork.Id
}
if ($TaggedNetworkIds.Length -gt 0 -or $null -ne $UnTaggedNetwork) {
if ($null -eq $Mode) { throw [System.ArgumentNullException] "Mode parameter required when specifing -TaggedNetworks or -UnTaggedNetwork" }
}
# Get network port and vlan info from existing template
$VlanPortMap = Get-OMETemplateNetwork -Template $Template
Write-Verbose "Current template network config"
Expand All @@ -198,6 +195,7 @@ Process {
-TaggedNetworkIds $TaggedNetworkIds -UnTaggedNetworkId $UnTaggedNetworkId -VlanPortMap $VlanPortMap -PropagateVlan $PropagateVlan -Mode $Mode
$UpdateNetworkConfigURL = $BaseUri + "/api/TemplateService/Actions/TemplateService.UpdateNetworkConfig"
$UpdateNetworkConfigPayload = $UpdateNetworkConfigPayload | ConvertTo-Json -Depth 6
Write-Verbose "New template network config"
Write-Verbose $UpdateNetworkConfigPayload
$UpdateNetworkConfigResp = Invoke-WebRequest -Uri $UpdateNetworkConfigURL -UseBasicParsing -Headers $Headers -ContentType $Type -Method POST -Body $UpdateNetworkConfigPayload
if ($UpdateNetworkConfigResp.StatusCode -in 200, 201) {
Expand Down
20 changes: 14 additions & 6 deletions DellOpenManage/Public/OME/Update-OMEFirmware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ limitations under the License.
.PARAMETER DeviceFilter
Array of type Device returned from Get-OMEDevice function. Used to limit the devices updated within the baseline.
.PARAMETER ComponentFilter
String to represent component name. Used to limit the components updated within the baseline. Supports regex via Powershell -match
Array of Strings that represent component name. Used to limit the components updated within the baseline. Supports regex via Powershell -match
.PARAMETER ResetiDRAC
This option will restart the iDRAC. Occurs immediately, regardless if StageForNextReboot is set
.PARAMETER ClearJobQueue
Expand Down Expand Up @@ -180,6 +180,10 @@ limitations under the License.
Update-OMEFirmware -Baseline $("AllLatest" | Get-OMEFirmwareBaseline) -ComponentFilter "iDRAC" -UpdateSchedule "StageForNextReboot" -ClearJobQueue
Update firmware on specific components in baseline on next reboot and clear job queue before update
.EXAMPLE
Update-OMEFirmware -Baseline $("AllLatest" | Get-OMEFirmwareBaseline) -ComponentFilter "BIOS", "iDRAC" -UpdateSchedule "StageForNextReboot" -ClearJobQueue
Update firmware on multiple specific components in baseline on next reboot and clear job queue before update
#>

[CmdletBinding()]
Expand All @@ -191,7 +195,7 @@ param(
[Device[]]$DeviceFilter,

[Parameter(Mandatory=$false)]
[String]$ComponentFilter,
[String[]]$ComponentFilter,

[Parameter(Mandatory)]
[FirmwareBaseline]$Baseline,
Expand Down Expand Up @@ -241,10 +245,16 @@ Process {
"Graceful" = 2;
"GracefulForced" = 3;
}

$BaselineId = $Baseline.Id
$CatalogId = $Baseline.CatalogId
$RepositoryId = $Baseline.RepositoryId

# If -DeviceFilter is $null all devices in baseline will be updated. This is a fix to ensure if a user specifies -DeviceFilter
# but it contains no devices the update will not be executed.
if ($PSBoundParameters.ContainsKey('DeviceFilter') -and $null -eq $DeviceFilter) {
throw [System.Exception]::new("Exception", "-DeviceFilter is specified but contains no devices")
}

if ($UpdateSchedule -eq "Preview") { # Only show report, do not perform any updates
return Get-OMEFirmwareCompliance -Baseline $Baseline -DeviceFilter $DeviceFilter -ComponentFilter $ComponentFilter -UpdateAction $UpdateAction -Output "Report"
} else { # Apply updates
Expand Down Expand Up @@ -282,9 +292,7 @@ Process {
}
}
Catch {
Write-Error ($_.ErrorDetails)
Write-Error ($_.Exception | Format-List -Force | Out-String)
Write-Error ($_.InvocationInfo | Format-List -Force | Out-String)
Resolve-Error $_
}
}

Expand Down
2 changes: 2 additions & 0 deletions Documentation/CommandReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@
- JobDescription (string JobDescription {get;set;})
- JobDetail (JobDetail[] JobDetail {get;set;})
- JobName (string JobName {get;set;})
- JobType (string JobType {get;set;})
- JobTypeId (int JobTypeId {get;set;})
- LastRun (System.Nullable[datetime] LastRun {get;set;})
- LastRunStatus (string LastRunStatus {get;set;})
- LastRunStatusId (int LastRunStatusId {get;set;})
Expand Down
13 changes: 10 additions & 3 deletions Documentation/Functions/Get-OMEFirmwareCompliance.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Get device firmware compliance report from OpenManage Enterprise

```
Get-OMEFirmwareCompliance [[-Baseline] <FirmwareBaseline[]>] [[-DeviceFilter] <Device[]>]
[[-ComponentFilter] <String>] [[-UpdateAction] <String[]>] [[-Output] <String>] [<CommonParameters>]
[[-ComponentFilter] <String[]>] [[-UpdateAction] <String[]>] [[-Output] <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -44,6 +44,13 @@ Filter report by device in baseline

Filter report by component in baseline

### EXAMPLE 4
```
"AllLatest" | Get-OMEFirmwareBaseline | Get-OMEFirmwareCompliance -ComponentFilter -ComponentFilter "iDRAC", "BIOS" | Format-Table
```

Filter report by multiple components in baseline

## PARAMETERS

### -Baseline
Expand Down Expand Up @@ -78,12 +85,12 @@ Accept wildcard characters: False
```

### -ComponentFilter
String to represent component name.
Array of Strings that represent component name.
Used to limit the components updated within the baseline.
Supports regex via Powershell -match

```yaml
Type: String
Type: String[]
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 2 additions & 0 deletions Documentation/Functions/New-OMEAlertPolicy.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ New-OMEAlertPolicy [-AlertPolicy] <String> [<CommonParameters>]
New-OMEAlertPolicy -AlertPolicy $NewAlertPolicy
```

See README for more examples

## PARAMETERS

### -AlertPolicy
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Functions/Set-OMETemplateNetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Aliases:

Required: False
Position: 7
Default value: None
Default value: Append
Accept pipeline input: False
Accept wildcard characters: False
```
Expand Down
13 changes: 10 additions & 3 deletions Documentation/Functions/Update-OMEFirmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Update firmware on devices in OpenManage Enterprise
## SYNTAX

```
Update-OMEFirmware [[-Name] <String>] [[-DeviceFilter] <Device[]>] [[-ComponentFilter] <String>]
Update-OMEFirmware [[-Name] <String>] [[-DeviceFilter] <Device[]>] [[-ComponentFilter] <String[]>]
[-Baseline] <FirmwareBaseline> [[-UpdateSchedule] <String>] [[-RebootType] <String>]
[[-UpdateScheduleCron] <String>] [[-UpdateAction] <String[]>] [-ResetiDRAC] [-ClearJobQueue] [-Wait]
[[-WaitTime] <Int32>] [<CommonParameters>]
Expand Down Expand Up @@ -67,6 +67,13 @@ Update-OMEFirmware -Baseline $("AllLatest" | Get-OMEFirmwareBaseline) -Component

Update firmware on specific components in baseline on next reboot and clear job queue before update

### EXAMPLE 7
```
Update-OMEFirmware -Baseline $("AllLatest" | Get-OMEFirmwareBaseline) -ComponentFilter "BIOS", "iDRAC" -UpdateSchedule "StageForNextReboot" -ClearJobQueue
```

Update firmware on multiple specific components in baseline on next reboot and clear job queue before update

## PARAMETERS

### -Name
Expand Down Expand Up @@ -101,12 +108,12 @@ Accept wildcard characters: False
```

### -ComponentFilter
String to represent component name.
Array of Strings that represent component name.
Used to limit the components updated within the baseline.
Supports regex via Powershell -match

```yaml
Type: String
Type: String[]
Parameter Sets: (All)
Aliases:

Expand Down
Loading

0 comments on commit 1e5da32

Please sign in to comment.