Executing DPM Powershell Commands

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)
            {

            }

July 17th, 2012 10:15am

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)
            {

            }

Free Windows Admin Tool Kit Click here and download it now
October 22nd, 2012 3:55pm

Here is how I fixed the issue on my computer.

If you look at your installation media and browse to the folder "SCDPM\DPM2012\setup", you will find "Acm.dll" file. If you copy that file to your computer to the following folder "C:\Program Files\Microsoft Data Protection Manager\DPM2012\bin", the above issue should go away.

If the problem persists, make sure that you have opened a new instance of PowerShell and then test your script.

October 22nd, 2012 4:12pm

Hi,

I am still facing this issue with C# console app. I am using DPM 2012 R2. I can run cmdlets from Windows powershell but not from C# code.

The error I am getting is as below:

ex = {"Argument 'Get-DPMProtectionGroup' is not recognized as a cmdlet: Could not load type 'Microsoft.Internal.EnterpriseStorage.Dls.Utils.ApplicationSettings' from assembly 'Utils, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."}

Do I need to copy some DPM files with my console App?

Free Windows Admin Tool Kit Click here and download it now
April 16th, 2015 12:42am

Hi,

I am still facing this issue with C# console app. I am using DPM 2012 R2. I can run cmdlets from Windows powershell but not from C# code.

The error I am getting is as below:

ex = {"Argument 'Get-DPMProtectionGroup' is not recognized as a cmdlet: Could not load type 'Microsoft.Internal.EnterpriseStorage.Dls.Utils.ApplicationSettings' from assembly 'Utils, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."}

Do I need to copy some DPM files with my console App?

April 16th, 2015 4:40am

Hi,

I am still facing this issue with C# console app. I am using DPM 2012 R2. I can run cmdlets from Windows powershell but not from C# code.

The error I am getting is as below:

ex = {"Argument 'Get-DPMProtectionGroup' is not recognized as a cmdlet: Could not load type 'Microsoft.Internal.EnterpriseStorage.Dls.Utils.ApplicationSettings' from assembly 'Utils, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."}

Do I need to copy some DPM files with my console App?

Free Windows Admin Tool Kit Click here and download it now
April 16th, 2015 4:40am

Hi,

I am still facing this issue with C# console app. I am using DPM 2012 R2. I can run cmdlets from Windows powershell but not from C# code.

The error I am getting is as below:

ex = {"Argument 'Get-DPMProtectionGroup' is not recognized as a cmdlet: Could not load type 'Microsoft.Internal.EnterpriseStorage.Dls.Utils.ApplicationSettings' from assembly 'Utils, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."}

Do I need to copy some DPM files with my console App?

April 16th, 2015 4:40am

Hi,

I am still facing this issue with C# console app. I am using DPM 2012 R2. I can run cmdlets from Windows powershell but not from C# code.

The error I am getting is as below:

ex = {"Argument 'Get-DPMProtectionGroup' is not recognized as a cmdlet: Could not load type 'Microsoft.Internal.EnterpriseStorage.Dls.Utils.ApplicationSettings' from assembly 'Utils, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."}

Do I need to copy some DPM files with my console App?

Free Windows Admin Tool Kit Click here and download it now
April 16th, 2015 4:40am

I found that if process it 32 bit, it will not be able to run DPM remote powershell cmdlets. I changed my app to 64 bit and now it is working fine.
  • Proposed as answer by UmeshBhatt25 20 hours 22 minutes ago
May 12th, 2015 7:20am

I found that if process it 32 bit, it will not be able to run DPM remote powershell cmdlets. I changed my app to 64 bit and now it is working fine.
  • Proposed as answer by UmeshBhatt25 Tuesday, May 12, 2015 11:19 AM
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2015 11:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics