puppetlabs / puppetlabs-iis

Manage IIS for Windows Server 2008 and above. Maintain application sites, pools, virtual applications, and many other IIS settings.
Apache License 2.0
13 stars 63 forks source link

Virtual Directories #356

Open flkdnt opened 1 year ago

flkdnt commented 1 year ago

Bug Report

Describe the Bug

  1. Powershell cannot run the IIS Specific Commands without importing the WebAdministration module if IIS Commands havn't already been run in the current powershell session/puppet run.

When Creating or Updating a Virtual Directory

  1. The CREATE function Errors: 

Debug: STDOUT: New-Item : A parameter cannot be found that matches parameter name 'Application'.

  1. The UPDATE Function Errors: 

Debug: STDOUT: Set-ItemProperty : Property application is not found on <PATH>

The reason for these errors is:

Expected Behavior

The Virtual Directory gets created in IIS

Steps to Reproduce

  1. Add a virtual directory from a folder from a network share, with the application parameter set:
iis_virtual_directory { 'NAME':
    ensure       => 'present',
    name         => 'NAME',
    sitename     => 'SITE',
    application  => 'APPLICATION,
    physicalpath => 'Z:\\FOLDER\\PATH',
}
  1. run puppet, i.e. puppet agent -t

Environment

Additional Context

The following is how I fixed the file webadministration.rb in my local environment:

Change function

Line 34:

Line 42:

Line 44:

Line 67:

Update function

Line 70:

Suggestion - To handle or eliminate the error that occurs when "application" isn't in the Item Property of the Virtual Directory and application is specified: Adding -ErrorAction SilentlyContinue to the current command is a workaround. A more permanent solution would be to filter on the attribute 'application' from the Item-property, like this: Import-Module WebAdministration;Start-Sleep -Seconds 5;Get-ItemProperty -Path PATH | Get-Member -MemberType NoteProperty and only run the command if it exists.

Line 87:

jordanbreen28 commented 1 year ago

@flkdnt thanks for raising this. We are accepting PRs to this repo, so if you want to implement your proposed changes feel free to do so. Otherwise I'll label this issue so It can be prioritised correctly by our team :-) Thanks again.