Running Configuration script actually ran scripts on authoring machine

I just ran my test configuration by calling “TestConfig -ConfigurationData C:\Folder\ConfigData.psd1 -OutputPath C:\Folder\Output” and it actually ran the scripts in the script resource on my authoring workstation. Luckily it was just an example deleting files in the temp folder. Has anyone run into this before?

Well, without seeing any of the code, it’s super hard to guess what happened. But assuming “TestConfig” is the name of a Configuration block, then I would have expected C:\Folder\Output\TestConfig\ to contain one or more MOF files. I would not have expected the contents of Script resources to run, no.

Thanks for the quick reply Don!

I figured it out and it was a rookie mistake… Wasn’t thinking that get/set/test had to be a script block, just went straight from “SetScript =” to the script without starting and ending with {}. So SetScript actually ran locally on my box. See below:

Script CDriveCleanup
        {
            GetScript = {@{Result = "WhateverResult"}}
            SetScript = Remove-Item C:\Windows\Temp\* 
            TestScript = 
            {
                $drive = Get-WmiObject win32_logicaldisk -Filter "Drivetype=3"
                $drivePercentRemaining = ($drive.FreeSpace / $drive.Size)
                If( $drivePercentRemaining -gt 0.1)
                {
                    return $true
                }Else
                {
                    return $false
                }
            }#end TestScript                 
        }

So for anyone else brand new to this, make sure your set/get/test are script blocks…

Script CDriveCleanup
        {
            GetScript = { @{Result = "WhateverResult"}}
            SetScript = {Remove-Item C:\Windows\Temp\*}
            TestScript = 
            {
                $drive = Get-WmiObject win32_logicaldisk -Filter "Drivetype=3"
                $drivePercentRemaining = ($drive.FreeSpace / $drive.Size)
                If( $drivePercentRemaining -gt 0.1)
                {
                    return $true
                }Else
                {
                    return $false
                }
            }#end TestScript                 
        }

Hopefully someone else will find this useful at least.