Skip to content

Commit

Permalink
merge devel
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSquillario committed Jan 19, 2023
2 parents 569b9b4 + d4d19cf commit d5008bc
Show file tree
Hide file tree
Showing 43 changed files with 1,349 additions and 131 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ 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.3.0]() - 2023-01-19
### Added
- Get-OMEApplianceInfo
- Invoke-OMEApplianceBackup
- Invoke-OMEResetApplication
- Remove-OMECatalog
- Remove-OMEFirmwareBaseline

### Fixed
- Column order issue in Invoke-OMEReport ([Issue #7](https://github.com/dell/OpenManage-PowerShell-Modules/issues/7))
- Issue where RebootNow wasn't actually rebooting in Update-OMEFirmware ([Issue #10](https://github.com/dell/OpenManage-PowerShell-Modules/issues/10))
- Issue where commandlets were failing when IE wasn't installed. Added -UseBasicParsing to all Invoke-WebRequest
- PowerShell v5 fix for Invoke-OMEDirectoryServiceImportGroup

## [3.2.0]() - 2023-01-12
### Added
- New-OMEDirectoryService
Expand Down
11 changes: 11 additions & 0 deletions DellOpenManage/Classes/ApplianceInfo.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class ApplianceInfo {
[String]$Name
[String]$Description
[String]$Vendor
[String]$Branding
[Version]$Version
[String]$BuildNumber
[String]$BuildDate
[String]$Guid
[String]$OperationStatus
}
19 changes: 19 additions & 0 deletions DellOpenManage/Classes/Domain.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class Domain {
[Int]$Id
[Int]$DeviceId
[String[]]$PublicAddress
[String]$Name
[String]$Description
[String]$Identifier
[Int]$DomainTypeId
[String]$DomainTypeValue
[Int]$DomainRoleTypeId
[String]$DomainRoleTypeValue
[Version]$Version
[Boolean]$Local
[String]$GroupId
[String]$GroupName
[Boolean]$BackupLead
[String[]]$Capabilities
[Int]$BackupLeadHealth
}
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 <[email protected]>
#
# Generated on: 1/12/2023
# Generated on: 1/19/2023
#

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

# Version number of this module.
ModuleVersion = '3.2.0'
ModuleVersion = '3.3.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
51 changes: 0 additions & 51 deletions DellOpenManage/Private/Get-MXDomain.ps1

This file was deleted.

19 changes: 19 additions & 0 deletions DellOpenManage/Private/New-ApplianceInfoFromJson.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using module ..\Classes\ApplianceInfo.psm1
function New-ApplianceInfoFromJson {
Param(
[PSCustomObject]$ApplianceInfo
)
$ApplianceInfoObj = [ApplianceInfo]@{
Name = $ApplianceInfo.Name
Description = $ApplianceInfo.Description
Vendor = $ApplianceInfo.Vendor
Branding = $ApplianceInfo.Branding
Version = [Version]$ApplianceInfo.Version
BuildNumber = $ApplianceInfo.BuildNumber
BuildDate = $ApplianceInfo.BuildDate
Guid = $ApplianceInfo.Guid
OperationStatus = $ApplianceInfo.OperationStatus
}
return $ApplianceInfoObj
}

25 changes: 25 additions & 0 deletions DellOpenManage/Private/New-DomainFromJson.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using module ..\Classes\Domain.psm1
function New-DomainFromJson {
Param(
[PSCustomObject]$Domain
)
return [Domain]@{
Id = $Domain.Id
DeviceId = $Domain.DeviceId
PublicAddress = $Domain.PublicAddress
Name = $Domain.Name
Description = $Domain.Description
Identifier = $Domain.Identifier
DomainTypeId = $Domain.DomainTypeId
DomainTypeValue = $Domain.DomainTypeValue
DomainRoleTypeId = $Domain.DomainRoleTypeId
DomainRoleTypeValue = $Domain.DomainRoleTypeValue
Version = $Domain.Version
Local = $Domain.Local
GroupId = $Domain.GroupId
GroupName = $Domain.GroupName
BackupLead = $Domain.BackupLead
Capabilities = $Domain.Capabilities
BackupLeadHealth = $Domain.BackupLeadHealth
}
}
4 changes: 2 additions & 2 deletions DellOpenManage/Public/OME/Connect-OMEServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ param(
$SessionUrl = "https://$($OMEHost)/api/SessionService/Sessions"
$UserDetails = @{"UserName"=$OMEUserName;"Password"=$OMEPassword;"SessionType"="API"} | ConvertTo-Json

$SessResponse = Invoke-WebRequest -Uri $SessionUrl -Method Post -Body $UserDetails -ContentType $Type
$SessResponse = Invoke-WebRequest -Uri $SessionUrl -UseBasicParsing -Method Post -Body $UserDetails -ContentType $Type
if ($SessResponse.StatusCode -eq 200 -or $SessResponse.StatusCode -eq 201) {
$SessResponseData = $SessResponse.Content | ConvertFrom-Json

Expand All @@ -89,7 +89,7 @@ param(

# Get Appliance Version
$AppInfoUrl = "https://$($OMEHost)/api/ApplicationService/Info"
$AppInfoResponse = Invoke-WebRequest -Uri $AppInfoUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $Type
$AppInfoResponse = Invoke-WebRequest -Uri $AppInfoUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $Type
$AppVersion = [System.Version]"1.0.0"
if ($AppInfoResponse.StatusCode -eq 200 -or $AppInfoResponse.StatusCode -eq 201) {
$AppInfoResponseData = $AppInfoResponse.Content | ConvertFrom-Json
Expand Down
6 changes: 3 additions & 3 deletions DellOpenManage/Public/OME/Copy-OMETemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Get-TemplateVlan($BaseUri, $ContentType, $Headers, $Template) {
$TemplateVlanPayload = $TemplateVlanPayload | ConvertFrom-Json
$NETWORK_HIERARCHY_VIEW = 4 # For Network hierarchy View in a Template
$TemplateVlanUrl = $BaseUri + "/api/TemplateService/Templates($($Template.Id))/Views($($NETWORK_HIERARCHY_VIEW))/AttributeViewDetails"
$TemplateVlanResponse = Invoke-WebRequest -Uri $TemplateVlanUrl -Method Get -ContentType $ContentType -Headers $Headers
$TemplateVlanResponse = Invoke-WebRequest -Uri $TemplateVlanUrl -UseBasicParsing -Method Get -ContentType $ContentType -Headers $Headers
if ($TemplateVlanResponse.StatusCode -eq 200) {
$TemplateVlans = $TemplateVlanResponse.Content | ConvertFrom-Json
$NICGroups = @()
Expand Down Expand Up @@ -187,7 +187,7 @@ Process {
Write-Verbose $TemplatePayload
$NewTemplateId = $null
Write-Verbose "Clone Template..."
$TemplateResponse = Invoke-WebRequest -Uri $TemplateUrl -Method Post -Body $TemplatePayload -ContentType $ContentType -Headers $Headers
$TemplateResponse = Invoke-WebRequest -Uri $TemplateUrl -UseBasicParsing -Method Post -Body $TemplatePayload -ContentType $ContentType -Headers $Headers
if ($TemplateResponse.StatusCode -eq 200) {
$NewTemplateId = [int]$TemplateResponse.Content
Write-Verbose "Clone Template Success - Id $($NewTemplateId)"
Expand All @@ -202,7 +202,7 @@ Process {
$CloneTemplateVlanPayload = $($CloneTemplateVlanPayload | ConvertTo-Json -Depth 6)
Write-Verbose $CloneTemplateVlanPayload
$TemplateUpdateNetworkUrl = $BaseUri + "/api/TemplateService/Actions/TemplateService.UpdateNetworkConfig"
$TemplateVlanResponse = Invoke-WebRequest -Uri $TemplateUpdateNetworkUrl -Method Post -Body $CloneTemplateVlanPayload -ContentType $ContentType -Headers $Headers
$TemplateVlanResponse = Invoke-WebRequest -Uri $TemplateUpdateNetworkUrl -UseBasicParsing -Method Post -Body $CloneTemplateVlanPayload -ContentType $ContentType -Headers $Headers
if ($TemplateVlanResponse.StatusCode -eq 200) {
Write-Verbose "Clone Template Success - VLANs"
}
Expand Down
2 changes: 1 addition & 1 deletion DellOpenManage/Public/OME/Disconnect-OMEServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ limitations under the License.
$Headers."X-Auth-Token" = $SessionAuth.Token
$SessionUrl = "https://$($SessionAuth.Host)/api/SessionService/Sessions('$($SessionAuth.Id)')"
$Type = "application/json"
$SessResponse = Invoke-WebRequest -Uri $SessionUrl -Method Delete -Headers $Headers -ContentType $Type
$SessResponse = Invoke-WebRequest -Uri $SessionUrl -UseBasicParsing -Method Delete -Headers $Headers -ContentType $Type
if ($SessResponse.StatusCode -eq 204) {
$Script:SessionAuth = [SessionAuth]::new()
}
Expand Down
2 changes: 1 addition & 1 deletion DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Process {
$Payload = $Payload | ConvertTo-Json -Depth 6
$DiscoveryId = $Discovery.Id
$DiscoverUrl = $BaseUri + "/api/DiscoveryConfigService/DiscoveryConfigGroups(" + $DiscoveryId + ")"
$DiscoverResponse = Invoke-WebRequest -Uri $DiscoverUrl -Method Put -Body $Payload -Headers $Headers -ContentType $Type
$DiscoverResponse = Invoke-WebRequest -Uri $DiscoverUrl -UseBasicParsing -Method Put -Body $Payload -Headers $Headers -ContentType $Type
if ($DiscoverResponse.StatusCode -eq 200) {
Write-Verbose "Discovering devices...."
Start-Sleep -Seconds 10
Expand Down
4 changes: 2 additions & 2 deletions DellOpenManage/Public/OME/Edit-OMESupportAssistGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Process {
$GroupDevicePayload = $GroupDevicePayload | ConvertTo-Json -Depth 6
Write-Verbose $GroupDevicePayload
if ($DeviceIds.Length -gt 0) {
$GroupDeviceResponse = Invoke-WebRequest -Uri $GroupDeviceURL -Headers $Headers -ContentType $ContentType -Method POST -Body $GroupDevicePayload
$GroupDeviceResponse = Invoke-WebRequest -Uri $GroupDeviceURL -UseBasicParsing -Headers $Headers -ContentType $ContentType -Method POST -Body $GroupDevicePayload
Write-Verbose "Updating group devices..."
if ($GroupDeviceResponse.StatusCode -eq 200 -or $GroupDeviceResponse.StatusCode -eq 202) {
Write-Verbose "Group device update successful..."
Expand Down Expand Up @@ -163,7 +163,7 @@ Process {
$GroupPayload = $GroupPayload | ConvertTo-Json -Depth 6
Write-Verbose $GroupPayload

$GroupResponse = Invoke-WebRequest -Uri $GroupURL -Headers $Headers -ContentType $ContentType -Method POST -Body $GroupPayload
$GroupResponse = Invoke-WebRequest -Uri $GroupURL -UseBasicParsing -Headers $Headers -ContentType $ContentType -Method POST -Body $GroupPayload
Write-Verbose "Updating group..."
if ($GroupResponse.StatusCode -eq 200 -or $GroupResponse.StatusCode -eq 202) {
Write-Verbose "Group update successful!"
Expand Down
68 changes: 68 additions & 0 deletions DellOpenManage/Public/OME/Get-OMEApplianceInfo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

function Get-OMEApplianceInfo {
<#
Copyright (c) 2021 Dell EMC Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>

<#
.SYNOPSIS
Get appliance info
.DESCRIPTION
This script uses the OME REST API.
Note that the credentials entered are not stored to disk.
.PARAMETER Name
String containing name to search by
.EXAMPLE
Get-OMEApplianceInfo | Format-Table
List all account roles
.EXAMPLE
Get-OMEApplianceInfo | Format-Table
Get appliance info
#>

Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
$Headers = @{}
$ContentType = "application/json"
$Headers."X-Auth-Token" = $SessionAuth.Token

$ApplianceInfoUrl = $BaseUri + "/api/ApplicationService/Info"

Write-Verbose $ApplianceInfoUrl
$ApplianceInfoResponse = Invoke-WebRequest -Uri $ApplianceInfoUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $ContentType
if ($ApplianceInfoResponse.StatusCode -in 200, 201) {
$ApplianceInfoData = $ApplianceInfoResponse.Content | ConvertFrom-Json
$ApplianceInfo = New-ApplianceInfoFromJson -ApplianceInfo $ApplianceInfoData
return $ApplianceInfo
}
}
Catch {
Resolve-Error $_
}

}

End {}

}
6 changes: 3 additions & 3 deletions DellOpenManage/Public/OME/Get-OMEIdentityPoolUsage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Process {

# Get Identity Pool Usage Sets
$IdentityPoolUsageSetUrl = $BaseUri + "/api/IdentityPoolService/IdentityPools($($Id))/UsageIdentitySets"
$IdentityPoolUsageSetResp = Invoke-WebRequest -Uri $IdentityPoolUsageSetUrl -Method Get -Headers $Headers -ContentType $Type
$IdentityPoolUsageSetResp = Invoke-WebRequest -Uri $IdentityPoolUsageSetUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $Type
if ($IdentityPoolUsageSetResp.StatusCode -eq 200) {
$IdentityPoolUsageSetRespData = $IdentityPoolUsageSetResp.Content | ConvertFrom-Json
$IdentityPoolUsageSetRespData = $IdentityPoolUsageSetRespData.'value'
Expand All @@ -77,7 +77,7 @@ Process {
$IdentitySetName = $IdentitySet.Name

$IdentityPoolUsageDetailUrl = $BaseUri + "/api/IdentityPoolService/IdentityPools($($Id))/UsageIdentitySets($($IdentitySetId))/Details"
$IdentityPoolUsageDetailResp = Invoke-WebRequest -Uri $IdentityPoolUsageDetailUrl -Method Get -Headers $Headers -ContentType $Type
$IdentityPoolUsageDetailResp = Invoke-WebRequest -Uri $IdentityPoolUsageDetailUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $Type
if ($IdentityPoolUsageDetailResp.StatusCode -eq 200) {
$IdentityPoolUsageDetailData = $IdentityPoolUsageDetailResp.Content | ConvertFrom-Json
# Loop through Details appending to object array
Expand All @@ -99,7 +99,7 @@ Process {
}
# Loop through pages until end
while ($NextLinkUrl) {
$IdentityPoolUsageDetailNextLinkResp = Invoke-WebRequest -Uri $NextLinkUrl -Method Get -Headers $Headers -ContentType $Type
$IdentityPoolUsageDetailNextLinkResp = Invoke-WebRequest -Uri $NextLinkUrl -UseBasicParsing -Method Get -Headers $Headers -ContentType $Type
if ($IdentityPoolUsageDetailNextLinkResp.StatusCode -eq 200) {
$IdentityPoolUsageDetailNextLinkData = $IdentityPoolUsageDetailNextLinkResp.Content | ConvertFrom-Json
# Loop through Details appending to object array
Expand Down
33 changes: 32 additions & 1 deletion DellOpenManage/Public/OME/Get-OMEMXDomain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,38 @@ Process {
$Headers = @{}
$Headers."X-Auth-Token" = $SessionAuth.Token

return Get-MXDomain -BaseUri $BaseUri -Headers $Headers -RoleType $RoleType
$Members = @()
$URL = $BaseUri + "/api/ManagementDomainService/Domains"
$ContentType = "application/json"
$Response = Invoke-WebRequest -Uri $URL -UseBasicParsing -Headers $Headers -ContentType $ContentType -Method GET
if ($Response.StatusCode -eq 200) {
$DomainResp = $Response.Content | ConvertFrom-Json
if ($DomainResp."value".Length -gt 0) {
$MemberDevices = $DomainResp."value"
If ($RoleType -eq "ALL") {
foreach ($Member in $MemberDevices) {
$Members += New-DomainFromJson -Domain $Member
}
} else {
foreach ($Member in $MemberDevices) {
if ($RoleType -eq "LEAD" -and $Member.'DomainRoleTypeValue' -eq "LEAD") {
$Members += New-DomainFromJson -Domain $Member
} elseif ($RoleType -eq "MEMBER" -and $Member.'DomainRoleTypeValue' -eq "MEMBER") {
$Members += New-DomainFromJson -Domain $Member
} elseif ($RoleType -eq "BACKUPLEAD" -and $Member.'BackupLead' -eq $true) {
$Members += New-DomainFromJson -Domain $Member
}
}
}
}
else {
Write-Warning "No domains discovered"
}
return $Members # Workaround for single element array
}
else {
Write-Warning "Failed to get domains and status code returned is $($Response.StatusCode)"
}
}
Catch {
Resolve-Error $_
Expand Down
Loading

0 comments on commit d5008bc

Please sign in to comment.