Created
March 15, 2017 22:09
-
-
Save michaeltlombardi/f5cca57377dbd0e512d993e03fc7a1d4 to your computer and use it in GitHub Desktop.
Functional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
driver: | |
name: vagrant | |
provisioner: | |
name: chef_zero | |
always_update_cookbooks: true | |
verifier: | |
name: inspec | |
transport: | |
name: winrm | |
elevated: true | |
platforms: | |
- name: mwrock/Windows2012R2 | |
driver: | |
provider: hyperv | |
memory: 2048 | |
cpus: 2 | |
vm_hostname: chef-fu | |
network: | |
- ["private_network", {bridge: "Guest"}] | |
suites: | |
- name: default | |
run_list: | |
- recipe[learn_chef_iis::default] | |
verifier: | |
inspec_tests: | |
- test/recipes | |
attributes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D, [2017-03-15T17:02:41.082067 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] BEGIN (vagrant plugin list) | |
D, [2017-03-15T17:02:42.117730 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] END (0m0.00s) | |
D, [2017-03-15T17:02:42.119755 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm requested, loading winrm gem (["~> 2.0"]) | |
D, [2017-03-15T17:02:42.453886 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm is loaded. | |
D, [2017-03-15T17:02:42.454924 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm-fs requested, loading winrm-fs gem (["~> 1.0"]) | |
D, [2017-03-15T17:02:42.534978 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm-fs is loaded. | |
D, [2017-03-15T17:02:42.537020 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm-elevated requested, loading winrm-elevated gem (["~> 1.0"]) | |
D, [2017-03-15T17:02:42.540982 #11376] DEBUG -- default-mwrock-Windows2012R2: winrm-elevated is loaded. | |
I, [2017-03-15T17:02:43.761441 #11376] INFO -- default-mwrock-Windows2012R2: -----> Creating <default-mwrock-Windows2012R2>... | |
D, [2017-03-15T17:02:43.763409 #11376] DEBUG -- default-mwrock-Windows2012R2: <default-mwrock-Windows2012R2> is synchronizing on Kitchen::Driver::Vagrant#create | |
D, [2017-03-15T17:02:43.764407 #11376] DEBUG -- default-mwrock-Windows2012R2: <default-mwrock-Windows2012R2> is messaging Kitchen::Driver::Vagrant#create | |
D, [2017-03-15T17:02:43.766439 #11376] DEBUG -- default-mwrock-Windows2012R2: Creating Vagrantfile for <default-mwrock-Windows2012R2> (C:/dev/AutoMon/chef-repo/.kitchen/kitchen-vagrant/kitchen-chef-repo-default-mwrock-Windows2012R2/Vagrantfile) | |
D, [2017-03-15T17:02:43.816134 #11376] DEBUG -- default-mwrock-Windows2012R2: ------------ | |
D, [2017-03-15T17:02:43.817630 #11376] DEBUG -- default-mwrock-Windows2012R2: Vagrant.configure("2") do |c| | |
D, [2017-03-15T17:02:43.818633 #11376] DEBUG -- default-mwrock-Windows2012R2: c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf") | |
D, [2017-03-15T17:02:43.820125 #11376] DEBUG -- default-mwrock-Windows2012R2: c.vm.box = "mwrock/Windows2012R2" | |
D, [2017-03-15T17:02:43.821125 #11376] DEBUG -- default-mwrock-Windows2012R2: c.vm.hostname = "chef-fu" | |
D, [2017-03-15T17:02:43.822126 #11376] DEBUG -- default-mwrock-Windows2012R2: c.vm.network(:private_network, {:bridge=>"Guest"}) | |
D, [2017-03-15T17:02:43.823129 #11376] DEBUG -- default-mwrock-Windows2012R2: c.vm.synced_folder ".", "/vagrant", disabled: true | |
D, [2017-03-15T17:02:43.823625 #11376] DEBUG -- default-mwrock-Windows2012R2: c.vm.provider :hyperv do |p| | |
D, [2017-03-15T17:02:43.824641 #11376] DEBUG -- default-mwrock-Windows2012R2: end | |
D, [2017-03-15T17:02:43.825125 #11376] DEBUG -- default-mwrock-Windows2012R2: end | |
D, [2017-03-15T17:02:43.827628 #11376] DEBUG -- default-mwrock-Windows2012R2: ------------ | |
D, [2017-03-15T17:02:43.828635 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] BEGIN (vagrant up --no-provision --provider hyperv) | |
I, [2017-03-15T17:02:46.792339 #11376] INFO -- default-mwrock-Windows2012R2: Bringing machine 'default' up with 'hyperv' provider... | |
I, [2017-03-15T17:02:46.836527 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Verifying Hyper-V is enabled... | |
I, [2017-03-15T17:02:47.381429 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Configured startup memory is 1024 | |
I, [2017-03-15T17:02:47.814718 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Importing a Hyper-V instance | |
I, [2017-03-15T17:02:49.275098 #11376] INFO -- default-mwrock-Windows2012R2: Looking for switch with name: Guest | |
I, [2017-03-15T17:02:49.275098 #11376] INFO -- default-mwrock-Windows2012R2: Found switch: Guest | |
I, [2017-03-15T17:02:49.275098 #11376] INFO -- default-mwrock-Windows2012R2: default: Cloning virtual hard drive... | |
I, [2017-03-15T17:02:49.275098 #11376] INFO -- default-mwrock-Windows2012R2: default: Creating and registering the VM... | |
I, [2017-03-15T17:03:57.245288 #11376] INFO -- default-mwrock-Windows2012R2: default: Successfully imported a VM with name: packer-hyperv-iso | |
I, [2017-03-15T17:03:58.901394 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Starting the machine... | |
I, [2017-03-15T17:04:00.360781 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Waiting for the machine to report its IP address... | |
I, [2017-03-15T17:04:00.360781 #11376] INFO -- default-mwrock-Windows2012R2: default: Timeout: 240 seconds | |
I, [2017-03-15T17:05:07.679859 #11376] INFO -- default-mwrock-Windows2012R2: default: IP: 172.31.165.253 | |
I, [2017-03-15T17:05:07.724858 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Waiting for machine to boot. This may take a few minutes... | |
I, [2017-03-15T17:05:11.145526 #11376] INFO -- default-mwrock-Windows2012R2: default: WinRM address: 172.31.165.253:5985 | |
I, [2017-03-15T17:05:11.145526 #11376] INFO -- default-mwrock-Windows2012R2: default: WinRM username: vagrant | |
I, [2017-03-15T17:05:11.145526 #11376] INFO -- default-mwrock-Windows2012R2: default: WinRM execution_time_limit: PT2H | |
I, [2017-03-15T17:05:11.145526 #11376] INFO -- default-mwrock-Windows2012R2: default: WinRM transport: negotiate | |
I, [2017-03-15T17:05:18.000362 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Machine booted and ready! | |
I, [2017-03-15T17:05:18.000362 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Setting hostname... | |
I, [2017-03-15T17:06:21.423693 #11376] INFO -- default-mwrock-Windows2012R2: ==> default: Machine not provisioned because `--no-provision` is specified. | |
D, [2017-03-15T17:06:21.456701 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] END (0m0.00s) | |
D, [2017-03-15T17:06:21.457710 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] BEGIN (vagrant winrm-config) | |
D, [2017-03-15T17:07:11.869031 #11376] DEBUG -- default-mwrock-Windows2012R2: [Vagrant command] END (0m0.00s) | |
D, [2017-03-15T17:07:12.574530 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] <{:endpoint=>"http://172.31.165.253:5985/wsman", :user=>"vagrant", :password=>"vagrant", :transport=>:negotiate, :elevated_username=>"vagrant", :elevated_password=>"vagrant", :no_ssl_peer_verification=>true, :disable_sspi=>false, :basic_auth_only=>false}> (Write-Host '[WinRM] Established | |
') | |
D, [2017-03-15T17:07:12.577502 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] opening remote shell on http://172.31.165.253:5985/wsman | |
D, [2017-03-15T17:07:16.563463 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:18.124804 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:18.126767 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x4e40a40 @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, [2017-03-15T17:07:18.128281 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:21.451549 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:21.453553 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x4d80908 @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, [2017-03-15T17:07:21.455549 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:21.511013 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:21.512022 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x4ceab48 @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, [2017-03-15T17:07:21.520524 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] remote shell created with shell_id: F4543EDE-608E-4D70-B17F-E06B30A9B300 | |
D, [2017-03-15T17:07:21.898954 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for $env:temp | |
if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: BC858D97-DDA1-4184-8969-989F4127E551 | |
D, [2017-03-15T17:07:21.901970 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: BC858D97-DDA1-4184-8969-989F4127E551 on shell_id F4543EDE-608E-4D70-B17F-E06B30A9B300 | |
D, [2017-03-15T17:07:21.903959 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:23.774363 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:23.786362 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: BC858D97-DDA1-4184-8969-989F4127E551 on shell_id F4543EDE-608E-4D70-B17F-E06B30A9B300 | |
D, [2017-03-15T17:07:23.902691 #11376] DEBUG -- default-mwrock-Windows2012R2: creating hash for file c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.ps1 | |
D, [2017-03-15T17:07:23.903705 #11376] DEBUG -- default-mwrock-Windows2012R2: Running check_files.ps1 | |
D, [2017-03-15T17:07:23.906691 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] opening remote shell on http://172.31.165.253:5985/wsman | |
D, [2017-03-15T17:07:24.118284 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:24.396070 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:24.398087 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x525d7a0 @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, [2017-03-15T17:07:24.401070 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x525c510 @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, [2017-03-15T17:07:24.402071 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:24.512582 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:24.513581 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] polling for pipeline state. message: #<WinRM::PSRP::Message:0x5126670 @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, [2017-03-15T17:07:24.521088 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] remote shell created with shell_id: EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:24.760111 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for $hash_file = @{ | |
"da0157b82719eb93345353798e5db8fa" = @{ | |
"target" = "c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.ps1"; | |
"src_basename" = "winrm-elevated-shell20170315-11376-13yz7xbps1"; | |
"dst" = "c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.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: FB343380-6A7C-47BA-A468-585119EB9917 | |
D, [2017-03-15T17:07:24.767112 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: FB343380-6A7C-47BA-A468-585119EB9917 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:24.769119 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:26.401167 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:26.412175 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: FB343380-6A7C-47BA-A468-585119EB9917 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:26.470176 #11376] DEBUG -- default-mwrock-Windows2012R2: Parsing CSV Response | |
D, [2017-03-15T17:07:26.471177 #11376] DEBUG -- default-mwrock-Windows2012R2: "chk_exists","src_md5","dst_md5","chk_dirty","verifies","target_is_folder" | |
"False","da0157b82719eb93345353798e5db8fa",,"True","False","False" | |
D, [2017-03-15T17:07:26.474188 #11376] DEBUG -- default-mwrock-Windows2012R2: Uploading C:/Users/lombarm/AppData/Local/Temp/winrm-elevated-shell20170315-11376-13yz7xbps1 to c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.ps1 | |
D, [2017-03-15T17:07:26.601020 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for $to = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.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: 3762BE48-7674-47A9-B501-6DF73466AEFC | |
D, [2017-03-15T17:07:26.605021 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: 3762BE48-7674-47A9-B501-6DF73466AEFC on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:26.608034 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:26.657697 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:26.662698 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: 3762BE48-7674-47A9-B501-6DF73466AEFC on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:26.805514 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for if($method) { $method.Invoke($Null, $Null) } | |
$bytes=[Convert]::FromBase64String('JGVudjp0ZW1wPSdDOlxVc2Vyc1x2YWdyYW50XEFwcERhdGFcTG9jYWxcVGVtcCc7V3JpdGUtSG9zdCAnW1dpblJNXSBFc3RhYmxpc2hlZA0KJw0NCiRIb3N0LlNldFNob3VsZEV4aXQoJExBU1RFWElUQ09ERSk=') | |
$fileStream.Write($bytes, 0, $bytes.length) | |
if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: 1E61BE45-AD7D-4357-AD18-34F88D5C5F64 | |
D, [2017-03-15T17:07:26.808525 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: 1E61BE45-AD7D-4357-AD18-34F88D5C5F64 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:26.811522 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:27.084308 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:27.090308 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: 1E61BE45-AD7D-4357-AD18-34F88D5C5F64 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:27.212222 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for $fileStream.Dispose() | |
if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } } with id: C44EE2D7-9E45-4738-A01A-664189FEA287 | |
D, [2017-03-15T17:07:27.216223 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: C44EE2D7-9E45-4738-A01A-664189FEA287 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:27.219237 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:27.277228 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
D, [2017-03-15T17:07:27.283229 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: C44EE2D7-9E45-4738-A01A-664189FEA287 on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:27.342010 #11376] DEBUG -- default-mwrock-Windows2012R2: Finished uploading C:/Users/lombarm/AppData/Local/Temp/winrm-elevated-shell20170315-11376-13yz7xbps1 to c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.ps1 (0.156 KB over 1 chunks) in (0m0.87s) | |
D, [2017-03-15T17:07:27.346010 #11376] DEBUG -- default-mwrock-Windows2012R2: No remote files to extract, skipping | |
D, [2017-03-15T17:07:27.348559 #11376] DEBUG -- default-mwrock-Windows2012R2: Uploaded 1 items dirty_check: (0m2.57s) stream_files: (0m0.87s) extract: (0m0.00s) | |
D, [2017-03-15T17:07:27.421566 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Command created for $username = 'vagrant' | |
$password = 'vagrant' | |
$script_file = 'c:/windows/temp/winrm-elevated-shell-bce799f6-aae8-4973-b30d-a25dd387d9e3.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 > $out_file 2>$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: DDB1C1F0-34FE-4099-8361-FC6EC00D774D | |
D, [2017-03-15T17:07:27.431577 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] creating command_id: DDB1C1F0-34FE-4099-8361-FC6EC00D774D on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
D, [2017-03-15T17:07:27.435590 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Waiting for output... | |
D, [2017-03-15T17:07:29.561474 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] Processing output | |
I, [2017-03-15T17:07:29.567477 #11376] INFO -- default-mwrock-Windows2012R2: [WinRM] Established | |
I, [2017-03-15T17:07:29.572461 #11376] INFO -- default-mwrock-Windows2012R2: | |
D, [2017-03-15T17:07:29.582463 #11376] DEBUG -- default-mwrock-Windows2012R2: [WinRM] cleaning up command_id: DDB1C1F0-34FE-4099-8361-FC6EC00D774D on shell_id EDDFD718-48C4-4FFD-8612-4B36F4BBCDE4 | |
I, [2017-03-15T17:07:29.606974 #11376] INFO -- default-mwrock-Windows2012R2: Vagrant instance <default-mwrock-Windows2012R2> created. | |
I, [2017-03-15T17:07:29.617939 #11376] INFO -- default-mwrock-Windows2012R2: Finished creating <default-mwrock-Windows2012R2> (4m45.85s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I, [2017-03-15T17:02:40.602912 #11376] INFO -- Kitchen: -----> Starting Kitchen (v1.15.0) | |
D, [2017-03-15T17:02:40.620449 #11376] DEBUG -- Kitchen: [Vagrant command] BEGIN (vagrant --version) | |
D, [2017-03-15T17:02:40.821957 #11376] DEBUG -- Kitchen: [Vagrant command] END (0m0.00s) | |
I, [2017-03-15T17:02:43.761441 #11376] INFO -- Kitchen: -----> Creating <default-mwrock-Windows2012R2>... | |
I, [2017-03-15T17:07:29.619969 #11376] INFO -- Kitchen: -----> Kitchen is finished. (4m49.02s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |c| | |
c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf") | |
c.vm.box = "mwrock/Windows2012R2" | |
c.vm.hostname = "chef-fu" | |
c.vm.network(:private_network, {:bridge=>"Guest"}) | |
c.vm.synced_folder ".", "/vagrant", disabled: true | |
c.vm.provider :hyperv do |p| | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment