Snapin Powershell 32/64 bit issue?



  • 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 
    

  • Moderator

    @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.



  • @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?



  • 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.


  • Moderator

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



  • @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
    
    

  • Moderator

    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.


Log in to reply
 

453
Online

39.4k
Users

11.1k
Topics

105.4k
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.