1

I developed a custom Powershell CmdLet.

namespace GetStuff
{
    using System.Management.Automation;

    [Cmdlet(VerbsCommon.Get, "Stuff")]
    [OutputType(typeof(Stuff[]))]
    public class GetStuffCmdLet : PSCmdlet
    {

    }
}

after Building the project i tried to import it in PowerShell with Import-Module .\GetStuff.dll -Force The following Error Message appeared:

Import-Module : Could not load file or assembly 'System.Management.Automation, >Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1 Import-Module .\GetStuff.dll -Force CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

rubgra
  • 165
  • 2
  • 9
  • 2
    Looks like you compiled your module against version 7.2.1 of the library. If you want to write cmdlets for Windows PowerShell (5.1 and earlier), you need to compile against the "Windows PowerShell Reference Assemblies" instead of `S.M.A.dll` - if both = PowerShell Standard – Mathias R. Jessen Feb 15 '22 at 17:17
  • 2
    [This answer](https://stackoverflow.com/a/58211901/45375) provides an overview of the various PowerShell SDK NuGet packages and when to use which. – mklement0 Feb 15 '22 at 17:26

0 Answers0