Hello,
I am currently working on some configuration items and I am having some problems with my discovery script. Basically, I'm trying to see if a file exists, and run the remediation script if it doesn't. Here is my discovery script:
Function Check-Path {
$return = Test-Path 'C:\Users\Public\Desktop\File.txt'
return $return
}Function Check-True {
if (Check-Path) {
Return $true
} else {
Return $false
}
}
Return Check-True
Now I can't tell if this script is working correctly or not through Config manager. When I run it locally, it does detect if the file exists. The part I'm not sure on is the text that says, "Use the echo command to return the script value to Configuration Manager" in the Edit discovery script window. I'm not sure what result it is expecting.
Since it is a Boolean, it should be just looking for a true or false, but when the file is absent, it isn't running the remediation script. (Here is the sanitized remediation script)
Copy-Item '\\server\publicshare\file" -Destination "C:\Users\Public\Desktop"
Here are the settings for my compliance rules:
I'm guessing that the discovery script isn't sending the correct information to Config Manager in order to detect if the file exists. Please let me know if you need more information.
Thanks,
Ed