-
-
Save RIKIKU/4e5f6e11629f130287d90b8f2562e06c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$BackupFilesLocation = '\\MyfileServer\MyBackupsFolder' | |
$DBPATHS = Get-ChildItem -Recurse $BackupFilesLocation | |
#$DBPATH.FullName | |
$OutputArray =@() | |
foreach ($DBPATH in $DBPATHS){ | |
$namesnstuff = New-Object psobject -Property @{ | |
BaseName = $DBPATH.BaseName -replace "_backup.*" | |
FullName = $DBPATH.FullName | |
} | |
$OutputArray += $namesnstuff | |
} | |
$OutputArray | Export-Csv "$BackupFilesLocation\FileList.csv" -NoTypeInformation | |
<# | |
Below is the formula to use in excel. | |
="RESTORE DATABASE " & B2 & " FROM DISK = '" & A2 & "' WITH MOVE 'mscrm' TO 'E:\MSSQL10_50.SOL\MSSQL\DATA\"&B2&".MDF', MOVE 'mscrm_log' TO 'E:\MSSQL10_50.SOL\MSSQL\DATA\"&B2&".LDF'" | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment