2

I have made this very simple DSC script. Which basically creates web application in default website.

Configuration ConfigureWebApp
{
  param ($MachineName)
  Import-DscResource -Module xWebAdministration
  Node $MachineName
  {
    xWebApplication NewWebApplication 
    { 
      Name = "MyApp"
      Website = "Default Web Site" 
      WebAppPool =  "DefaultAppPool" 
      PhysicalPath = "C:\Inetpub\wwwroot\MyApp"
      Ensure = "Present"       
    } 
  }
}

cd "C:\Dsc\scripts"
ConfigureWebApp -MachineName "WIN-KPURIN2B87H"

When I run generated MOF file, it gives me following error.

The PowerShell provider xWebAdministration does not exist at the PowerShell module path nor is it registered as a WMI provider. + CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : ModuleNameNotFound + PSComputerName : WIN-KPURIN2B87H

If I run Get-Module -ListAvailable , xWebAdministration is listed over there. I checked that $env:PSModulePath includes "C:\Program Files\WindowsPowerShell\Modules"

Odd part is, this DSC script is part of larger script which combines bunch of other DSC scripts which installs and setup IIS for this app. And they seem to run through fine.

I am using Windows Server 2012 R2. And it is not PULL or PUSH server. I am generating and running MOF file locally. Does anyone has any suggestion about what I am missing here ? I have a feeling that it has something to do about user context in which these scripts get executed, but just can't pinpoint the cause.

Including output of "tree "C:\Program Files\WindowsPowerShell\Modules\xWebAdministration" /F "

Folder PATH listing
Volume serial number is 80FD-C8E9
C:\PROGRAM FILES\WINDOWSPOWERSHELL\MODULES\XWEBADMINISTRATION
³   TechNetDocumentation-xWebAdministration.docx
³   TechNetDocumentation_xWebAdministration.html
³   xWebAdministration.psd1
³   
ÃÄÄÄDSCResources
³   ÃÄÄÄMSFT_xIisModule
³   ³       MSFT_xIisModule.psm1
³   ³       MSFT_xIisModule.schema.mof
³   ³       xIisModuleDesigner.ps1
³   ³       
³   ÃÄÄÄMSFT_xWebApplication
³   ³       MSFT_xWebApplication.psm1
³   ³       MSFT_xWebApplication.schema.mof
³   ³       
³   ÃÄÄÄMSFT_xWebAppPool
³   ³       MSFT_xWebAppPool.psm1
³   ³       MSFT_xWebAppPool.schema.mof
³   ³       
³   ÃÄÄÄMSFT_xWebConfigKeyValue
³   ³       MSFT_xWebConfigKeyValue.psm1
³   ³       MSFT_xWebConfigKeyValue.schema.mof
³   ³       
³   ÃÄÄÄMSFT_xWebDeploy
³   ³       MSFT_xWebdeploy.psm1
³   ³       MSFT_xWebdeploy.schema.mof
³   ³       
³   ÃÄÄÄMSFT_xWebsite
³   ³       MSFT_xWebsite.psm1
³   ³       MSFT_xWebsite.schema.mof
³   ³       
³   ÀÄÄÄMSFT_xWebVirtualDirectory
³           MSFT_xWebVirtualDirectory.psm1
³           MSFT_xWebVirtualDirectory.schema.mof
³           
ÀÄÄÄExamples
        BakeryWebsite.zip
        README.md
        Sample_xWebsite_ConfigurationData.psd1
        Sample_xWebsite_NewWebsite.ps1
        Sample_xWebsite_NewWebsiteFromConfigurationData.ps1
        Sample_xWebsite_RemoveDefault.ps1
TylerH
  • 20,799
  • 66
  • 75
  • 101
JackLock
  • 1,168
  • 1
  • 13
  • 26
  • Could you post the output of `tree "C:\Program Files\WindowsPowerShell\Modules\xWebAdministration" /F` on the target node? It might be that the directory structure is not quite right. – briantist Jun 17 '15 at 21:31
  • Just saw your edit. There is no such thing as "running MOF file locally" unless you're using PUSH (that is, you would be using `Start-DscConfiguration`) so please explain in greater detail how you are applying configuration. – briantist Jun 17 '15 at 21:32
  • @briantist I am still in process of learning of DSC, so I am not all familiar with terminology of DSC. But what I mean to say is, once I generate MOF file. I use "Start-DscConfiguration .\ConfigureWebApp -Verbose -Force -Wait" to run that MOF file. I have also included output you asked for. – JackLock Jun 17 '15 at 21:36
  • Ok, so just to be clear, what you are doing is `Push` mode. There is no such thing as a `Push` server, but if you were using `Pull` mode then you would need a `Pull` server. The output of `tree` looks good. I wonder if maybe you didn't unblock the ZIP file before extracting it? If that's the case, then all the files will have the "mark of the web". You could try this real quick: `gci 'C:\Program Files\WindowsPowerShell\Modules\xWebAdministration' | % { Unblock-File $_.FullName }` – briantist Jun 17 '15 at 21:41
  • I got this a bunch of times when testing my DSC scripts but could never quite pin down the reason for it. In the end I found the old 'switch it off/on again worked' so now I have 2 high level DSC scripts..1 called NodePrep.ps1 which installs the reskit and performs a reboot, the other that applies the remaining configuration. Not ideal but OK for now. I'll be interested if you find the answer! – sburgess123 Jun 18 '15 at 07:26
  • 1
    @briantist I tried your suggested solution. But I didn't help me. What I found that because of other things done by other DSC scripts, system needed to reboot. So I added check if reboot is required using `xPendingReboot` resource and it worked. Thanks for your help though. – JackLock Jun 19 '15 at 19:18
  • 1
    @JackLock, could you post you solution as answer so the question shows an answered? – TravisEz13 May 30 '16 at 16:49

0 Answers0