@@ -646,7 +646,7 @@ Describe 'Restore-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL
646646CREATE TABLE dbo.TestData (Id INT PRIMARY KEY, InsertTime DATETIME, Value NVARCHAR(50));
647647INSERT INTO dbo.TestData (Id, InsertTime, Value) VALUES (1, GETDATE(), 'Initial');
648648"@
649- Invoke-SqlDscQuery - ServerObject $script :serverObject - Database $script :pitSourceDbName - Query $query1 - ErrorAction ' Stop'
649+ Invoke-SqlDscQuery - ServerObject $script :serverObject - DatabaseName $script :pitSourceDbName - Query $query1 - ErrorAction ' Stop'
650650
651651 # Create full backup
652652 $script :pitFullBackupFile = Join-Path - Path $script :backupDirectory - ChildPath ($script :pitSourceDbName + ' _PIT_Full.bak' )
@@ -663,7 +663,7 @@ INSERT INTO dbo.TestData (Id, InsertTime, Value) VALUES (1, GETDATE(), 'Initial'
663663
664664 # Insert additional data after the point-in-time
665665 $query2 = " INSERT INTO dbo.TestData (Id, InsertTime, Value) VALUES (2, GETDATE(), 'AfterPIT');"
666- Invoke-SqlDscQuery - ServerObject $script :serverObject - Database $script :pitSourceDbName - Query $query2 - ErrorAction ' Stop'
666+ Invoke-SqlDscQuery - ServerObject $script :serverObject - DatabaseName $script :pitSourceDbName - Query $query2 - ErrorAction ' Stop'
667667
668668 # Create log backup to capture the additional data
669669 $script :pitLogBackupFile = Join-Path - Path $script :backupDirectory - ChildPath ($script :pitSourceDbName + ' _PIT_Log.trn' )
@@ -712,12 +712,12 @@ INSERT INTO dbo.TestData (Id, InsertTime, Value) VALUES (1, GETDATE(), 'Initial'
712712 }
713713
714714 # Clean up backup files
715- if (Test-Path - Path $script :pitFullBackupFile )
715+ if ($ script :pitFullBackupFile -and ( Test-Path - Path $script :pitFullBackupFile ) )
716716 {
717717 Remove-Item - Path $script :pitFullBackupFile - Force - ErrorAction ' SilentlyContinue'
718718 }
719719
720- if (Test-Path - Path $script :pitLogBackupFile )
720+ if ($ script :pitLogBackupFile -and ( Test-Path - Path $script :pitLogBackupFile ) )
721721 {
722722 Remove-Item - Path $script :pitLogBackupFile - Force - ErrorAction ' SilentlyContinue'
723723 }
@@ -740,12 +740,12 @@ INSERT INTO dbo.TestData (Id, InsertTime, Value) VALUES (1, GETDATE(), 'Initial'
740740
741741 # Verify data reflects the point-in-time (only initial record should exist)
742742 $query = " SELECT COUNT(*) AS RecordCount FROM dbo.TestData WHERE Id = 1;"
743- $result = Invoke-SqlDscQuery - ServerObject $script :serverObject - Database $script :pitDbName - Query $query - ErrorAction ' Stop'
743+ $result = Invoke-SqlDscQuery - ServerObject $script :serverObject - DatabaseName $script :pitDbName - Query $query - ErrorAction ' Stop'
744744 $result.RecordCount | Should - Be 1 - Because ' Initial record should exist'
745745
746746 # Verify the second record (inserted after point-in-time) should NOT exist
747747 $query = " SELECT COUNT(*) AS RecordCount FROM dbo.TestData WHERE Id = 2;"
748- $result = Invoke-SqlDscQuery - ServerObject $script :serverObject - Database $script :pitDbName - Query $query - ErrorAction ' Stop'
748+ $result = Invoke-SqlDscQuery - ServerObject $script :serverObject - DatabaseName $script :pitDbName - Query $query - ErrorAction ' Stop'
749749 $result.RecordCount | Should - Be 0 - Because ' Record inserted after point-in-time should not exist'
750750 }
751751 }
0 commit comments