• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Snapin (Template: Powershell) cannot load modules. Is this normal?

Scheduled Pinned Locked Moved Solved
Windows Problems
1
5
1.1k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    Szeraax
    last edited by Mar 16, 2018, 7:44 PM

    I’m writing a powershell script to use as a snapin. Works fine as user, works fine as admin, works fine as admin from a -noprofile, works fine from user as -noprofile. I get an error from the snapin when trying to load modules like Bitlocker, Microsoft.PowerShell.LocalAccounts, etc. This happens whether I use the module name, a command from within the module (get-localuser, get-bitlockervolume, etc.), or the full path to the module .psm1 file. I am using windows 10 1709.

    The error I get is: the specified module XXXXXX was not loaded because no valid module was found in any module directory
    Category info: ResourceUnavailable
    FullyqualifiedErrorID: Modules_ModuleNotFound

    1 Reply Last reply Reply Quote 0
    • S
      Szeraax
      last edited by Szeraax Mar 20, 2018, 12:23 AM Mar 20, 2018, 4:20 AM

      Start-Transcript -Path C:\$([Environment]::Is64BitProcess).txt
      "Is 64?"
      [Environment]::Is64BitProcess
      $pwd
      if ([Environment]::Is64BitProcess)
      {
      	
      	$a = Get-BitLockerVolume -MountPoint C: 
      	$a | Out-File C:\file.txt -append
      }
      else
      {
      	$arguments = "-ExecutionPolicy Bypass -NoProfile -File temp.ps1 "
      	start-process C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe -ArgumentList $arguments -Wait -WorkingDirectory $pwd
      }
      

      I know its not pretty, but its a proof of running 64 powershell. In essence, I need the 32bit to launch a 64bit version of powershell. Can’t just run powershell.exe because it goes still into x86.

      1 Reply Last reply Reply Quote 1
      • S
        Szeraax
        last edited by Mar 16, 2018, 8:03 PM

        Might have found the key:

        ls C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\Modules\bitlocker\bitlocker.psm1
        ls C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\bitlocker\bitlocker.psm1

        Loading bitlocker normally uses system32. But SYSTEM on a 64 bit machine can’t find that path. Doing more testing now.

        1 Reply Last reply Reply Quote 0
        • S
          Szeraax
          last edited by Mar 16, 2018, 8:09 PM

          Hmmm, something funky.

          PS > ls C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\Modules\bitlocker\bitlocker.psm1
          

          Directory: C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\Modules\bitlocker
          Mode LastWriteTime Length Name
          -a---- 3/18/2017 2:59 PM 302052 bitlocker.psm1

          PS > Import-Module bitlocker
          

          WARNING: The names of some imported commands from the module ‘bitlocker’ include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

          PS > Get-BitLockerVolume -Mount C:
          

          Unable to find type [Microsoft.BitLocker.Structures.BitLockerVolumeLockStatus].
          At C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\Modules\bitlocker\bitlocker.psm1:483 char:37

          • … -eq [uint32][Microsoft.BitLocker.Structures.BitLockerVolumeLockStatus …
            +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          • CategoryInfo : InvalidOperation: (Microsoft.BitLo…olumeLockStatus:TypeName) [], RuntimeException
          • FullyQualifiedErrorId : TypeNotFound
          1 Reply Last reply Reply Quote 0
          • S
            Szeraax
            last edited by Mar 20, 2018, 3:33 AM

            AH HAAAAAAA

            "Is 64?"
            [Environment]::Is64BitProcess
            

            Output is

            Is 64?
            False
            

            This means that the 32bit fog service is running powershell snapins as a 32 version of powershell. If you’ve used powershell recently, you’ve almost certainly been using the 64 bit… cause 32 bit sucks. Doesn’t run modules hardly ever, etc. this is the cause of my problems. All I need to do is get the 32 bit process to run the 64 bit powershell and I win!

            Time to test.

            1 Reply Last reply Reply Quote 0
            • S
              Szeraax
              last edited by Szeraax Mar 20, 2018, 12:23 AM Mar 20, 2018, 4:20 AM

              Start-Transcript -Path C:\$([Environment]::Is64BitProcess).txt
              "Is 64?"
              [Environment]::Is64BitProcess
              $pwd
              if ([Environment]::Is64BitProcess)
              {
              	
              	$a = Get-BitLockerVolume -MountPoint C: 
              	$a | Out-File C:\file.txt -append
              }
              else
              {
              	$arguments = "-ExecutionPolicy Bypass -NoProfile -File temp.ps1 "
              	start-process C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe -ArgumentList $arguments -Wait -WorkingDirectory $pwd
              }
              

              I know its not pretty, but its a proof of running 64 powershell. In essence, I need the 32bit to launch a 64bit version of powershell. Can’t just run powershell.exe because it goes still into x86.

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              1 / 1
              • First post
                5/5
                Last post

              232

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project