Skip to content

Instantly share code, notes, and snippets.


RIKIKU/DBBakCSVLocations.ps1 Secret

Last active Jun 30, 2016
What would you like to do?
$BackupFilesLocation = '\\MyfileServer\MyBackupsFolder'
$DBPATHS = Get-ChildItem -Recurse $BackupFilesLocation
$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
You can’t perform that action at this time.