diff --git a/CHANGELOG.md b/CHANGELOG.md index 93baa2b..e4b0c86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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.1]() - 2023-07-11 +### Fixed +- Issue with Get-OMEJob not listing all execution histories when using the -Detail parameter + ## [3.6.0]() - 2023-04-26 ### Added - New-OMEAlertPolicy diff --git a/DellOpenManage/Classes/Job.psm1 b/DellOpenManage/Classes/Job.psm1 index c2123ea..6cb235c 100644 --- a/DellOpenManage/Classes/Job.psm1 +++ b/DellOpenManage/Classes/Job.psm1 @@ -18,6 +18,8 @@ Class Job { [Boolean]$UserGenerated [Int]$LastRunStatusId [String]$LastRunStatus + [Int]$JobTypeId + [String]$JobType [PSCustomObject[]]$Targets [JobDetail[]]$JobDetail } \ No newline at end of file diff --git a/DellOpenManage/DellOpenManage.psd1 b/DellOpenManage/DellOpenManage.psd1 index 2a32151..873ef88 100644 --- a/DellOpenManage/DellOpenManage.psd1 +++ b/DellOpenManage/DellOpenManage.psd1 @@ -3,7 +3,7 @@ # # Generated by: Trevor Squillario # -# Generated on: 5/8/2023 +# Generated on: 7/11/2023 # @{ @@ -12,7 +12,7 @@ RootModule = 'DellOpenManage.psm1' # Version number of this module. -ModuleVersion = '3.6.0' +ModuleVersion = '3.6.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/DellOpenManage/Private/New-JobFromJson.ps1 b/DellOpenManage/Private/New-JobFromJson.ps1 index 694efb2..e79a17d 100644 --- a/DellOpenManage/Private/New-JobFromJson.ps1 +++ b/DellOpenManage/Private/New-JobFromJson.ps1 @@ -23,6 +23,8 @@ function New-JobFromJson { UserGenerated = $Job.UserGenerated LastRunStatusId = $Job.LastRunStatus.Id LastRunStatus = $Job.LastRunStatus.Name + JobTypeId = $Job.JobType.Id + JobType = $Job.JobType.Name Targets = $Job.Targets } if ($JobDetails) { diff --git a/DellOpenManage/Public/OME/Get-OMEJob.ps1 b/DellOpenManage/Public/OME/Get-OMEJob.ps1 index bfe14c0..45c4263 100644 --- a/DellOpenManage/Public/OME/Get-OMEJob.ps1 +++ b/DellOpenManage/Public/OME/Get-OMEJob.ps1 @@ -4,19 +4,21 @@ $HistoryDetails = @() if ($ExecResp.StatusCode -eq 200) { $ExecRespInfo = $ExecResp.Content | ConvertFrom-Json - $HistoryId = $ExecRespInfo.value[0].Id - $ExecHistoryUrl = "$($JobExecUrl)($($HistoryId))/ExecutionHistoryDetails" - $HistoryResp = Invoke-WebRequest -UseBasicParsing -Uri $ExecHistoryUrl -Method Get -Headers $Headers -ContentType $Type - if ($HistoryResp.StatusCode -eq 200) { - $HistoryData = $HistoryResp.Content | ConvertFrom-Json - foreach ($HistoryDetail in $HistoryData.value) { - $HistoryDetails += $HistoryDetail + foreach ($ExecRespValue in $ExecRespInfo.value) { + $HistoryId = $ExecRespValue.Id + $ExecHistoryUrl = "$($JobExecUrl)($($HistoryId))/ExecutionHistoryDetails" + $HistoryResp = Invoke-WebRequest -UseBasicParsing -Uri $ExecHistoryUrl -Method Get -Headers $Headers -ContentType $Type + if ($HistoryResp.StatusCode -eq 200) { + $HistoryData = $HistoryResp.Content | ConvertFrom-Json + foreach ($HistoryDetail in $HistoryData.value) { + $HistoryDetails += $HistoryDetail + } + } + else { + Write-Warning "Unable to get job execution history details" } - return $HistoryDetails - } - else { - Write-Warning "Unable to get job execution history details" } + return $HistoryDetails } else { Write-Warning "Unable to get job execution history info" diff --git a/Examples/AddToStaticGroupFromTextFile.ps1 b/Examples/AddToStaticGroupFromTextFile.ps1 new file mode 100755 index 0000000..ad9073a --- /dev/null +++ b/Examples/AddToStaticGroupFromTextFile.ps1 @@ -0,0 +1,11 @@ +$AllDevices = Get-OMEDevice # Get all devices and store in variable +$HostIPs = Get-Content "C:\Temp\hosts.txt" # Get context of text file +$NewDevices = @() # Variable to hold devices found by IP +foreach ($ip in $HostIPs) { # Loop through text file contents + $IPMatch = $AllDevices | Where-Object {$_.NetworkAddress -EQ $ip} # Look for device with matching IP + if ($IPMatch.Count -gt 0) { # Match found + $DeviceMatch = $IPMatch.Identifier | Get-OMEDevice -FilterBy "ServiceTag" # Get Device object by Service Tag + $NewDevices += $DeviceMatch # Add Device to array + } +} +Get-OMEGroup "Test Group 01" | Edit-OMEGroup -Devices $NewDevices # Edit group and add devices from the array we created \ No newline at end of file diff --git a/README.md b/README.md index 0b540cc..5182245 100644 --- a/README.md +++ b/README.md @@ -441,6 +441,15 @@ Get job by state ``` "Enabled" | Get-OMEJob -FilterBy "State" | Format-Table ``` +Export job details to CSV by Id +``` +10085 | Get-OMEJob -FilterBy "Id" -Detail | Select-Object @{Name='JobId'; Expression='Id'}, JobName, JobTypeId, JobType, JobDescription, LastRun -ExpandProperty JobDetail + | Export-Csv -Path "C:\Temp\OMEJobDetail.csv" -NoTypeInformation +``` +Get jobs filter by multiple properties +``` +2070 | Get-OMEJob -FilterBy "LastRunStatus" | Where-Object JobTypeId -EQ 101 +``` Run job ``` 28991 | Invoke-OMEJobRun -Wait -Verbose