Tuesday, October 18, 2016

Verify you Windows Server Backups with notification

If you scheduled a Windows Server Backup, you can check for Errors and send an email if a Error happened.

To do this just schedule to run the following script after your backup job:

# Check EventLog for Error created by Windows Backup
If (Get-EventLog -LogName Application -EntryType Error -Source Microsoft-Windows-Backup -After (Get-Date).AddHours(-24))
    {
    #Set E-mail variables.
    $EmailFrom = "server@yourdomain.com"
    $EmailTo = "Tim.Buntrock@yourdomain.com"
    $Subject = "$env:COMPUTERNAME - Windows Backup failed"
    $Body = "$env:COMPUTERNAME - Windows Backup failed. Please logon to the server and verify your backup task!"
    $SMTPServer = "smtp01.yourdomain.com"
    #Send message
    Send-MailMessage -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Priority High -To $EmailTo -From $EmailFrom
    }

Else
    {
    exit
    }


Thats it. :)

AD Powershell Oneliner - Get PSO Settings

Just type in the following:
Get-ADFineGrainedPasswordPolicy PSOName
Replace PSOName with the name of your PSO object.

You can add >c:\admin\PSOSettings.txt to export the settings to a text file.
Get-ADFineGrainedPasswordPolicy PSOName >c:\admin\PSOSettings.txt