pixelmybit
pixelmybit

Reputation: 133

Powershell command-line with Autologon.exe

Has anyone made the 'Autologon.exe for Windows v3.10' work with PowerShell v5.1?

Execution 1:

As administrator the following is run:

.\Autologon.exe -n guest10 -d test.com -p Password1 -accepteula yes

Error 1:

enter image description here


Execution 2:

As administrator in powershell the following is run:

.\Autologon.exe guest10 test.com Password1

Error2: Nothing happens


Execution 3:

As administrator in powershell the following is run:

$obj=.\Autologon.exe
        $name ="guest10"
        $domain="test"
        $pass="Password1"
        & $obj $name $domain $pass

Error3:

The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.

Upvotes: 3

Views: 30811

Answers (3)

Bjorn Hamsterdam
Bjorn Hamsterdam

Reputation: 21

This worked for me:

Start-Process -FilePath  $exePath -ArgumentList "/accepteula", $user, $domain, $password -Wait

It's very picky about quote placement.

Upvotes: 2

mstrmke
mstrmke

Reputation: 1

As Stephan mentioned, however without args, here's how I did it and it worked perfectly.

Start-Process -FilePath ".\Autologon.exe" -ArgumentList '"/accepteula" username domain password' 

Upvotes: 0

henrycarteruk
henrycarteruk

Reputation: 13227

I generally use Start-Process with the ArgumentList parameter to run programs with arguments:

$autologon = "C:\folder\Autologon.exe"
$username = "guest10"
$domain = "domain"
$password = "Password1"

Start-Process $autologon -ArgumentList $username,$domain,$password

Or you can put them directly into the command:

Start-Process "C:\folder\Autologon.exe" -ArgumentList "guest10","domain","Password1"

Upvotes: 6

Related Questions