Powershell (sqlps) lastbackupdate not changing despite having run a sqlserver backup

Posted by user1666376 on Server Fault See other posts from Server Fault or by user1666376
Published on 2012-09-12T16:28:54Z Indexed on 2012/09/13 3:41 UTC
Read the original article Hit count: 480

I'm using Powershell to check last backup times across all our sqlserver databases. This seems to work really well, but I've got a question

If I run this (a cut-down version of the actual script):

dir SQLSERVER:\SQL\Server1\default\databases | select parent, name, 
lastbackupdate

I get:

Parent                     Name                       LastBackupDate
------                     ----                       --------------
[Server1]                  ADBA                       10/09/2012 21:15:37
[Server1]                  ReportServer               10/09/2012 21:00:17
[Server1]                  ReportServerTempDB         10/09/2012 21:00:18
[Server1]                  db1                        10/09/2012 21:15:35

If I then run a sql backup of the Server1 default instance, and run the same query the last backup date doesn't change:

PS C:\temp> dir SQLSERVER:\SQL\Server1\default\databases | select parent, name,
lastbackupdate

Parent                     Name                       LastBackupDate
------                     ----                       --------------
[Server1]                  ADBA                       10/09/2012 21:15:37
[Server1]                  ReportServer               10/09/2012 21:00:17
[Server1]                  ReportServerTempDB         10/09/2012 21:00:18
[Server1]                  db1                        10/09/2012 21:15:35

..but if I open a new powershell window, it shows the backup I just took:

PS SQLSERVER:\> dir SQLSERVER:\SQL\Server1\default\databases | select parent, 
name,    lastbackupdate

Parent                     Name                       LastBackupDate
------                     ----                       --------------
[server1]                  ADBA                       12/09/2012 09:03:23
[server1]                  ReportServer               12/09/2012 08:48:03
[server1]                  ReportServerTempDB         12/09/2012 08:48:04
[server1]                  db1                        12/09/2012 09:03:21

My guess is that this is expected behaviour, but could anybody show me where it's documented/explained - I just want to understand what's going on.

This is running the SQlps which came with 2008, against a 2008 instance.

Thanks

Matt

© Server Fault or respective owner

Related posts about powershell

Related posts about sql-server-2008-r2