1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public void BackupDatabase(string databaseName)
{
if (RoleEnvironment.IsAvailable)
return;
using (Runspace runspace = RunspaceFactory.CreateRunspace(RunspaceConfiguration.Create()))
{
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
Command saveBaseCommand = new Command(SaveBaseCommand);
CommandParameter databaseNameParameter = new CommandParameter("-dbToBackup", databaseName);
saveBaseCommand.Parameters.Add(databaseNameParameter);
pipeline.Commands.Add(saveBaseCommand);
Collection<PSObject> result = pipeline.Invoke();
if (result != null && result.Count > 0)
{
foreach (var item in result)
{
logger.Trace(item.ToString());
}
}
}
} |