Skip to content

Feature/add wrkbookrecs ps#18

Merged
cocallaw merged 16 commits intomainfrom
feature/add-wrkbookrecs-ps
Jan 13, 2026
Merged

Feature/add wrkbookrecs ps#18
cocallaw merged 16 commits intomainfrom
feature/add-wrkbookrecs-ps

Conversation

@cocallaw
Copy link
Owner

This pull request introduces a major update to the AzRetirementMonitor PowerShell module, shifting the default behavior to use the Az.Advisor PowerShell module for retrieving Azure service retirement recommendations, while retaining REST API support as an opt-in mode. It also expands compatibility to PowerShell Desktop (5.1), adds improved error handling and messaging, and enhances the export and reporting features for better data clarity.

closes #16

Default behavior and compatibility changes:

  • The module now defaults to using the Az.Advisor PowerShell module for retrieving recommendations, providing full parity with Azure Advisor data. REST API access is now opt-in via the -UseAPI switch, and Connect-AzRetirementMonitor is only required for API access (-UsingAPI switch). PowerShell Desktop (5.1) is now supported in addition to Core (7+). (AzRetirementMonitor.psd1, Public/Connect-AzRetirementMonitor.ps1, Public/Get-AzRetirementRecommendation.ps1, [1] [2] [3] [4] [5]

Command and parameter updates:

  • Connect-AzRetirementMonitor now requires the -UsingAPI switch and is only needed for API-based access. The help documentation and parameter sets have been updated to clarify usage scenarios and to prevent accidental use when not needed. (Public/Connect-AzRetirementMonitor.ps1, [1] [2] [3]
  • Get-AzRetirementRecommendation adds a -UseAPI switch, with updated logic to use either the Az.Advisor module (default) or REST API (when specified). The function checks for module/session availability and provides clearer error messages and help documentation. (Public/Get-AzRetirementRecommendation.ps1, [1] [2]

New and improved validation:

  • Introduced Test-AzAdvisorSession to verify that the Az.Advisor module is installed and an active Azure session exists before attempting module-based operations, improving reliability and user guidance. (Private/Test-AzAdvisorSession.ps1, Private/Test-AzAdvisorSession.ps1R1-R52)

Export/reporting enhancements:

  • Enhanced export logic in Export-AzRetirementReport to improve the "Solution" column: when using Az.Advisor, if "Problem" and "Solution" are identical, the more informative "Description" is used instead. Also, improved PowerShell 5.1 compatibility for date formatting and clarified HTML export columns. (Public/Export-AzRetirementReport.ps1, [1] [2] [3] [4]

Documentation and error message improvements:

  • Updated help documentation and error messages throughout the module to clarify the distinction between API and module modes, and to provide more actionable feedback to users. (Public/Get-AzRetirementMetadataItem.ps1, Public/Get-AzRetirementRecommendation.ps1, [1] [2]

These changes represent a significant usability and compatibility improvement, with a clear separation between default (module-based) and advanced (API-based) usage, enhanced error handling, and improved reporting outputs.

Changed default behavior to use the Az.Advisor PowerShell module for retrieving Azure retirement recommendations, with REST API access now available via the -UseAPI switch. Added Test-AzAdvisorSession for module/session validation, updated Connect-AzRetirementMonitor to require -UsingAPI for API mode, and improved documentation and error handling throughout. This is a breaking change and requires Az.Advisor for default usage; see release notes for migration details.
Introduces QUICKSTART.md with setup instructions, usage examples, troubleshooting tips, and migration notes for AzRetirementMonitor v2.0. Highlights new default method using Az.Advisor and provides guidance for both PowerShell and API workflows.
Documents major changes in version 2.0.0, including the new default use of the Az.Advisor module, updated authentication workflows, and the introduction of API mode via switches. Adds migration guidance, clarifies command usage, updates example outputs, and provides a comparison table between the default and API methods. Improves overall structure and detail for installation, authentication, and usage scenarios.
Improved detection of retirement recommendations by parsing extended properties for retirementFeatureName and retirementDate, and updated logic to check both text and extended properties. Also, switched to using ResourceMetadataResourceId for resource identification and improved description building to prefer retirement feature details.
* Expand PowerShell compatibility in module manifest

Updated AzRetirementMonitor.psd1 to support both PowerShell Core (7+) and Desktop (5.1) editions. This change broadens compatibility for users on different PowerShell platforms.

* Fix UTC time generation for PowerShell 5.1 compatibility

Replaced usage of Get-Date -AsUTC with [DateTime]::UtcNow to ensure compatibility with PowerShell 5.1, which does not support the -AsUTC parameter.

* Update README for PowerShell compatibility

Clarifies that the module now supports both PowerShell Desktop 5.1 and Core 7+, updating prerequisites and feature notes to reflect expanded compatibility.

* Update QUICKSTART.md
Added clarification that both PowerShell Desktop 5.1 and Core 7+ are supported. Improved formatting and readability in QUICKSTART.md and README.md for better guidance and migration instructions.
Transforms the Solution field to use Description when Problem and Solution are identical and Description exists, providing more informative output for Az.Advisor mode in CSV, JSON, and HTML exports.
Updated the HTML export table header to use 'Description' instead of 'Solution' for clarity and consistency with report content.
@cocallaw cocallaw self-assigned this Jan 13, 2026
Copilot AI review requested due to automatic review settings January 13, 2026 03:20
@cocallaw cocallaw added the enhancement New feature or request label Jan 13, 2026
Added the -UseAPI parameter to relevant Connect-AzRetirementMonitor and Get-AzRetirementRecommendation calls in the test suite to ensure API-based authentication and error handling are properly validated.
@cocallaw cocallaw requested review from Copilot and removed request for Copilot January 13, 2026 03:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a major breaking change to the AzRetirementMonitor PowerShell module by shifting from REST API-based access to using the Az.Advisor PowerShell module as the default method for retrieving Azure service retirement recommendations. The REST API remains available as an opt-in alternative via the -UseAPI switch.

Changes:

  • Default behavior changed to use Az.Advisor PowerShell module instead of REST API
  • PowerShell Desktop 5.1 support added alongside existing Core 7+ support
  • New mandatory -UsingAPI parameter on Connect-AzRetirementMonitor to prevent accidental use when not needed
  • Enhanced export functionality with improved Description/Solution field handling for better data clarity
  • New Test-AzAdvisorSession private function for validating Az.Advisor module availability and active Azure sessions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Tests/AzRetirementMonitor.Tests.ps1 Updated existing tests to add -UsingAPI parameter to Connect-AzRetirementMonitor calls and -UseAPI to Get-AzRetirementRecommendation calls for API mode testing
README.md Comprehensive documentation updates explaining the new default vs API methods, migration guide from v1.x, updated authentication instructions, and feature comparison table
QUICKSTART.md New quick start guide showing both recommended (Az.Advisor) and alternative (REST API) workflows with troubleshooting section
Public/Get-AzRetirementRecommendation.ps1 Implements dual-mode support: default Az.Advisor module mode and opt-in REST API mode via -UseAPI switch
Public/Get-AzRetirementMetadataItem.ps1 Updated error messages to clarify API-only access requirement and reference -UsingAPI parameter
Public/Export-AzRetirementReport.ps1 Enhanced export logic to use Description field when Problem equals Solution, with PowerShell 5.1 compatibility for date formatting
Public/Connect-AzRetirementMonitor.ps1 Added mandatory -UsingAPI parameter to confirm API-based access intent, with updated help documentation
Private/Test-AzAdvisorSession.ps1 New validation function checking Az.Advisor module availability and active Azure PowerShell context
AzRetirementMonitor.psd1 Version bumped to 2.0.0, PowerShell compatibility updated to 5.1+ supporting both Desktop and Core, release notes added

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cocallaw and others added 2 commits January 12, 2026 22:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Jan 13, 2026

@cocallaw I've opened a new pull request, #19, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 13, 2026

@cocallaw I've opened a new pull request, #20, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits January 13, 2026 10:13
…ptions via Az.Advisor (#19)

* Initial plan

* Fix subscription context handling in Get-AzRetirementRecommendation

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

* Add error handling for context restoration

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

* Update Public/Get-AzRetirementRecommendation.ps1

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Public/Get-AzRetirementRecommendation.ps1

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add test coverage for subscription context switching behavior

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>
Co-authored-by: Corey Callaway <coreylcallaway@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…entReport (#20)

* Initial plan

* Refactor: extract duplicated transformation logic before switch statement

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

* Update Public/Export-AzRetirementReport.ps1

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add functional tests for transformation logic

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>
Co-authored-by: Corey Callaway <coreylcallaway@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…t-AzRetirementReport help (#21)

* Initial plan

* Enhanced Export-AzRetirementReport help documentation

Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cocallaw <11371083+cocallaw@users.noreply.github.com>
Refactored the transformation of recommendation objects to ensure all properties are strings and not arrays, improving export consistency. Enhanced CSV export by explicitly sanitizing all fields to prevent formula injection in spreadsheet applications. This improves data safety and reliability for CSV consumers.
@cocallaw cocallaw requested a review from Copilot January 13, 2026 16:56
@cocallaw cocallaw merged commit e2161bf into main Jan 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Change PowerShellVersion to 5.0 Instead Of 7.0

3 participants