Virtualbox & WinRM - invalid 401 error

52 views
Skip to first unread message

Alexander Robinson

unread,
Oct 15, 2020, 1:52:46 PM10/15/20
to Packer
Hi Packer Group!

First off I am running Packer 1.6.4 and Virtualbox 6.1. I'm working off of a Ubuntu18.04 machine. I'm using the JSON and autounattend XML that I've attached to this message.

 I've tested various versions of enabling WinRM manually on the VM once it's up, but I can't get past this invalid content type error and I've been poking at this for a while.

 Any help would be appreciated as I just want to get it to connect to finish the packer run so I can save the VM. Thanks!
autounattend.xml
vcrs_windows10.json

Megan Marsh

unread,
Oct 16, 2020, 6:18:21 PM10/16/20
to packe...@googlegroups.com
I'm not seeing your autounattend actually call your configure-winrm.ps1 script. That could be your issue.  Without knowing how you're configuring winrm, I'm not sure whether the options you've set are correct. Can you share the script?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/c948dfac-a354-4f6c-8e22-d272aa7817can%40googlegroups.com.

Alexander Robinson

unread,
Oct 19, 2020, 5:55:34 PM10/19/20
to packe...@googlegroups.com
attached is the script. Any additional help would be appreciated.

# Supress network location Prompt
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff" -Force

# Set network to private
$ifaceinfo = Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex $ifaceinfo.InterfaceIndex -NetworkCategory Private

# Set up WinRM and configure some things
winrm quickconfig -q
winrm s "winrm/config" '@{MaxTimeoutms="1800000"}'
winrm s "winrm/config/winrs" '@{MaxMemoryPerShellMB="2048"}'
winrm s "winrm/config/service" '@{AllowUnencrypted="true"}'
winrm s "winrm/config/service/auth" '@{Basic="true"}'

# Enable the WinRM Firewall rule, which will likely already be enabled due to the 'winrm quickconfig' command above
Enable-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)"

sc.exe config winrm start= auto

exit 0

You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/zEWZKrBIxFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAGPV1upn2%2BD_NNJbdGLpNJF%2B%3DAPo1PnSsZG1SGkhSmc4f3D%3DAw%40mail.gmail.com.

Megan Marsh

unread,
Oct 20, 2020, 12:25:36 PM10/20/20
to packe...@googlegroups.com
Okay that looks reasonable. Is it possible that capitalization matters, and the username "vcrs" versus "VCRS" is the issue?

Alexander Robinson

unread,
Oct 20, 2020, 2:53:27 PM10/20/20
to packe...@googlegroups.com
I just tried that and no change, still getting the 401 invalid content error after I manually run the PowerShell script. Not sure what else I'm doing wrong, lol.

Megan Marsh

unread,
Oct 20, 2020, 5:12:19 PM10/20/20
to packe...@googlegroups.com
So I can see in your autounattend that your user is a member of the Administrators group, which I think should be enough. I'd get onto the instance manually and check that the user has remote access permissions. This looks like a reasonable tutorial for that: http://woshub.com/powershell-remoting-via-winrm-for-non-admin-users/

I wonder if you have to have a password? Looks like you're trying to connect without one.

Alexander Robinson

unread,
Oct 23, 2020, 6:17:42 PM10/23/20
to packe...@googlegroups.com
Thank you for the help! 

I think it was the password missing that was the issue. It works now. Thanks again for your help!

On Tue, Oct 20, 2020 at 2:12 PM Megan Marsh <megan....@gmail.com> wrote:
So I can see in your autounattend that your user is a member of the Administrators group, which I think should be enough. I'd get onto the instance manually and check that the user has remote access permissions. This looks like a reasonable tutorial for that: http://woshub.com/powershell-remoting-via-winrm-for-non-admin-users/

I wonder if you have to have a password? Looks like you're trying to connect without one.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/zEWZKrBIxFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages