Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IisModule - Using to remove at server level doesn't work #632

Open
quillypowers opened this issue Feb 20, 2024 · 1 comment
Open

IisModule - Using to remove at server level doesn't work #632

quillypowers opened this issue Feb 20, 2024 · 1 comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.

Comments

@quillypowers
Copy link

Problem description

Duplicate site error thrown when site param isn't set. In general this resource needs better examples.

Verbose logs

VERBOSE: [S150RCDOCSWS-CI]: LCM:  [ Start  Resource ]  [[IisModule]ServerSideIncludeModule]
VERBOSE: [S150RCDOCSWS-CI]: LCM:  [ Start  Test     ]  [[IisModule]ServerSideIncludeModule]
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Getting Handler for 'ServerSideIncludeModule' in Site ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Get-TargetResource has been run.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Get-TargetResource has been run.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] RequestPath is '*.shtm'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Path is '%windir%\System32\inetsrv\iis_ssi.dll'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] StatusRequestPath is ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] StatusPath is ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Module present is 'False'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] ModuleConfigured is 'False'.
VERBOSE: [S150RCDOCSWS-CI]: LCM:  [ End    Test     ]  [[IisModule]ServerSideIncludeModule]  in 0.3600 seconds.
VERBOSE: [S150RCDOCSWS-CI]: LCM:  [ Start  Set      ]  [[IisModule]ServerSideIncludeModule]
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Getting Handler for 'ServerSideIncludeModule' in Site ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Get-TargetResource has been run.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] RequestPath is '*.shtm'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Path is '%windir%\System32\inetsrv\iis_ssi.dll'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] StatusRequestPath is ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] StatusPath is ''.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Module present is 'False'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] ModuleConfigured is 'False'.
VERBOSE: [S150RCDOCSWS-CI]:                            [[IisModule]ServerSideIncludeModule] Removing handler.
The parameter "SiteName" is declared in parameter-set "__AllParameterSets" multiple times.
At C:\projects\SqlDscGit\DevServers\RunAll\WebApp\ServerConfigs.ps1:2148 char:21
+ ...             Start-DSCConfiguration -Path $localpath -Cimsession $Sess ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], CimException
    + FullyQualifiedErrorId : ParameterDeclaredInParameterSetMultipleTimes

DSC configuration

IisModule ServerSideIncludeModule
        {
            Name = "ServerSideIncludeModule"
            Path = "%windir%\System32\inetsrv\iis_ssi.dll"
            RequestPath = "*.shtm"
            Verb = "*"
            Ensure = "Absent"
        }

Suggested solution

I'm using this for IIS hardening and trying to remove unused modules, ideally at the server level, so maybe an example of how to do this (if it works) would be a solution. In this example, if site is a required param it should be marked required and noted that it only works down at the site level.

Operating system the target node is running

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      17763  0

PowerShell version and build the target node is running

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  5328

WebAdministrationDsc version

4.1.0
@johlju
Copy link
Member

johlju commented Feb 21, 2024

To me it looks like bug in the code. It looks like it calls without any parameters

But the function actually has mandatory parameters so the above call could never be successful.

param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $Name,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Parameter()]
[String] $SiteName
)

Not sure how this has ever worked. Most likely there are no unit tests that are testing this code path.

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub labels Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

2 participants