Advertisement
Guest User

Check email signatures

a guest
Jan 4th, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <#.
  2. .SYNOPSIS
  3. Check if User has signature for company policy.
  4.  
  5. .DESCRIPTION
  6. This is a script to run at logon and check if the users have a specific signature in the repo. This will then update a file ona
  7. remote share
  8.  
  9. .EXAMPLE
  10. .\Check-SignatureAdoption.ps1
  11.  
  12. .NOTES
  13. File Name : Check-SignatureAdoption.ps1
  14. Author : /u/sup3rlativ3
  15. Prerequisites : Powershell
  16.  
  17. #>
  18.  
  19. $SIG = "%AppData%\Roaming\Microsoft\Signatures\New Signature.htm" # Sets SIG variable to the users local appdata signature file.
  20. $FLAG = "\\SERVER\PATH\To\FILE.txt" # Sets FLAG variable to the file for logging.
  21. $NoRepeat = "$env:temp\completed.txt"
  22. $a = Get-Date # Assigns the date and time to the variable.
  23. $date = $a.ToShortDateString() # Assigns the date in short format to the variable.
  24. $time = $a.ToShortTimeString() # Assigns the time in short format to the variable.
  25. $SMTPServer = "smtpserver.internal.mydomain.com.au"
  26.  
  27.  
  28.  
  29. if(Test-Path $SIG) # Test if the file exists. If it does then do the following.
  30. {
  31. if(!(Test-Path $NoRepeat)) # Checks to make sure this hasn't been successful before. We don't want multiple reports of successful users.
  32. {
  33. Write-Host "You have adopted the email signature." # Write to the console.
  34. Write-Host "Exiting..." # Write to the console.
  35. Add-Content $FLAG "Completed by $env:username at $date $time" # Write to the file that it has been completed.
  36. Add-Content $NoRepeat "Completed by $env:username at $date $time" # Write to the file that it has been completed.
  37. }
  38. }
  39. else # If the signature file does NOT exist then do the following.
  40. {
  41. Try # Try the following.
  42. {
  43.  
  44. Send-MailMessage -From "$env:username@domain.com.au" -To "IT@mydomain.com.au" -Subject "$env:username does not have signature" -Body "user $env:username at $date $time on $env:COMPUTERNAME did not have the signature installed." -SmtpServer $SMTPServer
  45. }
  46.  
  47.  
  48. Catch # If the above errors then do the following.
  49. {
  50. Send-MailMessage -From "$env:username@domain.com.au" -To "IT@mydomain.com.au" -Subject "HALP!!1!1" -Body "Unknown error for user $env:username at $date $time on $env:COMPUTERNAME" -SmtpServer $SMTPServer
  51. Start-Sleep -s 10 # Wait 10 seconds
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement