Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#.
- .SYNOPSIS
- Check if User has signature for company policy.
- .DESCRIPTION
- 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
- remote share
- .EXAMPLE
- .\Check-SignatureAdoption.ps1
- .NOTES
- File Name : Check-SignatureAdoption.ps1
- Author : /u/sup3rlativ3
- Prerequisites : Powershell
- #>
- $SIG = "%AppData%\Roaming\Microsoft\Signatures\New Signature.htm" # Sets SIG variable to the users local appdata signature file.
- $FLAG = "\\SERVER\PATH\To\FILE.txt" # Sets FLAG variable to the file for logging.
- $NoRepeat = "$env:temp\completed.txt"
- $a = Get-Date # Assigns the date and time to the variable.
- $date = $a.ToShortDateString() # Assigns the date in short format to the variable.
- $time = $a.ToShortTimeString() # Assigns the time in short format to the variable.
- $SMTPServer = "smtpserver.internal.mydomain.com.au"
- if(Test-Path $SIG) # Test if the file exists. If it does then do the following.
- {
- if(!(Test-Path $NoRepeat)) # Checks to make sure this hasn't been successful before. We don't want multiple reports of successful users.
- {
- Write-Host "You have adopted the email signature." # Write to the console.
- Write-Host "Exiting..." # Write to the console.
- Add-Content $FLAG "Completed by $env:username at $date $time" # Write to the file that it has been completed.
- Add-Content $NoRepeat "Completed by $env:username at $date $time" # Write to the file that it has been completed.
- }
- }
- else # If the signature file does NOT exist then do the following.
- {
- Try # Try the following.
- {
- 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
- }
- Catch # If the above errors then do the following.
- {
- 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
- Start-Sleep -s 10 # Wait 10 seconds
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement