Skip to content

Commit 3e12ab3

Browse files
committed
7.9.4 release
FedRamp fix
1 parent a4a7392 commit 3e12ab3

6 files changed

Lines changed: 196 additions & 42 deletions

File tree

Public/Connect-LMAccount.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ function Connect-LMAccount {
116116
$Script:InformationPreference = 'Continue'
117117
}
118118

119+
$CachedGovCloud = $null
120+
119121
if ($UseCachedCredential -or $CachedAccountName) {
120122

121123
try {
@@ -169,6 +171,7 @@ function Connect-LMAccount {
169171
$AccountName = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Portal"]
170172
$AccessId = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Id"]
171173
$Type = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Type"]
174+
$CachedGovCloud = $CachedAccountSecrets[$CachedAccountIndex].Metadata["GovCloud"]
172175
if (($Type -eq "LMv1") -or ($null -eq $Type)) {
173176
[SecureString]$AccessKey = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString
174177
}
@@ -199,7 +202,8 @@ function Connect-LMAccount {
199202
$CachedAccountName = $CachedAccountSecrets[$StoredCredentialIndex].Name
200203
$AccessId = $CachedAccountSecrets[$StoredCredentialIndex].Metadata["Id"]
201204
$Type = $CachedAccountSecrets[$StoredCredentialIndex].Metadata["Type"]
202-
if ($Type -eq "LMv1") {
205+
$CachedGovCloud = $CachedAccountSecrets[$StoredCredentialIndex].Metadata["GovCloud"]
206+
if (($Type -eq "LMv1") -or ($null -eq $Type)) {
203207
[SecureString]$AccessKey = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString
204208
}
205209
elseif ($Type -eq "Bearer") {
@@ -248,6 +252,7 @@ function Connect-LMAccount {
248252
if (!$Type) {
249253
$Type = "LMv1"
250254
}
255+
$UseGovCloud = $GovCloud.IsPresent -or ($CachedGovCloud -eq 'True')
251256
$Version = Get-LMPortalVersion -ErrorAction SilentlyContinue
252257

253258
#Create Credential Object for reuse in other functions
@@ -259,7 +264,7 @@ function Connect-LMAccount {
259264
Valid = $true
260265
Type = $Type
261266
Logging = !$DisableConsoleLogging.IsPresent
262-
GovCloud = $GovCloud.IsPresent
267+
GovCloud = $UseGovCloud
263268
Version = $Version
264269
}
265270

Public/Get-LMCachedAccount.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This function requires access to the Logic.Monitor vault where credentials are s
2323
None. You cannot pipe objects to this command.
2424
2525
.OUTPUTS
26-
Returns an array of custom objects containing cached account information including CachedAccountName, Portal, Id, Modified date, and Type.
26+
Returns an array of custom objects containing cached account information including CachedAccountName, Portal, Id, Modified date, Type, and GovCloud.
2727
2828
.LINK
2929
Get-SecretInfo
@@ -49,6 +49,7 @@ function Get-LMCachedAccount {
4949
Id = if (!$Secret.Metadata["Id"]) { "N/A" }else { $Secret.Metadata["Id"] }
5050
Modified = $Secret.Metadata["Modified"]
5151
Type = if (!$Secret.Metadata["Type"]) { "LMv1" }else { $Secret.Metadata["Type"] }
52+
GovCloud = $Secret.Metadata["GovCloud"] -eq 'True'
5253
}
5354
}
5455
return $CachedAccounts

Public/New-LMCachedAccount.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ The name to use for the cached account. Defaults to AccountName.
2323
.PARAMETER OverwriteExisting
2424
Whether to overwrite an existing cached account. Defaults to false.
2525
26+
.PARAMETER GovCloud
27+
Connect using the LM GovCloud (FedRAMP) portal when this cached account is used.
28+
2629
.EXAMPLE
2730
#Cache LMv1 credentials
2831
New-LMCachedAccount -AccessId "id123" -AccessKey "key456" -AccountName "company"
@@ -31,6 +34,10 @@ New-LMCachedAccount -AccessId "id123" -AccessKey "key456" -AccountName "company"
3134
#Cache Bearer token
3235
New-LMCachedAccount -BearerToken "token123" -AccountName "company" -CachedAccountName "prod"
3336
37+
.EXAMPLE
38+
#Cache FedRAMP GovCloud credentials
39+
New-LMCachedAccount -AccessId "id123" -AccessKey "key456" -AccountName "agency" -GovCloud
40+
3441
.NOTES
3542
This command creates a secure vault to store credentials if one doesn't exist.
3643
@@ -60,7 +67,9 @@ function New-LMCachedAccount {
6067

6168
[String]$CachedAccountName = $AccountName,
6269

63-
[Boolean]$OverwriteExisting = $false
70+
[Boolean]$OverwriteExisting = $false,
71+
72+
[Switch]$GovCloud
6473
)
6574

6675
try {
@@ -84,6 +93,7 @@ function New-LMCachedAccount {
8493
Id = "$($BearerToken.Substring(0,20))****"
8594
Modified = [DateTime]$CurrentDate
8695
Type = "Bearer"
96+
GovCloud = [String]$GovCloud.IsPresent
8797
}
8898
}
8999
else {
@@ -93,6 +103,7 @@ function New-LMCachedAccount {
93103
Id = [String]$AccessId
94104
Modified = [DateTime]$CurrentDate
95105
Type = "LMv1"
106+
GovCloud = [String]$GovCloud.IsPresent
96107
}
97108
}
98109
$Message = "CachedAccountName: $CachedAccountName | Portal: $AccountName"

README.md

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,50 +72,24 @@ Connect-LMAccount -UseCachedCredential
7272
```
7373

7474
# Change List
75-
## 7.9.3
75+
## 7.9.4
7676
### Bug Fixes
77-
- **Set-LMWebsite**: Fixed an issue where `-WebsiteSteps` was omitted from the API request payload, so multi-step web check updates appeared to succeed but did not apply the supplied steps.
78-
- **Set-LMOpsNote**: Fixed an issue where scope updates (`-DeviceIds`, `-WebsiteIds`, `-DeviceGroupIds`) were not included in the request payload.
79-
- **Set-LMRole**: Fixed an issue where permission updates were omitted from the request payload when changing role privileges.
80-
- **Set-LMRecipientGroup**: Fixed `-Recipients` to accept an array of recipient objects instead of only binding a single recipient.
77+
- **Connect-LMAccount / New-LMCachedAccount / Get-LMCachedAccount**: Fixed an issue where cached credentials did not work for FedRAMP (GovCloud) portals on `lmgov.us`. `New-LMCachedAccount` now supports `-GovCloud` to persist the portal type in cached metadata, `Connect-LMAccount` restores that setting when connecting via `-UseCachedCredential` or `-CachedAccountName`, and `Get-LMCachedAccount` now includes a `GovCloud` property. Existing FedRAMP cached entries must be re-cached with `-GovCloud -OverwriteExisting $true`.
8178

82-
## 7.9.2
83-
### Bug Fixes
84-
- **SDT timezone compatibility with PowerShell 5.1**: Fixed an issue introduced in v7.9.1 where SDT commands would fail on PowerShell 5.1 with `Invalid timezone` errors due to .NET Framework not supporting IANA timezone IDs (e.g. `America/New_York`) directly.
85-
- **Cross-platform timezone support**: SDT commands now accept both IANA timezone IDs (e.g. `America/New_York`) and Windows standard timezone names (e.g. `Eastern Standard Time`). The module automatically resolves the input to the correct format for the API regardless of PowerShell version or operating system.
86-
87-
## 7.9.1
88-
89-
### Bug Fixes & Changes
90-
- **SDT timezone consistency**: Added timezone-aware behavior across `New-LMDeviceSDT`, `New-LMDeviceGroupSDT`, `New-LMDeviceDatasourceSDT`, and `New-LMDeviceDatasourceInstanceSDT` so schedules are no longer interpreted based on the machine running the script.
91-
- **Portal timezone default for SDTs**: If `-Timezone` is omitted, SDT commands now resolve and use the portal timezone by default.
92-
- **Timezone validation improvements**: Replaced legacy commented timezone lists with active validation for timezone IDs and clearer error messages for invalid values.
93-
- **Set-LMSDT update alignment**: Added timezone handling and validation improvements for one-time SDT updates in `Set-LMSDT`.
94-
95-
### Major Changes in v7:
96-
- **API Headers**: Updated all API request headers to use a custom User-Agent (Logic.Monitor-PowerShell-Module/Version) for usage reporting on versions deployed.
97-
98-
### Documentation Overhaul
99-
We're excited to announce our new comprehensive documentation site at [https://logicmonitor.github.io/lm-powershell-module-docs/](https://logicmonitor.github.io/lm-powershell-module-docs/). The site includes:
100-
- Detailed command reference information
101-
- Code examples and snippets
102-
- Best practices guides
79+
### Migration Example (FedRAMP / GovCloud cached credentials)
80+
```powershell
81+
# Review existing cached accounts and confirm GovCloud is not set
82+
Get-LMCachedAccount
10383
104-
### New Filter Wizard
105-
Introducing the Filter Wizard, a new interactive tool to help build complex filters:
106-
- Visual filter construction
107-
- Support for all filter operators
108-
- Real-time filter preview
109-
- Available through `Build-LMFilter` or `-FilterWizard` parameter
84+
# Re-cache FedRAMP credentials with GovCloud enabled (overwrite the existing entry)
85+
New-LMCachedAccount -AccessId "lm_access_id" -AccessKey "lm_access_key" -AccountName "agency" -CachedAccountName "agency-fedramp" -GovCloud -OverwriteExisting $true
11086
111-
```powershell
112-
# Use the standalone filter builder
113-
Build-LMFilter
87+
# Verify GovCloud is now stored in metadata
88+
Get-LMCachedAccount -CachedAccountName "agency-fedramp"
11489
115-
# Use built-in filter wizard parameter
116-
Get-LMDeviceGroup -FilterWizard
90+
# Connect using the updated cached credential
91+
Connect-LMAccount -CachedAccountName "agency-fedramp"
11792
```
118-
![Filter Wizard Example](https://logicmonitor.github.io/lm-powershell-module-docs/_astro/LMFilter.4g625cq9_1boMAv.webp)
11993

12094
[Previous Release Notes](RELEASENOTES.md)
12195

RELEASENOTES.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
# Previous module release notes
22

3+
## 7.9.3
4+
### Bug Fixes
5+
- **Set-LMWebsite**: Fixed an issue where `-WebsiteSteps` was omitted from the API request payload, so multi-step web check updates appeared to succeed but did not apply the supplied steps.
6+
- **Set-LMOpsNote**: Fixed an issue where scope updates (`-DeviceIds`, `-WebsiteIds`, `-DeviceGroupIds`) were not included in the request payload.
7+
- **Set-LMRole**: Fixed an issue where permission updates were omitted from the request payload when changing role privileges.
8+
- **Set-LMRecipientGroup**: Fixed `-Recipients` to accept an array of recipient objects instead of only binding a single recipient.
9+
10+
## 7.9.2
11+
### Bug Fixes
12+
- **SDT timezone compatibility with PowerShell 5.1**: Fixed an issue introduced in v7.9.1 where SDT commands would fail on PowerShell 5.1 with `Invalid timezone` errors due to .NET Framework not supporting IANA timezone IDs (e.g. `America/New_York`) directly.
13+
- **Cross-platform timezone support**: SDT commands now accept both IANA timezone IDs (e.g. `America/New_York`) and Windows standard timezone names (e.g. `Eastern Standard Time`). The module automatically resolves the input to the correct format for the API regardless of PowerShell version or operating system.
14+
15+
## 7.9.1
16+
### Bug Fixes & Changes
17+
- **SDT timezone consistency**: Added timezone-aware behavior across `New-LMDeviceSDT`, `New-LMDeviceGroupSDT`, `New-LMDeviceDatasourceSDT`, and `New-LMDeviceDatasourceInstanceSDT` so schedules are no longer interpreted based on the machine running the script.
18+
- **Portal timezone default for SDTs**: If `-Timezone` is omitted, SDT commands now resolve and use the portal timezone by default.
19+
- **Timezone validation improvements**: Replaced legacy commented timezone lists with active validation for timezone IDs and clearer error messages for invalid values.
20+
- **Set-LMSDT update alignment**: Added timezone handling and validation improvements for one-time SDT updates in `Set-LMSDT`.
21+
22+
### Major Changes in v7:
23+
- **API Headers**: Updated all API request headers to use a custom User-Agent (Logic.Monitor-PowerShell-Module/Version) for usage reporting on versions deployed.
24+
25+
### Documentation Overhaul
26+
We're excited to announce our new comprehensive documentation site at [https://logicmonitor.github.io/lm-powershell-module-docs/](https://logicmonitor.github.io/lm-powershell-module-docs/). The site includes:
27+
- Detailed command reference information
28+
- Code examples and snippets
29+
- Best practices guides
30+
31+
### New Filter Wizard
32+
Introducing the Filter Wizard, a new interactive tool to help build complex filters:
33+
- Visual filter construction
34+
- Support for all filter operators
35+
- Real-time filter preview
36+
- Available through `Build-LMFilter` or `-FilterWizard` parameter
37+
38+
```powershell
39+
# Use the standalone filter builder
40+
Build-LMFilter
41+
42+
# Use built-in filter wizard parameter
43+
Get-LMDeviceGroup -FilterWizard
44+
```
45+
![Filter Wizard Example](https://logicmonitor.github.io/lm-powershell-module-docs/_astro/LMFilter.4g625cq9_1boMAv.webp)
46+
347
## 7.9
448

549
### New Cmdlets

Tests/LMCachedAccount.Tests.ps1

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
Describe 'Connect-LMAccount cached GovCloud metadata' {
2+
BeforeAll {
3+
function Update-LogicMonitorModule { }
4+
function Get-LMPortalVersion { return $null }
5+
function New-MockCachedSecretInfo {
6+
param (
7+
[String]$Name,
8+
[String]$Portal,
9+
[String]$Id = 'test-access-id',
10+
[String]$Type = 'LMv1',
11+
[String]$GovCloud
12+
)
13+
14+
$metadata = [ordered]@{
15+
Portal = $Portal
16+
Id = $Id
17+
Modified = Get-Date
18+
Type = $Type
19+
}
20+
if ($PSBoundParameters.ContainsKey('GovCloud')) {
21+
$metadata['GovCloud'] = $GovCloud
22+
}
23+
24+
[PSCustomObject]@{
25+
Name = $Name
26+
Metadata = $metadata
27+
}
28+
}
29+
30+
. "$PSScriptRoot/../Public/Connect-LMAccount.ps1"
31+
}
32+
33+
BeforeEach {
34+
Remove-Variable LMAuth -Scope Script -ErrorAction SilentlyContinue
35+
Mock Get-SecretVault { }
36+
Mock Update-LogicMonitorModule { }
37+
Mock Get-Secret { 'cached-access-key' | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString }
38+
}
39+
40+
It 'Sets GovCloud from cached metadata when GovCloud is True' {
41+
$mockSecret = New-MockCachedSecretInfo -Name 'fedramp-account' -Portal 'agency' -GovCloud 'True'
42+
Mock Get-SecretInfo { @($mockSecret) }
43+
44+
Connect-LMAccount -CachedAccountName 'fedramp-account' -SkipCredValidation -SkipVersionCheck -DisableConsoleLogging
45+
46+
$Script:LMAuth.GovCloud | Should -Be $true
47+
$Script:LMAuth.Portal | Should -Be 'agency'
48+
}
49+
50+
It 'Defaults GovCloud to false when cached metadata has no GovCloud key' {
51+
$mockSecret = New-MockCachedSecretInfo -Name 'commercial-account' -Portal 'company'
52+
Mock Get-SecretInfo { @($mockSecret) }
53+
54+
Connect-LMAccount -CachedAccountName 'commercial-account' -SkipCredValidation -SkipVersionCheck -DisableConsoleLogging
55+
56+
$Script:LMAuth.GovCloud | Should -Be $false
57+
}
58+
59+
It 'Uses explicit -GovCloud switch when cached metadata has no GovCloud key' {
60+
$mockSecret = New-MockCachedSecretInfo -Name 'commercial-account' -Portal 'company'
61+
Mock Get-SecretInfo { @($mockSecret) }
62+
63+
Connect-LMAccount -CachedAccountName 'commercial-account' -GovCloud -SkipCredValidation -SkipVersionCheck -DisableConsoleLogging
64+
65+
$Script:LMAuth.GovCloud | Should -Be $true
66+
}
67+
68+
It 'Uses explicit -GovCloud switch when cached metadata has GovCloud False' {
69+
$mockSecret = New-MockCachedSecretInfo -Name 'commercial-account' -Portal 'company' -GovCloud 'False'
70+
Mock Get-SecretInfo { @($mockSecret) }
71+
72+
Connect-LMAccount -CachedAccountName 'commercial-account' -GovCloud -SkipCredValidation -SkipVersionCheck -DisableConsoleLogging
73+
74+
$Script:LMAuth.GovCloud | Should -Be $true
75+
}
76+
}
77+
78+
Describe 'Get-LMCachedAccount GovCloud metadata' {
79+
BeforeAll {
80+
. "$PSScriptRoot/../Public/Get-LMCachedAccount.ps1"
81+
}
82+
83+
It 'Returns GovCloud true when metadata GovCloud is True' {
84+
Mock Get-SecretInfo {
85+
[PSCustomObject]@{
86+
Name = 'fedramp-account'
87+
Metadata = @{
88+
Portal = 'agency'
89+
Id = 'test-id'
90+
Modified = Get-Date
91+
Type = 'LMv1'
92+
GovCloud = 'True'
93+
}
94+
}
95+
}
96+
97+
$result = Get-LMCachedAccount -CachedAccountName 'fedramp-account'
98+
99+
$result.GovCloud | Should -Be $true
100+
}
101+
102+
It 'Returns GovCloud false when metadata has no GovCloud key' {
103+
Mock Get-SecretInfo {
104+
[PSCustomObject]@{
105+
Name = 'commercial-account'
106+
Metadata = @{
107+
Portal = 'company'
108+
Id = 'test-id'
109+
Modified = Get-Date
110+
Type = 'LMv1'
111+
}
112+
}
113+
}
114+
115+
$result = Get-LMCachedAccount -CachedAccountName 'commercial-account'
116+
117+
$result.GovCloud | Should -Be $false
118+
}
119+
}

0 commit comments

Comments
 (0)