I've been using some powershell script in a C# application for several years, and due to an upgrade of VEEAM, it has stopped working in part of the app.
What I mean is, I run several powershell commands, but only one of them does not return any data, and I get no errors. But, the command will return data if I run it manually in a powershell window.
Here's the script that works:
Code: Select all
Runspace rs = RunspaceFactory.CreateRunspace();
rs.Open();
PowerShell ps = PowerShell.Create();
ps.Runspace = rs;
ps.AddScript("Add-PSSnapin VeeamPSSnapin");
ps.AddScript("Get-VBRJob | ?{$_.IsContinuous -match \"false\"} | where {($_.GetLastResult() -eq \"Failed\") -OR ($_.GetLastResult() -eq \"Warning\")} | select name");
Code: Select all
Runspace rs2 = RunspaceFactory.CreateRunspace();
rs2.Open();
PowerShell ps2 = PowerShell.Create();
ps2.Runspace = rs2;
ps2.AddScript("Add-PSSnapin VeeamPSSnapin");
ps2.AddScript("$Job = Get-VBRJob -name \"" + result.Members["Name"].Value + "\"");
ps2.AddScript("$LastSession = $Job.FindLastSession()");
// getlog here to get job level warnings
ps2.AddScript("$lastsession.logger.getlog().updatedrecords | ?{($_.status -eq \"EWarning\") -OR ($_.status -eq \"EFailed\")} | select title");
Code: Select all
Runspace rs3 = RunspaceFactory.CreateRunspace();
rs3.Open();
PowerShell ps3 = PowerShell.Create();
ps3.Runspace = rs3;
ps3.AddScript("Add-PSSnapin VeeamPSSnapin");
ps3.AddScript("Get-VBRJob | ?{$_.IsContinuous -match \"false\"} | select name, {$_.Findlastsession().creationTime}, {$_.Findlastsession().EndTime}, {$_.Findlastsession().IsFullMode}");
It used to work fine, but an upgrade to VEEAM broke it.
Any ideas?
Thank you!
Dan