title: Powershell: Use user32.dll in .psd1 file
body: <p>Environment: Win 10 64 bit, PS version 7.1</p>
  <p>I had a module and I decided to move everything into class based. To use the assembly I need to load the .dll etc via the workaround psd1 file.</p>
  <p>After look at the thread: <a href="https://stackoverflow.com/questions/42837447/powershell-unable-to-find-type-when-using-ps-5-classes/42839957#42839957">Powershell: Unable to find type when using PS 5 classes</a></p>
  <p>**Per comment from @mklement0 the .dll can't be loaded as the same way as the assmebly 'System.Windows.Forms'</p>
  <p><strong>updated per suggestion from @mklement0 but it still didn't work</strong>
  This is what it looks like after the update:</p>
  <pre><code>H:\PowerShell\Modules\TestUtils
  
  Mode                 LastWriteTime         Length Name
  ----                 -------------         ------ ----
  -a---           2/26/2021  6:25 AM           4168 TestUtils.psd1
  -a---           2/26/2021  6:22 AM            449 TestUtils.psm1
  
  </code></pre>
  <p>and TestUtils.psd1 was created by command:</p>
  <blockquote>
  <p>New-ModuleManifest TestUtils.psd1 -RootModule  TestUtils.psm1
  The content in .psm1 is as below:</p>
  </blockquote>
  <pre><code>Add-Type -name NativeMethods -namespace Win32 -MemberDefinition @'
      [DllImport(&quot;user32.dll&quot;)]
      public static extern void mouse_event(int flags, int dx, int dy, int cButtons, int info);
      [DllImport(&quot;user32.dll&quot;)]
      public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
  '@  
  
  Class MyWinUtils
  {
      
      Static [Void] ClickLeftMouse([int]$x,[int]$y)
      {
        [Win32.NativeMethods]::mouse_event(6,0,0,0,0) 
      }
  }
  </code></pre>
  <p>When I load the module the error popped up:</p>
  <pre><code>using module TestUtils
  InvalidOperation: At TestUtils.psm1:15 char:5
  +       [Win32.NativeMethods]::mouse_event(6,0,0,0,0)
  +        ~~~~~~~~~~~~~~~~~~~
  Unable to find type [Win32.NativeMethods].
  </code></pre>
  <p>Thanks</p>