Tag : compliance

Find A File with Random Characters and Send Email by SCCM Compliance Rule

Here is my Powershell script for Finding a file with random characters in the end, if the system find the file, it will email to our alert mailbox as well. This is done by SCCM Compliance Rule:

# File Finder
# Ray Qiu
# Feb 15, 2017

# Define variables

$username = “myself”
$password = ConvertTo-SecureString “password” -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
$Computer = hostname

# Start the scan!
$result=Get-ChildItem C:\Windows\Temp\ | Where-Object {$_.Name -like ‘sam_ref*.wav’}
echo $result

if($result) {
Write-Host “found”
# Email the result
Send-MailMessage -From [email protected] -To [email protected] -Subject “SCCM File Found For $Computer” -Credential $cred -Body ”
Time Stamp: $(Get-Date)
Host Name: $Computer

” -SmtpServer exchange.server.address
} else {
Write-Host “nothing”


SCCM Compliance Rule for Finding Process Running

Here is my powershell script for finding if a  process is running with SCCM compliance rule.

$process = Get-Process Process-name-xxx -ErrorAction SilentlyContinue
if ($process) {
Write-Host “Running”
else {Write-Host “Not Running”}


And for compliance rule is to check if the value is equal to  “Running”