Skip to content

Commit

Permalink
Release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSquillario committed Mar 16, 2022
1 parent 1b51798 commit 29f618d
Show file tree
Hide file tree
Showing 70 changed files with 309 additions and 483 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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.0.0]() - 2022-03-16
### Changed
- Changed the way commandlets exit when authentication fails. Previously all commandlets would stop script execution if not authenticated which isn't a PowerShell best practice. If you would like to maintain this behavior use the -ErrorAction Stop on the Connect-OMEServer or any commandlet. https://devblogs.microsoft.com/scripting/handling-errors-the-powershell-way/#erroraction-parameter

### Fixed
- Disconnect-OMEServer checks if auth token exists before trying to remove auth session

## [2.3.8]() - 2022-03-11
### Added
- Examples/DiscoverAddToStaticGroup.ps1 will run a Discovery, create a static group and add the devices to the group
Expand Down
8 changes: 4 additions & 4 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: 3/11/2022
# Generated on: 3/16/2022
#

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

# Version number of this module.
ModuleVersion = '2.3.8'
ModuleVersion = '3.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -101,7 +101,7 @@ PrivateData = @{
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''
ProjectUri = 'https://github.com/dell/OpenManage-PowerShell-Modules'

# A URL to an icon representing this module.
# IconUri = ''
Expand All @@ -120,7 +120,7 @@ PrivateData = @{

} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
Expand Down
8 changes: 8 additions & 0 deletions DellOpenManage/Private/Confirm-IsAuthenticated.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Confirm-IsAuthenticated {
if (!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
return $false
} else {
return $true
}
}
11 changes: 4 additions & 7 deletions DellOpenManage/Private/Wait-OnConfigurationBaseline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ param(
[int]$WaitTime = 3600
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Set-CertPolicy
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
$Type = "application/json"
$Headers = @{}
Expand Down
11 changes: 4 additions & 7 deletions DellOpenManage/Private/Wait-OnFirmwareBaseline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ param(
[int]$WaitTime = 3600
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Set-CertPolicy
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
$Type = "application/json"
$Headers = @{}
Expand Down
11 changes: 4 additions & 7 deletions DellOpenManage/Private/Wait-OnJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ param(
[int]$WaitTime = 3600
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Set-CertPolicy
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$Headers = @{}

$Headers."X-Auth-Token" = $SessionAuth.Token
Expand Down
11 changes: 4 additions & 7 deletions DellOpenManage/Private/Wait-OnTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,12 @@ param(
[int]$WaitTime = 3600
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Set-CertPolicy
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
$Type = "application/json"
$Headers = @{}
Expand Down
97 changes: 46 additions & 51 deletions DellOpenManage/Public/OME/Connect-OMEServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,62 +55,57 @@ param(
[Switch]$IgnoreCertificateWarning
)

Try {
if ($IgnoreCertificateWarning) { Set-CertPolicy }
$Type = "application/json"
# Allow for use of Environment Variables
if ($Name) {
$OMEHost = $Name
} else {
$OMEHost = $env:OMEHost
}
if ($Credentials) {
$OMEUserName = $Credentials.username
$OMEPassword = $Credentials.GetNetworkCredential().password
} else {
$OMEUserName = $env:OMEUserName
$OMEPassword = $env:OMEPassword
}
if ($IgnoreCertificateWarning) { Set-CertPolicy }
$Type = "application/json"
# Allow for use of Environment Variables
if ($Name) {
$OMEHost = $Name
} else {
$OMEHost = $env:OMEHost
}
if ($Credentials) {
$OMEUserName = $Credentials.username
$OMEPassword = $Credentials.GetNetworkCredential().password
} else {
$OMEUserName = $env:OMEUserName
$OMEPassword = $env:OMEPassword
}

# Input Validation
if ($null -eq $OMEHost) { throw [System.ArgumentNullException] "OMEHost" }
if ($null -eq $OMEUserName) { throw [System.ArgumentNullException] "OMEUserName" }
if ($null -eq $OMEPassword) { throw [System.ArgumentNullException] "OMEPassword" }
# Input Validation
if ($null -eq $OMEHost) { throw [System.ArgumentNullException] "OMEHost" }
if ($null -eq $OMEUserName) { throw [System.ArgumentNullException] "OMEUserName" }
if ($null -eq $OMEPassword) { throw [System.ArgumentNullException] "OMEPassword" }

$SessionUrl = "https://$($OMEHost)/api/SessionService/Sessions"
$UserDetails = @{"UserName"=$OMEUserName;"Password"=$OMEPassword;"SessionType"="API"} | ConvertTo-Json
$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
if ($SessResponse.StatusCode -eq 200 -or $SessResponse.StatusCode -eq 201) {
$SessResponseData = $SessResponse.Content | ConvertFrom-Json
$Token = [String]$SessResponse.Headers["X-Auth-Token"]
$Headers = @{}
$Headers."X-Auth-Token" = $Token
$SessResponse = Invoke-WebRequest -Uri $SessionUrl -Method Post -Body $UserDetails -ContentType $Type
if ($SessResponse.StatusCode -eq 200 -or $SessResponse.StatusCode -eq 201) {
$SessResponseData = $SessResponse.Content | ConvertFrom-Json

$Token = [String]$SessResponse.Headers["X-Auth-Token"]
$Headers = @{}
$Headers."X-Auth-Token" = $Token

# Get Appliance Version
$AppInfoUrl = "https://$($OMEHost)/api/ApplicationService/Info"
$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
Write-Verbose $($AppInfoResponseData)
$AppVersion = [System.Version]$AppInfoResponseData.Version
}
# Get Appliance Version
$AppInfoUrl = "https://$($OMEHost)/api/ApplicationService/Info"
$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
Write-Verbose $($AppInfoResponseData)
$AppVersion = [System.Version]$AppInfoResponseData.Version
}

$Script:SessionAuth = [SessionAuth]@{
Host = $OMEHost
Token = $Token
Id = $SessResponseData.Id
Version = $AppVersion
IgnoreCertificateWarning = $IgnoreCertificateWarning
}

} else {
Write-Error "Unable to create a session with appliance $($OMEHost)"
$Script:SessionAuth = [SessionAuth]@{
Host = $OMEHost
Token = $Token
Id = $SessResponseData.Id
Version = $AppVersion
IgnoreCertificateWarning = $IgnoreCertificateWarning
}
}
Catch {
Resolve-Error $_
} else {
Write-Error "Unable to create a session with appliance $($OMEHost)"
}
}
9 changes: 3 additions & 6 deletions DellOpenManage/Public/OME/Copy-OMETemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,11 @@ param(
[Switch]$All
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
4 changes: 3 additions & 1 deletion DellOpenManage/Public/OME/Disconnect-OMEServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#>
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
if ($SessionAuth.Token){
$Headers = @{}
$Headers."X-Auth-Token" = $SessionAuth.Token
$SessionUrl = "https://$($SessionAuth.Host)/api/SessionService/Sessions('$($SessionAuth.Id)')"
Expand All @@ -36,7 +37,8 @@ limitations under the License.
if ($SessResponse.StatusCode -eq 204) {
$Script:SessionAuth = [SessionAuth]::new()
}
}
}
}
Catch {
Write-Error ($_.ErrorDetails)
Write-Error ($_.Exception | Format-List -Force | Out-String)
Expand Down
9 changes: 3 additions & 6 deletions DellOpenManage/Public/OME/Edit-OMEDiscovery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,11 @@ param(
[int]$WaitTime = 3600
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
9 changes: 3 additions & 6 deletions DellOpenManage/Public/OME/Edit-OMEGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,11 @@ param(
[String] $Mode = "Append"
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
9 changes: 3 additions & 6 deletions DellOpenManage/Public/OME/Edit-OMESecurityBanner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ param(
[String]$Banner
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
10 changes: 3 additions & 7 deletions DellOpenManage/Public/OME/Edit-OMESupportAssistGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,16 @@ param(
[String] $Mode = "Append"
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
# Add version check for SupportAssist commandlets
if ($SessionAuth.Version -lt [System.Version]"3.5.0") {
Write-Error "SupportAssist API not supported in version $($SessionAuth.Version) of OpenManage Enterprise"
Break
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
6 changes: 2 additions & 4 deletions DellOpenManage/Public/OME/Get-OMEAlert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,8 @@ param(
[string] $AlertsByGroupDescription
)

if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Return
if (!$(Confirm-IsAuthenticated)){
Return
}

function Get-Data {
Expand Down
9 changes: 3 additions & 6 deletions DellOpenManage/Public/OME/Get-OMEAlertDefinition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ limitations under the License.
param(
)

Begin {
if(!$SessionAuth.Token){
Write-Error "Please use Connect-OMEServer first"
Break
Begin {}
Process {
if (!$(Confirm-IsAuthenticated)){
Return
}
}
Process {
Try {
if ($SessionAuth.IgnoreCertificateWarning) { Set-CertPolicy }
$BaseUri = "https://$($SessionAuth.Host)"
Expand Down
Loading

0 comments on commit 29f618d

Please sign in to comment.