Skip to content

Comments

Convert Microsoft.IIs.PowerShell.Framework.* objects to PSCustom#2510

Open
dpaulson45 wants to merge 1 commit intomainfrom
dpaul-HcIISModule
Open

Convert Microsoft.IIs.PowerShell.Framework.* objects to PSCustom#2510
dpaulson45 wants to merge 1 commit intomainfrom
dpaul-HcIISModule

Conversation

@dpaulson45
Copy link
Member

Issue:
On some computers, we are not able to automatically convert the IIS cmdlets to a data stream resulting in an error exception Value does not fall within the expected range.

Reason:
We need to this to help prevent serialization issues by having that class trying to convert it.

Fix:
Manually walk the object attributes and convert it to a Custom PS Object to be returned. This then would allow the script to properly work.

Resolved #2505

Validation:
Lab/Pester tested. Customer verified resolved issue.

@dpaulson45
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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 addresses serialization issues with Microsoft IIS PowerShell Framework objects that cause "Value does not fall within the expected range" exceptions when using jobs or Export-Clixml. The fix introduces a new ConvertTo-PSObject function that manually converts these objects to PSCustomObject by walking their properties, preventing serialization failures.

Changes:

  • Added new ConvertTo-PSObject.ps1 function to recursively convert IIS Framework objects to PSCustomObject
  • Modified Get-IISWebSite.ps1 to convert site and binding objects before returning
  • Modified Get-IISWebApplication.ps1 to convert web application objects before returning

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 14 comments.

File Description
ConvertTo-PSObject.ps1 New utility function that recursively converts objects to PSCustomObject, with depth limiting and type filtering to handle serialization issues
Get-IISWebSite.ps1 Updated to convert IIS site and binding objects using ConvertTo-PSObject before constructing return objects
Get-IISWebApplication.ps1 Updated to convert IIS web application objects using ConvertTo-PSObject before constructing return objects

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

@dpaulson45 dpaulson45 force-pushed the dpaul-HcIISModule branch 2 times, most recently from e315d40 to 291c3e6 Compare February 24, 2026 18:37
@dpaulson45
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45 dpaulson45 requested review from Copilot and removed request for Copilot February 24, 2026 18:44
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


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

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

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


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

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


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

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


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

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

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


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

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


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

@dpaulson45
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

We need to this to help prevent serialization issues by having that class trying to convert it. Now it is done manually

Add changes based off Copilot review
@dpaulson45
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue] - Health Checker - Throwing 'Value does not fall within the expected range'

2 participants