1

I want to check automatically the latest WindowsServerBackup result via PowerShell on Windows Server 2012/2012 R2.

It's not only "success" or "failure" but "backed-up volume" and "error message", too. So I tried using the following ways but I can't get the above informations.

  1. Get-WB* is not enough that I want to do.
  2. I can't find WMI object around WindowsServerBackup.
  3. Get-Eventlog can't access about Backup (Application and Service Log/Microsoft/Windows/Backup)

Did I miss some right way? What should I do?

2
  • I have a script I'm using that pulls the last backup time (for a Nagios check) by wrapping wbadmin get versions in powershell. WBadmin does give the information you're looking for in terms of successes, but it doesn't list failures. I'm mainly mentioning this in case you want to combine it with one of the approaches below. Feb 22 '18 at 20:59
  • Oh, I didn't know Get-WinEvent at all!! Thank you guys! That get info I wanted. I can't make up my mind which one to choose best answer, so Tomalak is more kind for me becasue he answer my question and navigate appropriate site for me.
    – keisuke
    Feb 23 '18 at 1:12
0

With the information from this website, I was able to figure it out:

You can use the Get-WinEvent cmdlet, because Get-EventLog can only access very few logfiles. To see all the log files on the system, you can use:

Get-WinEvent -ListLog *

To find a certain one, you can use

Get-WinEvent -ListLog * | Where LogName -like "*backup*"

Some of those logs are only accessible for with elevated privileges. The one we want is called "Microsoft-Windows-Backup", it can be accessed without admin privileges.

You can get all the events from this log using this command:

Get-WinEvent "Microsoft-Windows-Backup"

That's the way to access the Backup event log, but I'm not sure if it contains all the information you need.

0

To get an overview, where you can see error messages:

# All messages
Get-WinEvent "Microsoft-Windows-Backup" | Format-Table -Wrap

# Only the newest
Get-WinEvent "Microsoft-Windows-Backup" -MaxEvents 1 | Format-Table -Wrap

To get EventData with details like information about volumes, you can use this code:

# Save as variable
$Event = Get-WinEvent "Microsoft-Windows-Backup" -MaxEvents 1

# Convert to XML
$EventXML = [xml]$Event.ToXml()

# Show all EventData
$EventXML.Event.EventData.Data | Format-Table -Wrap

# Show only VolumesInfo data, with things like path, size and number of files
$EventXML.SelectSingleNode("//*[@Name='VolumesInfo']")."#text"

That can of course be parsed further, but with these commands you can get the information.

Sample output from my server:

TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
21-02-2018 23:12:16 14 Information The backup operation has completed.

<VolumeInfo><VolumeInfoItem Name="D:" OriginalAccessPath="D:" State="14" HResult="0" DetailedHResult="0" PreviousState="8" IsCritical="0" IsIncremental="1" BlockLevel="0" HasFiles="1" HasSystemState="0" IsCompacted="0" IsPruned="0" IsRecreateVhd="0" FullBackupReason="0" DataTransferred="6274990320" NumUnreadableBytes="0" TotalSize="5118410992" TotalNoOfFiles="4691" Flags="84" BackupTypeDetermined="1" SSBTotalNoOfFiles="0" SSBTotalSizeOnDisk="0" /></VolumeInfo>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.