2

This is similar to this question:

I downloaded xWebAdminstration. I modified my environment variable PSModulePath in Windows (I'm testing/developing on Win 7).

In C:\Program Files\WindowsPowerShell\Modules, I have 7 directories, for example the first is MSFT_xiisModule.

My environment variable PSModulePath is set to: %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\

I ran this:

Write-Host "`$env:PSModulePath=$($env:PSModulePath)"
Write-Host "`$env:ProgramFiles=$($env:ProgramFiles)"
Write-Host "`$CurrentValue=$CurrentValue"
Write-Host "`$PSVersionTable.PSVersion=$($PSVersionTable.PSVersion)"
Get-Module -ListAvailable
Write-Host "`n`n==== DscResources ====="
Get-DscResource | Select Name, Properties | ft -AutoSize 

and this is the output (which shows the modules are being found as module, but not as DscResources):

 $env:PSModulePath=C:\Users\neal.walters\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerS
hell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Serv
er\120\Tools\PowerShell\Modules\;c:\Program Files\WindowsPowerShell\Modules\
$env:ProgramFiles=C:\Program Filession=4.0


        Directory: C:\Program Files\WindowsPowerShell\Modules


    ModuleType Version    Name                                ExportedCommands                       
    ---------- -------    ----                                ----------------                       
    Script     0.0        MSFT_xIisModule                     {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebApplication                {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebAppPool                    {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebConfigKeyValue             {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebDeploy                     {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebsite                       {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebVirtualDirectory           {Get-TargetResource, Set-TargetResou...


        Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


    ModuleType Version    Name                                ExportedCommands                       
    ---------- -------    ----                                ----------------                       
    Manifest   1.0.0.0    AppLocker                           {Set-AppLockerPolicy, Get-AppLockerP...
    Manifest   1.0.0.0    BitsTransfer                        {Add-BitsFile, Remove-BitsTransfer, ...
    Manifest   1.0.0.0    CimCmdlets                          {Get-CimAssociatedInstance, Get-CimC...
    Script     1.0.0.0    ISE                                 {New-IseSnippet, Import-IseSnippet, ...
    Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-C...
    Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}    
    Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-I...
    Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificat...
    Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-...
    Manifest   3.0.0.0    Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManC...
    Binary     1.0        PSDesiredStateConfiguration         {Set-DscLocalConfigurationManager, S...
    Script     1.0.0.0    PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCom...
    Binary     1.1.0.0    PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Rem...
    Manifest   2.0.0.0    PSWorkflow                          {New-PSWorkflowExecutionOption, New-...
    Manifest   1.0.0.0    PSWorkflowUtility                   Invoke-AsWorkflow                      
    Manifest   1.0.0.0    TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-Tro...
    Manifest   1.0.0.0    WebAdministration                   {Start-WebCommitDelay, Stop-WebCommi...


        Directory: C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules


    ModuleType Version    Name                                ExportedCommands                       
    ---------- -------    ----                                ----------------                       
    Manifest   1.0        SQLASCMDLETS                        {Add-RoleMember, Backup-ASDatabase, ...
    Manifest   1.0        SQLPS                               {Backup-SqlDatabase, Add-SqlAvailabi...


        Directory: c:\Program Files\WindowsPowerShell\Modules


    ModuleType Version    Name                                ExportedCommands                       
    ---------- -------    ----                                ----------------                       
    Script     0.0        MSFT_xIisModule                     {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebApplication                {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebAppPool                    {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebConfigKeyValue             {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebDeploy                     {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebsite                       {Get-TargetResource, Set-TargetResou...
    Script     0.0        MSFT_xWebVirtualDirectory           {Get-TargetResource, Set-TargetResou...


    ==== DscResources =====



    Name           Properties                                          
    ----           ----------                                          
    File           {DestinationPath, Attributes, Checksum, Contents...}
    Archive        {Destination, Path, Checksum, DependsOn...}         
    Environment    {Name, DependsOn, Ensure, Path...}                  
    Group          {GroupName, Credential, DependsOn, Description...}  
    Log            {Message, DependsOn}                                
    Package        {Name, Path, ProductId, Arguments...}               
    Registry       {Key, ValueName, DependsOn, Ensure...}              
    Script         {GetScript, SetScript, TestScript, Credential...}   
    Service        {Name, BuiltInAccount, Credential, DependsOn...}    
    User           {UserName, DependsOn, Description, Disabled...}     
    WindowsFeature {Name, Credential, DependsOn, Ensure...}            
    WindowsProcess {Arguments, Path, Credential, DependsOn...}
Community
  • 1
  • 1
NealWalters
  • 17,197
  • 42
  • 141
  • 251
  • The page for that resource says `This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). It also requires IIS features.` I see that you have PS 4 installed from your output. Do you also have IIS features installed? Since not all IIS features are available on Windows 7, I wonder if maybe it's not possible to use this on a client OS. Unfortunately they don't seem to specify which features. – briantist Jan 16 '15 at 17:22
  • I do have IIS installed; I'll have to zoom-in on the features, but basically I can open IIS Admin and setup websites. I'm guessing that if you download Powershell 4.0 it doesn't matter what OS you are on. – NealWalters Jan 16 '15 at 17:29
  • Here's something interesting. I ran your code on my system (Windows 8.1), and I noticed that in the `Get-Module` call, all of the modules with DSC resources show a version of 0.0 in your call, but in mine they show real versions. That could be a clue as to what's happening. `Get-DscResource` does show the resources on my system. What is your execution policy? These are script modules so you need to be able to run scripts to load them. – briantist Jan 16 '15 at 18:38
  • Always run -unrestricted. Does the fourth line of your xIisModuleDesigner.ps1 file show this: $classVersion = "1.0.0" In that other post I referred to, he has "DSCResources" in his directory structure. The install said just to unpzip files to c:\Program Files\WindowsPowerShell\Modules\. I did try putting them under DSCResources but didn't see any difference. Is that foldername required to get DSC to work, i.e. to go beyond just being a module to being a real DSC? I have a Win 2008/R2 "dev" server, I could try it there. – NealWalters Jan 16 '15 at 20:22
  • Yes, I have the same version of that file. The `DSCResources` folder is absolutely required. The directory structure is very important. Your path should be something like this (for an example file): `C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\DSCResources\MSFT_xWebApplication\MSFT_xWebApplication.psm1` – briantist Jan 16 '15 at 20:27
  • Here is a good reference for that: http://blogs.msdn.com/b/powershell/archive/2013/12/05/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx – briantist Jan 16 '15 at 20:29
  • Okay, I should have taken the doc more literally. I figured I didn't need hte .docx file and the Examples, so I only unzipped the DSCResources. I think it was the missing xWebAdministration\xWebAdministration.psd1, along with the structure that was the problem. Thanks, do you want me to answer, or do you want the credit. – NealWalters Jan 16 '15 at 20:39

1 Answers1

4

Based on the comments, I am seeing now that the problem is path structure. In your output, you have this:

Directory: c:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                       
---------- -------    ----                                ----------------                       
Script     0.0        MSFT_xIisModule                     {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebApplication                {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebAppPool                    {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebConfigKeyValue             {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebDeploy                     {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebsite                       {Get-TargetResource, Set-TargetResou...
Script     0.0        MSFT_xWebVirtualDirectory           {Get-TargetResource, Set-TargetResou...

Your directory structure should look like this:

C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\DSCResources\

Within there, that's where the MSFT_x* directories go. This is also why the versions are all listed as 0.0.

Make sure you've got the parent directory for the module (xWebAdministration), which should contain at minimum a .psd1 (module manifest) and a DSCResources folder, in which is a folder for each resource which contains a .psm1 and an .mof file.

See http://blogs.msdn.com/b/powershell/archive/2013/12/05/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx for a visual.

briantist
  • 45,546
  • 6
  • 82
  • 127