Scripts

Check DDPE Policy

I created a script which looks for a specific file in a folder and searches for a specific word using list of remote machines.

if that word exists on that file and returns true or you can change the output text to yours.

$MachineList = ‘C:\hashmat\list.txt’

$Devices = Get-Content $MachineList

$Searchtext = “windows”

foreach($Device in $Devices)
{
$file = “\\$Device\c$\ProgramData\folderName\filename.txt”

if(Test-Connection -ComputerName $Device -Count 2 -ea silentlycontinue)
{
if(Test-Path $file)
{
if(Get-Content $file | Select-String $Searchtext -quiet)
{
Write-Host “$Device : Policy Found”
}
else
{
Write-Host “$Device : Policy Not found” -Fore Red
}
}
else
{
#Write-Host “Unable to find:[$file]” -Fore Red
Write-Host “DDPE Not installed on : $Device” -Fore Red
}
}
Else
{
Write-Host “Unable to connect to: $Device” -Fore Red
}

}

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button