DPM - Powershell Script to get list of files available for backup

1.2k views Asked by At

I am working on a DPM powershell script to get the list of files/folders available for backup in a particular directory. More precisely, i need to get the list of folders under the directory D:\inetpub\vhosts\ (i.e all vhosts). I have been trying to write a script using DPM powershell cmdlets and this is what i have come up with.

$searchpath = 'D:\inetpub\vhosts'
$so=New-SearchOption -FromRecoveryPoint $today -ToRecoveryPoint $tomorrow -SearchDetail     filesfolders -SearchType contains -Location  $searchpath -SearchString  "*" -ErrorAction SilentlyContinue

$ri=Get-RecoverableItem -Datasource $datasource -SearchOption $so  -ErrorAction SilentlyContinue
foreach($file in $ri)
{
    echo $file.userFriendlyName
}

But i was not able to get all the directories. After some research i found out that New-SearchOption can at maximum return 250 searches. In my use the number of folders is minimum 1500. Is there any way of getting all the files. Any help would really be appreciated.

1

There are 1 answers

0
MFT On

Have you tried using the pipeline. There might be paging features built in the cmdlet only available using the pipeline. Try the code below:

$searchpath = 'D:\inetpub\vhosts'

New-SearchOption -FromRecoveryPoint $today -ToRecoveryPoint $tomorrow -SearchDetail filesfolders -SearchType contains -Location  $searchpath -SearchString  "*" -ErrorAction SilentlyContinue |

    Get-RecoverableItem -Datasource $datasource -ErrorAction SilentlyContinue | For-EachObject { 

        $_.userFriendlyName
}