Hardcoding password to avoid password prompting

Dec 12, 2013 at 5:23 PM
Hi,

I have VM on amazaon EC2, and I'm trying to hardcode password to avoid password prompting, but I have no luck, boxstarter is restarting but no logging in back to continue.
This is my script, please let me know if this can be done.
    Import-Module Boxstarter.Chocolatey
    $password = ConvertTo-SecureString "password" -AsPlainText -Force
    $username = "user"
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    Install-BoxstarterPackage -PackageName DotNet4.5.1 -Credential $cred
    Install-BoxstarterPackage -PackageName VisualStudio2013Professional -Credential $cred
Thanks!!!
Coordinator
Dec 12, 2013 at 6:02 PM

Hmm. I’ll take a look at this on an EC2 instance. Couple questions:

1. What OS is your instance running?

2. Are you logged as $username when you run the script or is that a different user?

Thanks!

Dec 12, 2013 at 6:11 PM
Ohh, sorry, I forgot the context:

1 - Windows Server 2012
2 - I'm logged as $username.

Thanks for your quick answer!
Coordinator
Dec 13, 2013 at 7:19 AM
I wasn't able to reproduce your error on an EC2 instance. Can you send me a copy of $env:localAppData\Boxstarter\Boxstarter.log? In particular, it would be interesting to see if it contains an entry for:
[2013-12-13T05:19:11.7039118+00:00:::PID 2544] Boxstarter: writing restart file
[2013-12-13T05:19:11.9535323+00:00:::PID 2544] Boxstarter: Enabling Automatic Updates from Windows Update
[2013-12-13T05:19:12.0315103+00:00:::PID 2544] Boxstarter: UAC Enabled. Disabling...
[2013-12-13T05:19:12.0471490+00:00:::PID 2544] Boxstarter: Disabling UAC
[2013-12-13T05:19:12.0783615+00:00:::PID 2544] Boxstarter: Securely Storing WIN-442DVKE36V6\Administrator credentials for automatic logon
[2013-12-13T05:19:13.3107235+00:00:::PID 2544] Boxstarter: Logon Set
[2013-12-13T05:19:13.4043262+00:00:::PID 2544] Boxstarter: Restart Required. Restarting now...
Note "Boxstarter: Securely Storing WIN-442DVKE36V6\Administrator credentials for automatic logon". This would tell us if Boxstarter even tried to store the credentials and if so, did it store the correct user?

Thanks!
Dec 13, 2013 at 11:24 AM
Edited Dec 13, 2013 at 11:40 AM
Hey Matt, here is an extract of the log file, what I'm watching here, is that credentials are being stored for WIN-96Q9UI4G3RE\SYSTEM, and not for my user.
[2013-12-12T20:56:55.4874484+00:00:::PID 3056] Boxstarter: writing restart file
[2013-12-12T20:56:55.5498471+00:00:::PID 3056] Boxstarter: Enabling Automatic Updates from Windows Update
[2013-12-12T20:56:55.5966467+00:00:::PID 3056] Boxstarter: UAC Enabled. Disabling...
[2013-12-12T20:56:55.6278503+00:00:::PID 3056] Boxstarter: Disabling UAC
[2013-12-12T20:56:55.6902511+00:00:::PID 3056] Boxstarter: Securely Storing WIN-96Q9UI4G3RE\SYSTEM credentials for automatic logon
[2013-12-12T20:56:56.1114541+00:00:::PID 3056] Boxstarter: Logon Set
[2013-12-12T20:56:56.1426525+00:00:::PID 3056] Boxstarter: Restart Required. Restarting now...
BTW, I modified the script to get current user name:
Import-Module Boxstarter.Chocolatey
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$username = [Security.Principal.WindowsIdentity]::getcurrent().name
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
Install-BoxstarterPackage -PackageName DotNet4.5.1 -Credential $cred
Install-BoxstarterPackage -PackageName VisualStudio2013Professional -Credential $cred
Thanks for your time!
Coordinator
Dec 13, 2013 at 2:31 PM

Ah perfect. I have seen that before and I think I can get a fix in today for that. Thanks!

Dec 13, 2013 at 2:46 PM
Matt, thanks for your time and commitment with this project... it's a really good tool.
Coordinator
Dec 13, 2013 at 4:17 PM
Edited Dec 13, 2013 at 4:19 PM
I'm glad you find it useful!

The fix is up in version 2.2.15. Let me know if it fixes your issue or not.