Hi All,
I am trying to execute DPM 2012 Powershell commands from a console application in c#, but at the time of Invoke it is giving me the following error.
{"Could not load file or assembly 'ACM, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"ACM, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
Below is my code.
var runspace = PShell.GetRunSpace();
if (runspace.RunspaceStateInfo.State == RunspaceState.BeforeOpen)
runspace.Open();
var pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript("$installPath = (Get-ItemProperty \"HKLM:\\SOFTWARE\\Microsoft\\Microsoft Data Protection Manager\\Setup\" \"UIInstallPath\").UIInstallPath");
pipeline.Commands.AddScript("$dpmModuleFullPath = $installPath + \"Modules\\DataProtectionManager\\DataProtectionManager.psd1\"");
pipeline.Commands.AddScript("Import-Module $dpmModuleFullPath");
pipeline.Commands.AddScript("$pg=get-protectiongroup -dpmserver dpm-2012-01");
pipeline.Commands.AddScript("$pg");
try
{
System.Collections.ObjectModel.Collection<PSObject> result = pipeline.Invoke();
foreach (PSObject obj in result)
{
var name = obj.Properties["FriendlyName"].Name;
}
}
catch (Exception e)
{
}