Weird issue with the File resource

This topic contains 2 replies, has 3 voices, and was last updated by  Viktar Vedmich 2 years, 1 month ago.

  • Author
  • #26739


    So I have a strange problem. I'm just being myself creating a DSC Resource. I want to copy a folder to the computer. Here's the relevant bit of code:

    File localfolder
    SourcePath = "\\server1\share\subfolder\"
    DestinationPath = "c:\localfolder"
    Type = "Directory"
    Recurse = $true
    Force = $true
    Checksum = 'SHA-256'
    MatchSource = $true

    This is all cool. I've done this multiple times before. However when I compile the mof I see a new error message that I don't remember

    `WARNING: The configuration 'CRM' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.`

    Hey that's weird, why do I have to import the main resource? Oh well I can do it I guess. So I import it, get rid of the error message and go. This is what the resulting bits of the mof file looks like.

    instance of MSFT_FileDirectoryConfiguration as $MSFT_FileDirectoryConfiguration1ref
    ResourceID = "[File]localfolder";
    Type = "Directory";
    Checksum = "SHA-256";
    MatchSource = True;
    DestinationPath = "c:\\localfolder";
    Force = True;
    ModuleName = "PSDesiredStateConfiguration";
    SourceInfo = "REDACTED";
    Recurse = True;
    ModuleVersion = "0.0";
    SourcePath = "\\\\server1\\share\\subfolder\\";

    ConfigurationName = "Configuration";

    I edited out some bits like my server names and actual folder stuff. But the most important part is that it tells me the File Resource is part of the PSDesiredStateConfiguration Module and that it's version is 0.0.

    So I stick this in a pull server and tell it to go fish. But this makes the server pulling the configuration unhappy as it cannot find the module.

    Job {654D1234-19B3-11E5-80D7-005056A44AF0} :
    MIResult: 1
    Error Message: Cannot find module PSDesiredStateConfiguration_0.0 from the server http://Server1:8080/PSDSCPullServer/PSDSCPullServer.svc/Module(ConfigurationId='e54559e9-4ab8-48e0-a85c-79d30cf8aa0e',ModuleName='PSDesiredStateConfiguration',ModuleVersion='0.0')/ModuleContent.
    Message ID: WebDownloadManagerModuleNotFound,Microsoft.PowerShell.DesiredStateConfiguration.Commands.GetDscModuleCommand
    Error Category: 21
    Error Code: 1
    Error Type: MI

    Oh well. I guess I have to copy my PSDesiredStateConfiguration module from the workstation, zip it and create a checksum. I do notice that the version of the module is actually 1.1, but I name it anyway so the configuration will actually find it.

    This causes a new error:

    Job {C358A572-19B0-11E5-80D7-005056A44AF0} :
    This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is The PowerShell DSC resource C:\Program Files\WindowsPowerShell\Modules\PSDesiredStateConfiguration\DscResources\MSFT_FileDirectoryConfiguration does not contain the corresponding MOF file C:\Program Files\WindowsPowerShell\Modules\PSDesiredStateConfiguration\DscResources\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.schema.mof.

    You see, the File resource isn't actually a part of the module. If we take a look at it exists as it's own entity. It's compiled binary.

    20150623 14:39:34 C:\windows\system32\WindowsPowerShell\v1.0\Modules> Get-DscResource

    ImplementedAs Name ModuleName Version Properties
    ————- —- ———- ——- ———-
    Binary File {DestinationPath, Attributes, Checksum, Content...
    PowerShell cCreateFileShare cFileShare {Path, ShareName, DependsOn, Ensure...}
    PowerShell cSetSharePermissions cFileShare {ShareName, ChangeAccessUsers, DependsOn, Ensur...
    PowerShell Archive PSDesiredStateConfiguration 1.1 {Destination, Path, Checksum, Credential...}
    PowerShell Environment PSDesiredStateConfiguration 1.1 {Name, DependsOn, Ensure, Path...}
    PowerShell Group PSDesiredStateConfiguration 1.1 {GroupName, Credential, DependsOn, Description...}
    Binary Log PSDesiredStateConfiguration 1.1 {Message, DependsOn, PsDscRunAsCredential}
    PowerShell Package PSDesiredStateConfiguration 1.1 {Name, Path, ProductId, Arguments...}
    PowerShell Registry PSDesiredStateConfiguration 1.1 {Key, ValueName, DependsOn, Ensure...}
    PowerShell Script PSDesiredStateConfiguration 1.1 {GetScript, SetScript, TestScript, Credential...}
    PowerShell Service PSDesiredStateConfiguration 1.1 {Name, BuiltInAccount, Credential, Dependencies...
    PowerShell User PSDesiredStateConfiguration 1.1 {UserName, DependsOn, Description, Disabled...}
    PowerShell WaitForAll PSDesiredStateConfiguration 1.1 {NodeName, ResourceName, DependsOn, PsDscRunAsC...
    PowerShell WaitForAny PSDesiredStateConfiguration 1.1 {NodeName, ResourceName, DependsOn, PsDscRunAsC...
    PowerShell WaitForSome PSDesiredStateConfiguration 1.1 {NodeCount, NodeName, ResourceName, DependsOn...}
    PowerShell WindowsFeature PSDesiredStateConfiguration 1.1 {Name, Credential, DependsOn, Ensure...}
    PowerShell WindowsOptionalFeature PSDesiredStateConfiguration 1.1 {Name, DependsOn, Ensure, LogLevel...}
    PowerShell WindowsProcess PSDesiredStateConfiguration 1.1 {Arguments, Path, Credential, DependsOn...}
    PowerShell xADDomain xActiveDirectory 2.3 {DomainAdministratorCredential, DomainName, Saf...

    So there's no wonder it won't work.

    My problem is, how do I fix this?

  • #26759

    Don Jones

    So – I'm confused; you say you're creating a DSC Resource. Are you actually attempting to create a DSC configuration?

    Unfortunately, it's a little tough to troubleshoot because I don't know if you're showing me all the configuration code that's actually relevant. Consider going ti, pasting your configuration as a Gist, and then pasting the Gist URL into the forums here. Seeing the entire configuration is pretty much the only way I think I can help you figure this out.

    But, bottom line, File is not a part of PSDesiredStateConfiguration (which you knew), so that's the part to unwind. I'm not sure why your system believes that to be the case. It'd also be helpful to know what versions everything is.

  • #27910

    Viktar Vedmich

    I have the same problem, gits url
    OS: server 2012R2

You must be logged in to reply to this topic.