http://blogs.technet.com/b/heyscriptingguy/archive/2015/01/21/adding-and-subtracting-dates-with-powershell.aspx and http://blogs.msdn.com/b/powershell/archive/2006/09/17/the-wonders-of-date-math-using-windows-powershell.aspx
Google is your friend. Kurt On Thu, Dec 3, 2015 at 6:11 AM, Jesse Rink <[email protected]> wrote: > > 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 > > > >
