DSC Script resource erroring out on function name from module

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Bill Farrell Bill Farrell 4 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38646
    Profile photo of Bill Farrell
    Bill Farrell
    Participant

    I have the following desired state configuration script with a script resource referencing a module I'm using. The error I get is that in the test block, Get-NTFSAccess is not recognized. What's rude about this is that in the ISE, it's not only recognized, it autocompletes the function name and parameters for me. Could this be a scope issue?
    import-module NTFSSecurity -verbose
    Configuration DCConfig{
    param ($CompName)

    Import-DscResource -ModuleName PSDesiredStateConfiguration

    import-module NTFSSecurity -verbose

    Node $CompName{

    Script Check_C_NTFSPerms {

    GetScript= {
    Get-NTFSAccess -Path c:\ -Account "BUILTIN\Users" | Select-Object -ExpandProperty AccessRights
    }

    SetScript = {
    Remove-NTFSAccess -Path c:\ -Account "BUILTIN\users" -AccessRights AppendData -PassThru

    Remove-NTFSAccess -Path c:\ -Account "BUILTIN\users" -AccessRights CreateFiles -PassThru
    }

    TestScript = {
    if ((Get-NTFSAccess -Path c:\ -Account "BUILTIN\Users" | Select-Object -ExpandProperty AccessRights) -notlike "ReadAndExecute, Synchronize")
    {$False} else {$True}
    }
    }

    #38647
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Where is the module installed? If it's in your Documents folder, DSC won't see it; you'll need to put it in a system-wide location (typically Program Files\WindowsPowerShell\Modules).

    #38649
    Profile photo of Bill Farrell
    Bill Farrell
    Participant

    Thank you, that was the problem! Since I'm using a push method and not pull, the target server could not pull the module from my source server. When I copied the module to the target server's modules directory, it worked fine.

    Thanks again!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.