Oops sorry, yes, echo $BackupStatus|Select-Object -ExpandProperty LastSuccessfulBackupTime is correct... i was typing it out by hand since my copy/paste wasn't working.
Can you clarify what this does, $DeltaDays.TotalDays ? Jesse Rink Source One Technology, Inc. HP Partner 262 993 2231 ________________________________ From: [email protected] <[email protected]> on behalf of Michael B. Smith <[email protected]> Sent: Thursday, December 3, 2015 8:19 AM To: [email protected] Subject: [NTSysADM] Re: Powershell/scripting Are you certain this is the right line? echo $LastSuccessfulBackupDate|Select-Object -ExpandProperty LastSuccessfulBackupTime This seems more likely: echo $BackupStatus|Select-Object -ExpandProperty LastSuccessfulBackupTime If so $LastDate = $BackupStatus.LastSuccessfulBackupTime $DeltaDays =(Get-Now - $LastDate) $DeltaDays.TotalDays Of course, no error correction detection remediation there. ________________________________ From: [email protected] <[email protected]> on behalf of Jesse Rink <[email protected]> Sent: Thursday, December 3, 2015 9:11 AM To: [email protected] Subject: [NTSysADM] Powershell/scripting Hello. I couldn't script my way out of a paperbag so, I'm looking for help if anyone on here is decent with Powershell/scripting. I'm running the following command via a Powershell script. ------ $DEVICE=$args[0] $BackupStatus = Invoke-Command -Computername $DEVICE -ScriptBlock { add-Pssnapin Windows.serverbackup -ErrorAction SilentlyContinue; Get-WBSummary } echo $LastSuccessfulBackupDate|Select-Object -ExpandProperty LastSuccessfulBackupTime ------ That result yields the following, for example, "Friday, December 1st, 2015 9:00:38 PM" How can I have Powershell take that result, and have that date Subtracted from the Current Date, and the answer be a plain integer? Something to the affect of $DaysSinceLastSuccessfulBackup=($LastSuccessfulBackupDate-%DATE%) So for example, if on December 3rd, the last successful backup was December 1st, the $DaysSinceLastSuccessfulBackup would be an integer of 2. Pardon my obvious ignorance with Powershell and coding.! Is this easily doable? Thanks. J
