Hi Sumit or Richard,
Thanks for started the topic and this is so much frustration on my end that the script worked about 1 month using packer v1.2.3. However, it's failing with the same error message, inRM connection err: http response error: 401 - invalid content type.
I did followed how Serge suggested at the other forum and what Summit suggested. I see that my packer box created the self signed cert based on the aws ec2 private ip addresses.
I confirmed the Test out the WINRM port 5986 as below.
Test-netconnection << private IP address >> -port 5986
ComputerName : 10.129.xxx.xxx
RemoteAddress : 10.129.xxx.xxx
RemotePort : 5986
InterfaceAlias :
SourceAddress :
TcpTestSucceeded : True
Or ran the below script to check
> $ipAddress = '10.129.xxx.xxx'
$password = 'xxxxxxx'
$splatParams = @{
ComputerName = $ipAddress
Authentication = 'Negotiate'
UseSSL = $true
Port = 5986
SessionOption = (New-PSSessionOption -SkipCACheck -SkipCNCheck)
Credential = [PSCredential]::new(
'Administrator',
(ConvertTo-SecureString -String $password -AsPlainText -Force)
)
ScriptBlock = {$env:COMPUTERNAME}
}
Invoke-Command @splatParams
which returns the packer box machine hostname correctly.
I'm still not able to resolve this issue though....is there anything you can think of? Packer version I'm currently using is v1.2.3 and v1.2.5 and both didn't work.
Also, I have check netstat -an 2 | findstr 5986 that the connection is established and the Administrator user got created from the user data.
As I am writing this message, it built fine but, in my second attempt, I'm back to 401, http response error: 401 - invalid content type, error again.
John.