Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Last active September 16, 2016 11:29
Show Gist options
  • Save chgeuer/a8b5327bbeee035d839cdf6d3bdd9e19 to your computer and use it in GitHub Desktop.
Save chgeuer/a8b5327bbeee035d839cdf6d3bdd9e19 to your computer and use it in GitHub Desktop.

Debugging packer by logging to to the currently provisioned VM

  • Open the current packer log file in the TEMP directory, something like %TEMP%packer-log722498239, in a text editor.
  • Find the string \"osProfile\":{\"adminPassword\":\". There you can see your admin password, something like 9RQF11ZTRL1W3YfQN3LpJ7Jib9gfkgXa...
  • Figure out the public IP address of your Windows VM, for example through resources.azure.com.
  • Run the following:
$address = "13.81.111.231"
$pass = "9RQF11ZTRL1W3YfQN3LpJ7Jib9gfkgXa"

$user = "packer"
$cred = New-Object System.Management.Automation.PSCredential($user, ($pass | ConvertTo-SecureString -asPlainText -Force))
$session = New-PSSession -ConnectionUri "https://$($address):5986/WSMAN" -Credential $cred -SessionOption $(New-PSSessionOption -SkipCNCheck -SkipCACheck)

Invoke-Command -Session $session -ScriptBlock { Get-ChildItem C:\ } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment