need assistance modifying a quest AD cmdlet powershell script

can someone help me add a small piece of logic to this script that will exit the script if the results found are zero.

here is the script that searches a security group for pwd that will expire in 60 days:
I need to build in some logic to exit the script if the results are empty.

$Logfile="C:\result.csv"
Get-QADUser -MemberOf ABCsecuritygroup -PasswordNotChangedFor 120 | Where PasswordNeverExpires -eq $False | Select-Object email -Unique |
Export-Csv $Logfile -NoTypeInformation
#Email the data
$EmailBody = "Exec list attached - password detected to expire in the next 60 days"
$message = New-Object System.Net.Mail.MailMessage –ArgumentList automation@mydomain.com,target@mydomain.com,'60 day notification - Exec pwd detected will expire', $EmailBody
$smtp = New-Object System.Net.Mail.SMTPClient –ArgumentList smtp.mydomain.com
$Attachment = New-Object System.Net.Mail.Attachment($Logfile)
$message.Attachments.Add($attachment)
$smtp.Send($message)
Start-Sleep 1
$Attachment.Dispose()
$Message.Dispose()
#Remove the temp file
if (Test-Path $Logfile) {Remove-Item $Logfile}

Open in new window

siber1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
Test for empty
$Logfile="C:\result.csv"
$users = Get-QADUser -MemberOf ABCsecuritygroup -PasswordNotChangedFor 120 | Where PasswordNeverExpires -eq $False 
if ($uses.count) -ge 1) {
Get-QADUser -MemberOf ABCsecuritygroup -PasswordNotChangedFor 120 | Where PasswordNeverExpires -eq $False | Select-Object email -Unique | Export-Csv $Logfile -NoTypeInformation
#Email the data
$EmailBody = "Exec list attached - password detected to expire in the next 60 days"
$message = New-Object System.Net.Mail.MailMessage –ArgumentList automation@mydomain.com,target@mydomain.com,'60 day notification - Exec pwd detected will expire', $EmailBody
$smtp = New-Object System.Net.Mail.SMTPClient –ArgumentList smtp.mydomain.com
$Attachment = New-Object System.Net.Mail.Attachment($Logfile)
$message.Attachments.Add($attachment)
$smtp.Send($message)
Start-Sleep 1
$Attachment.Dispose()
$Message.Dispose()
#Remove the temp file
if (Test-Path $Logfile) {Remove-Item $Logfile}
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
siber1Author Commented:
hi, just tested and it errors out on this

At C:\scripts\adhoc\execnotify.ps1:3 char:16
+ if ($uses.count) -ge 1) {
+                ~
Missing statement block after if ( condition ).
At C:\scripts\adhoc\execnotify.ps1:3 char:23
+ if ($uses.count) -ge 1) {
+                       ~
Unexpected token ')' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingStatementBlock

Open in new window

RobSampsonCommented:
Hi, change
if ($uses.count) -ge 1) {

to
if (($uses.count) -ge 1) {

Rob.
siber1Author Commented:
thx for the assistance.
David Johnson, CD, MVPOwnerCommented:
($users.count -ge 1) vice  ($uses.count) -ge 1)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.