Goal: To use Puppet to install IIS with full-duration logging.
Problem: Through a simple PowerShell command, I install IIS but with poor Puppet logging. I need to get around this. For background, a Puppet manifest can execute this raw PowerShell command and successfully install IIS: Import-module servermanager; Add-windowsfeature web-server, web-webserver
The Puppet technology can log and on the client (Puppet agent node) and server (Puppet Master server). But with the command above, Puppet logging does not stay with it. Normally to get around long-duration PowerShell processes, I use the "start-process" command with the "wait" option. This way the PowerShell operation does not return control until the targeted process is complete. Despite working well, I have found that this does not work for installing IIS. The error I get is consistent with not having sufficient permissions. Installing other things or doing other duties that require administrator privileges are normally not a problem with start-process. I try to get around this limitation of start-process and installing IIS by having a Scheduled Task kick off the installation of IIS. This Scheduled Task is executed by the "System" user. The IIS installation still fails.
What can I do to install IIS and have a Puppet Manifest log the long-duration process? It seems that only a raw command will allow IIS to be installed. I want full-duration logging, and nothing I try works.
Without any verbose logging enabled or even a try\catch around your Add-WindowsFeature, you're basically doing a silent installation. With a try catch, you can dig further into the exception and see if there anything to understand what is causing your failures.