WinRb / winrm-elevated

Runs PowerShell commands as elevated over Windows Remote Management (WinRM) via a scheduled task
Apache License 2.0
27 stars 17 forks source link

500 Error in EC2 #20

Closed jdgoins closed 7 years ago

jdgoins commented 7 years ago

@mwrock I mentioned this to you at ChefConf today.

I'm having an issue with elevated mode when I use the ec2 kitchen driver. A connection establishes properly when running normally, but not when I add elevated: true to my kitchen.yml file. I receive a 500 error reporting a bad response. This is running as part of my Chef Workflow pipeline. The Chef version, resource, and output are below.

$ chef --version
Chef Development Kit Version: 1.3.43
chef-client version: 12.19.36
delivery version: master (dd319aa632c2f550c92a2172b9d1226478fea997)
berks version: 5.6.4
kitchen version: 1.16.0
delivery_test_kitchen 'ec2_kitchen_test' do
    yaml '.kitchen.ec2.yml'
    driver 'ec2'
    options '--log-level=debug'
    repo_path delivery_workspace_repo
    action [:test, :destroy]
  end
Starting job on builder automate-runner-2.company.com at 2017-05-24T16:49:50-04:00.
Command: delivery job acceptance smoke --server automate.company.com --user builder --ent enterprise --org delivery --project lib_test_cookbook --for master --change-id 8819ab64-881e-4fda-9cf6-7c89d36cb1de --shasum 8e5a77c204a29657d44e3e5a9f3d06e2f9334771 --git-url ssh://builder@enterprise@automate.company.com:8989/enterprise/delivery/lib_test_cookbook
Chef Delivery
Starting job for lib_test_cookbook acceptance smoke
Creating workspace in /var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke
Cloning repository, and merging 8e5a77c204a29657d44e3e5a9f3d06e2f9334771 to master
Configuring the job
Running the job
Setting up the builder
[2017-05-24T16:49:56-04:00] WARN: Ohai::Config[:disabled_plugins] is set. Ohai::Config[:disabled_plugins] is deprecated and will be removed in future releases of ohai. Use ohai.disabled_plugins in your configuration file to configure :disabled_plugins for ohai.
[2017-05-24T16:49:57-04:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.19.36
[2017-05-24T16:49:57-04:00] INFO: *** Chef 12.19.36 ***
[2017-05-24T16:49:57-04:00] INFO: Platform: x86_64-linux
[2017-05-24T16:49:57-04:00] INFO: Chef-client pid: 9326
[2017-05-24T16:49:58-04:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/automate-runner-2.company.com
[2017-05-24T16:49:58-04:00] INFO: Setting the run_list to [#<Chef::RunList::RunListItem:0x0000000223f058 @version=nil, @type=:recipe, @name="build_cookbook::default">] from CLI options
[2017-05-24T16:49:58-04:00] INFO: Run List is [recipe[build_cookbook::default]]
[2017-05-24T16:49:58-04:00] INFO: Run List expands to [build_cookbook::default]
[2017-05-24T16:49:58-04:00] INFO: Starting Chef Run for automate-runner-2.company.com
[2017-05-24T16:49:58-04:00] INFO: Running start handlers
[2017-05-24T16:49:58-04:00] INFO: Start handlers complete.
[2017-05-24T16:49:58-04:00] INFO: HTTP Request Returned 404 Not Found: Object not found: 
resolving cookbooks for run list: ["build_cookbook::default"]
[2017-05-24T16:49:58-04:00] INFO: Loading cookbooks [build_cookbook@0.1.0, delivery-truck@2.3.2, delivery-sugar@1.5.2]
Synchronizing Cookbooks:
  - build_cookbook (0.1.0)
  - delivery-truck (2.3.2)
  - delivery-sugar (1.5.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: delivery-truck::default
  * chef_gem[knife-supermarket] action install[2017-05-24T16:49:59-04:00] INFO: Processing chef_gem[knife-supermarket] action install (delivery-truck::default line 27)
 (skipped due to only_if)
  * log[notify_user_about_supermarket_gem] action nothing[2017-05-24T16:49:59-04:00] INFO: Processing log[notify_user_about_supermarket_gem] action nothing (delivery-truck::default line 38)
 (skipped due to action :nothing)
[2017-05-24T16:49:59-04:00] INFO: Chef Run complete in 0.414133293 seconds

Running handlers:
[2017-05-24T16:49:59-04:00] INFO: Running report handlers
Running handlers complete
[2017-05-24T16:49:59-04:00] INFO: Report handlers complete
Chef Client finished, 0/2 resources updated in 02 seconds
Running phase smoke
[2017-05-24T16:50:00-04:00] WARN: Ohai::Config[:disabled_plugins] is set. Ohai::Config[:disabled_plugins] is deprecated and will be removed in future releases of ohai. Use ohai.disabled_plugins in your configuration file to configure :disabled_plugins for ohai.
[2017-05-24T16:50:00-04:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.19.36
[2017-05-24T16:50:00-04:00] INFO: *** Chef 12.19.36 ***
[2017-05-24T16:50:00-04:00] INFO: Platform: x86_64-linux
[2017-05-24T16:50:00-04:00] INFO: Chef-client pid: 9614
[2017-05-24T16:50:03-04:00] INFO: Setting the run_list to [#<Chef::RunList::RunListItem:0x00000003bafc40 @version=nil, @type=:recipe, @name="build_cookbook::smoke">] from CLI options
[2017-05-24T16:50:03-04:00] INFO: Run List is [recipe[build_cookbook::smoke]]
[2017-05-24T16:50:03-04:00] INFO: Run List expands to [build_cookbook::smoke]
[2017-05-24T16:50:03-04:00] INFO: Starting Chef Run for automate-runner-2.company.com
[2017-05-24T16:50:03-04:00] INFO: Running start handlers
[2017-05-24T16:50:03-04:00] INFO: Start handlers complete.
[2017-05-24T16:50:03-04:00] INFO: HTTP Request Returned 404 Not Found: Object not found: 
resolving cookbooks for run list: ["build_cookbook::smoke"]
[2017-05-24T16:50:03-04:00] INFO: Loading cookbooks [build_cookbook@0.1.0, delivery-truck@2.3.2, delivery-sugar@1.5.2]
Synchronizing Cookbooks:
  - build_cookbook (0.1.0)
  - delivery-truck (2.3.2)
  - delivery-sugar (1.5.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: build_cookbook::smoke
  * delivery_test_kitchen[ec2_kitchen_test] action test[2017-05-24T16:50:03-04:00] INFO: Processing delivery_test_kitchen[ec2_kitchen_test] action test (build_cookbook::smoke line 9)

  Recipe: <Dynamically Defined Resource>
    * chef_gem[kitchen-ec2] action install[2017-05-24T16:50:04-04:00] INFO: Processing chef_gem[kitchen-ec2] action install (dynamically defined)
 (up to date)
    * directory[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.aws] action create[2017-05-24T16:50:04-04:00] INFO: Processing directory[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.aws] action create (dynamically defined)
 (up to date)
    * directory[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.ssh] action create[2017-05-24T16:50:04-04:00] INFO: Processing directory[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.ssh] action create (dynamically defined)
 (up to date)
    * file[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.aws/credentials] action create[2017-05-24T16:50:04-04:00] INFO: Processing file[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.aws/credentials] action create (dynamically defined)
 (up to date)
    * file[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.ssh/REDACTED.pem] action create[2017-05-24T16:50:04-04:00] INFO: Processing file[/var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/cache/.ssh/REDACTED.pem] action create (dynamically defined)
 (up to date)
-----> Starting Kitchen (v1.16.0)
D      Berksfile found at /var/opt/delivery/workspace/automate.company.com/enterprise/delivery/lib_test_cookbook/master/acceptance/smoke/repo/Berksfile, loading Berkshelf
D      Berkshelf 5.6.4 library loaded
D      winrm requested, loading winrm gem (["~> 2.0"])
D      winrm is loaded.
D      winrm-fs requested, loading winrm-fs gem (["~> 1.0"])
D      winrm-fs is loaded.
D      winrm-elevated requested, loading winrm-elevated gem (["~> 1.0"])
D      winrm-elevated is loaded.
-----> Cleaning up any prior instances of <default-windows-2012r2>
-----> Destroying <default-windows-2012r2>...
       Finished destroying <default-windows-2012r2> (0m0.00s).
-----> Testing <default-windows-2012r2>
-----> Creating <default-windows-2012r2>...
D      platform name windows-2012r2 appears to be a standard platform. Searching for windows 2012r2 ...
D      Searching for images matching {"owner-alias"=>"amazon", "name"=>["Windows_Server-2012-R2_RTM-English-*-Base-*", "Windows_Server-2012-R2_SP*-English-*-Base-*"]} ...
D      Search returned 3 images:
D      - Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.05.10: Detected windows 2012r2rtm x86_64.  Architecture: x86_64, Virtualization: hvm, Storage: ebs gp2, Created: 2017-05-11T06:32:05.000Z
D      - Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.04.12: Detected windows 2012r2rtm x86_64.  Architecture: x86_64, Virtualization: hvm, Storage: ebs gp2, Created: 2017-04-23T03:30:51.000Z
D      - Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.03.15: Detected windows 2012r2rtm x86_64.  Architecture: x86_64, Virtualization: hvm, Storage: ebs gp2, Created: 2017-03-15T03:54:58.000Z
D      Image for default-windows-2012r2: Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.05.10.  Architecture: x86_64, Virtualization: hvm, Storage: ebs gp2, Created: 2017-05-11T06:32:05.000Z
       Detected platform: windows version 2012r2rtm on x86_64. Instance Type: t2.small. Default username: administrator (default).
D      No SSH username specified: using default username administrator  for image ami-3189ec51, which we detected as windows 2012r2rtm x86_64.
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

D      Creating EC2 instance in region us-west-2 with properties:
D      - instance_type = "t2.small"
D      - ebs_optimized = false
D      - image_id = "ami-3189ec51"
D      - key_name = "REDACTED"
D      - subnet_id = "subnet-REDACTED"
D      - private_ip_address = nil
D      - placement = {:availability_zone=>"us-west-2a", :tenancy=>"default"}
D      - security_group_ids = ["sg-REDACTED"]
REDACTED
       Instance <i-0b1e2d1939e5f8c11> requested.
       Polling AWS for existence, attempt 0...
       Attempting to tag the instance, 0 retries
       EC2 instance <i-0b1e2d1939e5f8c11> created.
       Waited 0/300s for instance <i-0b1e2d1939e5f8c11> volumes to be ready.
       Waited 0/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 5/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 10/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 15/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 20/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 25/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 30/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 35/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 40/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 45/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 50/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 55/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 60/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 65/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 70/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 75/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 80/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 85/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 90/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 95/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 100/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
       Waited 105/300s for instance <i-0b1e2d1939e5f8c11> to become ready.
D      Console output: --- 
2017/05/24 20:51:45Z: EC2ConfigMonitorState: 0
2017/05/24 20:51:45Z: Windows sysprep configuration complete.
2017/05/24 20:51:46Z: AMI Origin Version: 2017.05.10
2017/05/24 20:51:46Z: AMI Origin Name: Windows_Server-2012-R2_RTM-English-64Bit-Base
2017/05/24 20:51:46Z: OS: Microsoft Windows NT 6.3.9600
2017/05/24 20:51:46Z: OsVersion: 6.3
2017/05/24 20:51:46Z: OsProductName: Windows Server 2012 R2 Standard
2017/05/24 20:51:46Z: OsBuildLabEx: 9600.18685.amd64fre.winblue_ltsb.170427-1704
2017/05/24 20:51:46Z: Language: en-US
2017/05/24 20:51:46Z: TimeZone: Coordinated Universal Time
2017/05/24 20:51:46Z: Offset: UTC 00:00:00
2017/05/24 20:51:46Z: EC2 Agent: Ec2Config service v4.9.1775
2017/05/24 20:51:47Z: Message: Waiting for meta-data accessibility...
2017/05/24 20:51:47Z: Message: Meta-data is now available.
2017/05/24 20:51:48Z: AMI-ID: ami-3189ec51
2017/05/24 20:51:48Z: Instance-ID: i-0b1e2d1939e5f8c11
2017/05/24 20:51:51Z: Driver: AWS PV Network Device v7.4.6.0
2017/05/24 20:51:51Z: Driver: AWS PV Storage Host Adapter v7.4.6.5
2017/05/24 20:51:51Z: Ec2SetPassword: Enabled
2017/05/24 20:51:51Z: RDPCERTIFICATE-SUBJECTNAME: WIN-LSJU57S546N
2017/05/24 20:51:51Z: RDPCERTIFICATE-THUMBPRINT: 10A7543B7475885F5FF48A5A91A41CAF666C322B
2017/05/24 20:51:54Z: Username: Administrator
2017/05/24 20:51:54Z: Password: <Password>
A3B/QRktGOo2lzNXy0dKyah4jJLnpOCPoGPg0Qyb7dDxVrDp+QrOqE0M47pe74rDsSv4E4KZsYNubw/VKAXeolmhcfJ2KA03L69U8oZILegmafaSmSB7HcJki+PUBwPmLqcEr2dtXrF5gnuhWOosBaV3/XgLSiZkLol/XOnwWBvGAN34MQwAPKLUM5eExXlxykzkyzj3h477/qYst9tab1FXiMApKKn9RNd87R/tOC+5vjZLrMQZ5djkDYO0glv+edksqiKeRyghHi73A707khIFUqQWUQ2IWShDiHHSzMsaqKoRYmzpbCGHZEr5mlt9Sy7VRlrgPvYPISAjA6yurQ==
</Password>
2017/05/24 20:51:55Z: Message: Windows is Ready to use

       Waited 0/300s for instance <i-0b1e2d1939e5f8c11> to fetch windows admin password.
       Retrieved Windows password for instance <i-0b1e2d1939e5f8c11>.
       EC2 instance <i-0b1e2d1939e5f8c11> ready.
D      [WinRM] <{:endpoint=>"http://10.0.224.72:5985/wsman", :user=>"administrator", :password=>"3GzGSe*c*S", :transport=>:negotiate, :elevated_username=>"administrator", :elevated_password=>"3GzGSe*c*S", :no_ssl_peer_verification=>true, :disable_sspi=>false, :basic_auth_only=>false}> (Write-Host '[WinRM] Established
')
D      [WinRM] opening remote shell on http://10.0.224.72:5985/wsman
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x00000005a2e928 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><Version N=\"protocolversion\">2.2</Version><Version N=\"PSVersion\">2.0</Version><Version N=\"SerializationVersion\">1.1.0.1</Version></MS></Obj>", @destination=1, @type=65538, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x00000005d8fc70 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><Obj N=\"ApplicationPrivateData\" RefId=\"1\"><TN RefId=\"0\"><T>System.Management.Automation.PSPrimitiveDictionary</T><T>System.Collections.Hashtable</T><T>System.Object</T></TN><DCT><En><S N=\"Key\">DebugMode</S><I32 N=\"Value\">1</I32></En><En><S N=\"Key\">DebugStop</S><B N=\"Value\">false</B></En><En><S N=\"Key\">PSVersionTable</S><Obj N=\"Value\" RefId=\"2\"><TNRef RefId=\"0\" /><DCT><En><S N=\"Key\">PSVersion</S><Version N=\"Value\">2.0</Version></En><En><S N=\"Key\">PSCompatibleVersions</S><Obj N=\"Value\" RefId=\"3\"><TN RefId=\"1\"><T>System.Version[]</T><T>System.Array</T><T>System.Object</T></TN><LST><Version>1.0</Version><Version>2.0</Version><Version>3.0</Version><Version>4.0</Version></LST></Obj></En><En><S N=\"Key\">BuildVersion</S><Version N=\"Value\">6.3.9600.17400</Version></En><En><S N=\"Key\">CLRVersion</S><Version N=\"Value\">4.0.30319.42000</Version></En><En><S N=\"Key\">WSManStackVersion</S><Version N=\"Value\">3.0</Version></En><En><S N=\"Key\">PSRemotingProtocolVersion</S><Version N=\"Value\">2.2</Version></En><En><S N=\"Key\">SerializationVersion</S><Version N=\"Value\">1.1.0.1</Version></En></DCT></Obj></En><En><S N=\"Key\">DebugBreakpointCount</S><I32 N=\"Value\">0</I32></En></DCT></Obj></MS></Obj>", @destination=1, @type=135177, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x00000006054938 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I32 N=\"RunspaceState\">2</I32></MS></Obj>", @destination=1, @type=135173, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] remote shell created with shell_id: C1D51546-6800-4C55-B151-7BD6BE846367
D      [WinRM] Command created for $env:temp
if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: E7463BDB-92F1-4FA0-9516-2FBE0A5AFB0F
D      [WinRM] creating command_id: E7463BDB-92F1-4FA0-9516-2FBE0A5AFB0F on shell_id C1D51546-6800-4C55-B151-7BD6BE846367
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: E7463BDB-92F1-4FA0-9516-2FBE0A5AFB0F on shell_id C1D51546-6800-4C55-B151-7BD6BE846367
D      creating hash for file c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1
D      Running check_files.ps1
D      [WinRM] opening remote shell on http://10.0.224.72:5985/wsman
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x007f1430580cc8 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><Version N=\"protocolversion\">2.2</Version><Version N=\"PSVersion\">2.0</Version><Version N=\"SerializationVersion\">1.1.0.1</Version></MS></Obj>", @destination=1, @type=65538, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x007f1430537dc0 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><Obj N=\"ApplicationPrivateData\" RefId=\"1\"><TN RefId=\"0\"><T>System.Management.Automation.PSPrimitiveDictionary</T><T>System.Collections.Hashtable</T><T>System.Object</T></TN><DCT><En><S N=\"Key\">DebugMode</S><I32 N=\"Value\">1</I32></En><En><S N=\"Key\">DebugStop</S><B N=\"Value\">false</B></En><En><S N=\"Key\">PSVersionTable</S><Obj N=\"Value\" RefId=\"2\"><TNRef RefId=\"0\" /><DCT><En><S N=\"Key\">PSVersion</S><Version N=\"Value\">2.0</Version></En><En><S N=\"Key\">PSCompatibleVersions</S><Obj N=\"Value\" RefId=\"3\"><TN RefId=\"1\"><T>System.Version[]</T><T>System.Array</T><T>System.Object</T></TN><LST><Version>1.0</Version><Version>2.0</Version><Version>3.0</Version><Version>4.0</Version></LST></Obj></En><En><S N=\"Key\">BuildVersion</S><Version N=\"Value\">6.3.9600.17400</Version></En><En><S N=\"Key\">CLRVersion</S><Version N=\"Value\">4.0.30319.42000</Version></En><En><S N=\"Key\">WSManStackVersion</S><Version N=\"Value\">3.0</Version></En><En><S N=\"Key\">PSRemotingProtocolVersion</S><Version N=\"Value\">2.2</Version></En><En><S N=\"Key\">SerializationVersion</S><Version N=\"Value\">1.1.0.1</Version></En></DCT></Obj></En><En><S N=\"Key\">DebugBreakpointCount</S><I32 N=\"Value\">0</I32></En></DCT></Obj></MS></Obj>", @destination=1, @type=135177, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x007f1430168488 @data="\xEF\xBB\xBF<Obj RefId=\"0\"><MS><I32 N=\"RunspaceState\">2</I32></MS></Obj>", @destination=1, @type=135173, @pipeline_id="00000000-0000-0000-0000-000000000000", @runspace_pool_id="00000000-0000-0000-0000-000000000000">
D      [WinRM] remote shell created with shell_id: 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Command created for $hash_file = @{
  "4e710c89ff1036476a09ef8fdb67cf10" = @{
    "target" = "c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1";
    "src_basename" = "winrm-elevated-shell20170524-9898-vg3nwips1";
    "dst" = "c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1"
  }
}

Function Cleanup($disposable) {
  if (($disposable -ne $null) -and ($disposable.GetType().GetMethod("Dispose") -ne $null)) {
    $disposable.Dispose()
  }
}

Function Check-Files($h) {
  return $h.GetEnumerator() | ForEach-Object {
    $dst = Unresolve-Path $_.Value.target
    $dst_changed = $false
    if(Test-Path $dst -PathType Container) {
      $dst_changed = $true
      $dst = Join-Path $dst $_.Value.src_basename
    }
    New-Object psobject -Property @{
      chk_exists = ($exists = Test-Path $dst -PathType Leaf)
      src_md5 = ($sMd5 = $_.Key)
      dst_md5 = ($dMd5 = if ($exists) { Get-MD5Sum $dst } else { $null })
      chk_dirty = ($dirty = if ($sMd5 -ne $dMd5) { $true } else { $false })
      verifies = if ($dirty -eq $false) { $true } else { $false }
      target_is_folder = $dst_changed
    }
  } | Select-Object -Property chk_exists,src_md5,dst_md5,chk_dirty,verifies,target_is_folder
}

Function Get-MD5Sum($src) {
  Try {
    $c = [System.Security.Cryptography.MD5]::Create()
    $bytes = $c.ComputeHash(($in = (Get-Item $src).OpenRead()))
    return ([System.BitConverter]::ToString($bytes)).Replace("-", "").ToLower()
  } 
  Finally {
    Cleanup $c
    Cleanup $in
  }
}

Function Unresolve-Path($path) {
  if ($path -eq $null) {
    return $null
  }
  else {
    return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path)
  }
}

Check-Files $hash_file | ConvertTo-Csv -NoTypeInformation

if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: 944322CC-A92A-4BA4-8304-F2B202B313EB
D      [WinRM] creating command_id: 944322CC-A92A-4BA4-8304-F2B202B313EB on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: 944322CC-A92A-4BA4-8304-F2B202B313EB on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      Parsing CSV Response
D      "chk_exists","src_md5","dst_md5","chk_dirty","verifies","target_is_folder"
"False","4e710c89ff1036476a09ef8fdb67cf10",,"True","False","False"

D      Uploading /tmp/winrm-elevated-shell20170524-9898-vg3nwips1 to c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1
D      [WinRM] Command created for             $to = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1")
            $parent = Split-Path $to
            if(!(Test-path $parent)) { mkdir $parent | Out-Null }
            $fileStream = New-Object -TypeName System.IO.FileStream -ArgumentList @(
                $to,
                [system.io.filemode]::Create,
                [System.io.FileAccess]::Write,
                [System.IO.FileShare]::ReadWrite
            )

            # Powershell caches ScrpitBlocks in a dictionary
            # keyed on the script block text. Thats just great
            # unless the script is super large and called a gillion
            # times like we might do. In such a case it will saturate the
            # Large Object Heap and lead to Out Of Memory exceptions
            # for large files or folders. So we call the internal method
            # ClearScriptBlockCache to clear it.
            $bindingFlags= [Reflection.BindingFlags] "NonPublic,Static"
            $method = [scriptblock].GetMethod("ClearScriptBlockCache", $bindingFlags)

if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: C70341CF-DE37-440A-97AC-6E73E860EAB3
D      [WinRM] creating command_id: C70341CF-DE37-440A-97AC-6E73E860EAB3 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: C70341CF-DE37-440A-97AC-6E73E860EAB3 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Command created for             if($method) { $method.Invoke($Null, $Null) }
            $bytes=[Convert]::FromBase64String('JGVudjp0ZW1wPSdDOlxVc2Vyc1xBRE1JTkl+MVxBcHBEYXRhXExvY2FsXFRlbXAnO1dyaXRlLUhvc3QgJ1tXaW5STV0gRXN0YWJsaXNoZWQKJw0KJEhvc3QuU2V0U2hvdWxkRXhpdCgkTEFTVEVYSVRDT0RFKQ==')
            $fileStream.Write($bytes, 0, $bytes.length)

if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: 66572F93-2A72-4392-BD42-0BBB678C1197
D      [WinRM] creating command_id: 66572F93-2A72-4392-BD42-0BBB678C1197 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: 66572F93-2A72-4392-BD42-0BBB678C1197 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Command created for $fileStream.Dispose()
if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: B0DAC595-2DEE-401F-96DF-F73A03E61194
D      [WinRM] creating command_id: B0DAC595-2DEE-401F-96DF-F73A03E61194 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: B0DAC595-2DEE-401F-96DF-F73A03E61194 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      Finished uploading /tmp/winrm-elevated-shell20170524-9898-vg3nwips1 to c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1 (0.156 KB over 1 chunks) in (0m0.61s)
D      No remote files to extract, skipping
D      Uploaded 1 items dirty_check: (0m0.45s) stream_files: (0m0.61s) extract: (0m0.00s) 
D      [WinRM] Command created for $username = 'administrator'
$password = '3GzGSe*c*S'
$script_file = 'c:/windows/temp/winrm-elevated-shell-bc62f5c7-2f06-4e3d-ac8c-a4f1f6e55e39.ps1'

$interactive = 'false'
$pass_to_use = $password
$logon_type = 1
$logon_type_xml = "<LogonType>Password</LogonType>"
if($pass_to_use.length -eq 0) {
  $pass_to_use = $null
  $logon_type = 5
  $logon_type_xml = ""
}
if($interactive -eq 'true') {
  $logon_type = 3
  $logon_type_xml = "<LogonType>InteractiveTokenOrPassword</LogonType>"
}

$task_name = "WinRM_Elevated_Shell"
$out_file = [System.IO.Path]::GetTempFileName()
$err_file = [System.IO.Path]::GetTempFileName()

$task_xml = @'
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <Principals>
    <Principal id="Author">
      <UserId>{username}</UserId>
      {logon_type}
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT24H</ExecutionTimeLimit>
    <Priority>4</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>cmd</Command>
      <Arguments>{arguments}</Arguments>
    </Exec>
  </Actions>
</Task>
'@

$arguments = "/c powershell.exe -executionpolicy bypass -NoProfile -File $script_file &gt; $out_file 2&gt;$err_file"

$task_xml = $task_xml.Replace("{arguments}", $arguments)
$task_xml = $task_xml.Replace("{username}", $username)
$task_xml = $task_xml.Replace("{logon_type}", $logon_type_xml)

$schedule = New-Object -ComObject "Schedule.Service"
$schedule.Connect()
$task = $schedule.NewTask($null)
$task.XmlText = $task_xml
$folder = $schedule.GetFolder("\")
$folder.RegisterTaskDefinition($task_name, $task, 6, $username, $pass_to_use, $logon_type, $null) | Out-Null

$registered_task = $folder.GetTask("\$task_name")
$registered_task.Run($null) | Out-Null

$timeout = 10
$sec = 0
while ( (!($registered_task.state -eq 4)) -and ($sec -lt $timeout) ) {
  Start-Sleep -s 1
  $sec++
}

function SlurpOutput($file, $cur_line, $out_type) {
  if (Test-Path $file) {
    get-content $file | select -skip $cur_line | ForEach {
      $cur_line += 1
      if ($out_type -eq 'err') {
        $host.ui.WriteErrorLine("$_")
      } else {
        $host.ui.WriteLine("$_")
      }
    }
  }
  return $cur_line
}

$err_cur_line = 0
$out_cur_line = 0
do {
  Start-Sleep -m 100
  $out_cur_line = SlurpOutput $out_file $out_cur_line 'out'
  $err_cur_line = SlurpOutput $err_file $err_cur_line 'err'
} while (!($registered_task.state -eq 3))

# We'll make a best effort to clean these files
# But a reboot could possibly end the task while the process
# still runs and locks the file. If we can't delete we don't want to fail
try { Remove-Item $out_file -ErrorAction Stop } catch {}
try { Remove-Item $err_file -ErrorAction Stop } catch {}
try { Remove-Item $script_file -ErrorAction Stop } catch {}

$exit_code = $registered_task.LastTaskResult
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null

exit $exit_code

if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: 779852EA-73D2-4914-8389-15E5FCC6DB66
D      [WinRM] creating command_id: 779852EA-73D2-4914-8389-15E5FCC6DB66 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
D      [WinRM] Waiting for output...
D      [WinRM] cleaning up command_id: 779852EA-73D2-4914-8389-15E5FCC6DB66 on shell_id 50C4B56A-F24F-44EF-B95E-282CB7D8061E
       [WinRM] 500 returned in cleanup with error: Bad HTTP response returned from server. Body(if present): (500).
-----> Destroying <default-windows-2012r2>...
D      [WinRM] reusing existing connection <{:endpoint=>"http://10.0.224.72:5985/wsman", :user=>"administrator", :password=>"3GzGSe*c*S", :transport=>:negotiate, :elevated_username=>"administrator", :elevated_password=>"3GzGSe*c*S", :no_ssl_peer_verification=>true, :disable_sspi=>false, :basic_auth_only=>false}>
D      ------Exception-------
D      Class: Kitchen::ActionFailed
D      Message: 1 actions failed.
>>>>>>     Failed to complete #destroy action: [Bad HTTP response returned from server. Body(if present): (500).] on default-windows-2012r2
D      ----------------------
D      ------Backtrace-------
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:183:in `report_errors'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:174:in `run_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command/test.rb:42:in `block in call'
D      /opt/chefdk/embedded/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command/test.rb:38:in `call'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/cli.rb:53:in `perform'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/cli.rb:234:in `test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/cli.rb:334:in `invoke_task'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/bin/kitchen:13:in `block in <top (required)>'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/errors.rb:171:in `with_friendly_errors'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/bin/kitchen:13:in `<top (required)>'
D      /opt/chefdk/bin/kitchen:21:in `load'
D      /opt/chefdk/bin/kitchen:21:in `<main>'
D      ----End Backtrace-----
D      -Composite Exception--
D      Class: Kitchen::ActionFailed
D      Message: Failed to complete #destroy action: [Bad HTTP response returned from server. Body(if present): (500).] on default-windows-2012r2
D      ----------------------
D      ------Backtrace-------
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:90:in `raise_transport_error'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:54:in `raise_if_error'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:36:in `parse_to_xml'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/transport.rb:186:in `send_request'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/shells/power_shell.rb:44:in `close_shell'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/shells/base.rb:90:in `close'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/transport/winrm.rb:87:in `close'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/kitchen-ec2-1.3.2/lib/kitchen/driver/ec2.rb:235:in `destroy'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `block in perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:527:in `synchronize_or_call'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:489:in `block in action'
D      /opt/chefdk/embedded/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:488:in `action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:447:in `destroy_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:359:in `block in transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:358:in `each'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:358:in `transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:168:in `destroy'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:192:in `ensure in test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:192:in `test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:197:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:197:in `run_action_in_thread'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/logging-2.2.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
D      ----End Backtrace-----
D      ---Nested Exception---
D      Class: Kitchen::ActionFailed
D      Message: Failed to complete #destroy action: [Bad HTTP response returned from server. Body(if present): (500).]
D      ----------------------
D      ------Backtrace-------
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:90:in `raise_transport_error'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:54:in `raise_if_error'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/response_handler.rb:36:in `parse_to_xml'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/http/transport.rb:186:in `send_request'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/shells/power_shell.rb:44:in `close_shell'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/winrm-2.2.1/lib/winrm/shells/base.rb:90:in `close'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/transport/winrm.rb:87:in `close'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/kitchen-ec2-1.3.2/lib/kitchen/driver/ec2.rb:235:in `destroy'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `block in perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:527:in `synchronize_or_call'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:489:in `block in action'
D      /opt/chefdk/embedded/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:488:in `action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:460:in `perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:447:in `destroy_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:359:in `block in transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:358:in `each'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:358:in `transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:168:in `destroy'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:192:in `ensure in test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/instance.rb:192:in `test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:197:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:197:in `run_action_in_thread'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/test-kitchen-1.16.0/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/logging-2.2.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
D      ----End Backtrace-----
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #destroy action: [Bad HTTP response returned from server. Body(if present): (500).] on default-windows-2012r2
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
mwrock commented 7 years ago

Thanks for following up with the issue @jdgoins! I'm not able to replicate your error. I'm using the same AMI, instance size as well as TK and winrm versions. Hard to say what the difference might be and the fact that it works without elevated eliminates most other possible culprits like proxy interference.

It may help to RDP to the instance and see if you can find anything in the event logs that might prove helpful. Also check to see if you see a schedule task created called WinRM_elevated_shell. If so, does it look like it was ever run? Look at the script file the task loads and see if the contents of that file look off.

Another thing to look at is whether the command that the task is running would cause a reboot. I just ask because depending on timing, that could be a problem.

jdgoins commented 7 years ago

Closed. Issue was on our end.