I am backing up the database on data domain however I'll have to delete an expired backup using following command. It's an emc databoost agent app for Microsoft sql server.
I am trying to convert the command into powershell so I can run the command to delete expired backups from multiple clients in a loop. That way I can avoid running the command on each individual client.
I created following script and $clientname
is hardcoded, but I would like to pass multiple server names as $clientname
in loop.
$FileExe = "C:\..\bin\ddbmexptool.exe"
$dbtype = "mssql"
$dduser = "DDBOOST_USER=dduser"
$ddhostpath = "DEVICE_PATH=DDHOSTMSSQL"
$devicehostname = "DEVICE_HOST=ddhost.domain.com"
$clientname = "CLIENT=server1.domain.com"
& $FileExe -n $dbtype -a $dduser -a $ddhostpath -a $ddhostpath -a $devicehostname -a $clientname -b "6 weeks ago" -e "2 weeks ago"
1 Answer 1
Something like this:
$FileExe = "C:\..\bin\ddbmexptool.exe"
$dbtype = "mssql"
$dduser = "DDBOOST_USER=dduser"
$ddhostpath = "DEVICE_PATH=DDHOSTMSSQL"
$devicehostname = "DEVICE_HOST=ddhost.domain.com"
$servers = "server1","server2","server3"
foreach ($server in $servers)
{
$clientname = "CLIENT=$server.domain.com"
& $FileExe -n $dbtype -a $dduser -a $ddhostpath -a $ddhostpath -a $devicehostname -a $clientname -b "6 weeks ago" -e "2 weeks ago"
}
-
Thanks. It worked although it does return file sets before deleting actual file, it also throws following error :- ddbmexptool.exe : Setting default operation display information for savesets by savetime range. At D:\...\ddboostscript2.ps1:12 char:3 + & $FileExe -n $dbtype -a $dduser -a $ddhostpath -a $ddhostpath -a $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Setting default...savetime range.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError`SqlDBA– SqlDBA2020年05月22日 18:43:58 +00:00Commented May 22, 2020 at 18:43