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

    Snapin Powershell 32/64 bit issue?

    Scheduled Pinned Locked Moved Solved
    Windows Problems
    4
    7
    2.2k
    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.
    • T
      Tywyn
      last edited by

      Hi there,

      we are setting several things via powershell snapin (IP-Adress, workgroup, adding a new user). Some things work, others (e.g. adding users ) do not.

      When I start the script locally on a machine with the powershell ISE 64 bit version everything works fine. When I start the same script with the Powershell ISE (X86), I get an error message, that the command New-LocalUser
      is not part of a commandlet or function.

      So, knowing, that some parts of the script are being processed when I let it run as a snapin from the fog-gui, but others are not (the addition of a new user) makes me wonder, whether snapins are being invokes with the 32-bit Version of Powershell, where the New-LocalUser is not available (for what reason ever).

      How do I explicitely invoke the 64 bit version?

      At the moment the call looks like this

      powershell.exe -ExecutionPolicy Bypass -NoProfile -File C3-327_Install.ps1 
      
      1 Reply Last reply Reply Quote 0
      • Q
        Quazz Moderator
        last edited by

        Try a direct call instead

        %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
        

        On 64bit systems this should be the 64 bit version (the 32bit version residing in SysWoW64) and on 32 bit versions it will be the 32 bit version.

        I would assume the cmdlets being available in 32bit on 32bit systems, but I have none to confirm this with currently.

        1 Reply Last reply Reply Quote 0
        • T
          Tywyn
          last edited by

          @quazz said in Snapin Powershell 32/64 bit issue?:

          %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

          Tried it, but strangely it does not find the New-LocalUser command. Here is the output, when I invoke it as a snapin (script works fine when invoked in the Powershell ISE on the machine itself:

          **********************
          Start der Windows PowerShell-Aufzeichnung
          Startzeit: 20171130095507
          Benutzername: C3-RAUM327\SYSTEM
          RunAs-Benutzer: C3-RAUM327\SYSTEM
          Computer: C3-R327DOZENT (Microsoft Windows NT 10.0.14393.0)
          Hostanwendung: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoProfile -File C:\Program Files (x86)\FOG\tmp\C3-327_Install.ps1
          Prozess-ID: 7052
          PSVersion: 5.1.14393.1715
          PSEdition: Desktop
          PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.1715
          BuildVersion: 10.0.14393.1715
          CLRVersion: 4.0.30319.42000
          WSManStackVersion: 3.0
          PSRemotingProtocolVersion: 2.3
          SerializationVersion: 1.1.0.1
          **********************
          Die Aufzeichnung wurde gestartet. Die Ausgabedatei ist "C:\output.txt".
          Überprüfe Voraussetzungen.
          C:\Windows\system32\cscript.exe...
             -> Gefunden
          c:\Programme\Microsoft Office\Office16\ospp.vbs...
             -> Gefunden
          C:\Windows\system32\slmgr.vbs...
             -> Gefunden
          Starte Modifikationen
          Erstelle neuen Benutzer C3-R327DOZENT...
          New-LocalUser : Die Benennung "New-LocalUser" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder 
          eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern 
          enthalten), und wiederholen Sie den Vorgang.
          In C:\Program Files (x86)\FOG\tmp\C3-327_Install.ps1:142 Zeichen:5
          +     New-LocalUser $UserName -Password $UserPasswordEnc -AccountNeverE ...
          +     ~~~~~~~~~~~~~
              + CategoryInfo          : ObjectNotFound: (New-LocalUser:String) [], CommandNotFoundException
              + FullyQualifiedErrorId : CommandNotFoundException
          New-LocalUser : Die Benennung "New-LocalUser" wurde nicht als Name eines
          Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms
          erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt
          ist (sofern enthalten), und wiederholen Sie den Vorgang.
          In C:\Program Files (x86)\FOG\tmp\C3-327_Install.ps1:142 Zeichen:5
          +     New-LocalUser $UserName -Password $UserPasswordEnc -AccountNeverE ...
          +     ~~~~~~~~~~~~~
              + CategoryInfo          : ObjectNotFound: (New-LocalUser:String) [], Comma
             ndNotFoundException
              + FullyQualifiedErrorId : CommandNotFoundException
          
          
          Wayne WorkmanW 1 Reply Last reply Reply Quote 0
          • Wayne WorkmanW
            Wayne Workman @Tywyn
            last edited by

            @tywyn you realize that all windows snapins run as SYSTEM and not as administrator?

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
            Daily Clean Installation Results:
            https://fogtesting.fogproject.us/
            FOG Reporting:
            https://fog-external-reporting-results.fogproject.us/

            T 1 Reply Last reply Reply Quote 1
            • AvaryanA
              Avaryan
              last edited by

              You may have better luck using a .cmd file and using something like:

              net user <username> <password> /ADD
              

              I’ve seen similar issues posted regarding trying to do this via PowerShell as a snapin.

              1 Reply Last reply Reply Quote 1
              • T
                Tywyn @Wayne Workman
                last edited by Tywyn

                @wayne-workman
                Wayne, I was not aware of that.
                Does that mean, that SYSTEM does not have access to those commands (like New-LocalUser) at all?

                Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                • Wayne WorkmanW
                  Wayne Workman @Tywyn
                  last edited by Wayne Workman

                  @tywyn the largest difference is that SYSTEM is not allowed (by design) any interaction with the user or userspace at all. This probably also means the user’s account too. This is Microsoft’s design, not ours - and they went that route for security reasons.

                  When developing snapins, if your snapin will work manually but not as a fog snapin (and you’re sure you deployed the snapin correctly), you can normally assume the problem is because of the above.

                  Try what @Avaryan posted.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                  Daily Clean Installation Results:
                  https://fogtesting.fogproject.us/
                  FOG Reporting:
                  https://fog-external-reporting-results.fogproject.us/

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

                  144

                  Online

                  12.0k

                  Users

                  17.3k

                  Topics

                  155.2k

                  Posts
                  Copyright © 2012-2024 FOG Project