From 149dd9ca869efd86c489d3b327ab16ae6e8849eb Mon Sep 17 00:00:00 2001 From: Ssawa Date: Thu, 9 Feb 2017 19:43:52 -0500 Subject: [PATCH] Update winrm to allow fetch_file to work on files in use by processes (#18174) --- lib/ansible/plugins/connection/winrm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 860b58f4b05..031e45ea2dc 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -426,7 +426,7 @@ class Connection(ConnectionBase): script = ''' If (Test-Path -PathType Leaf "%(path)s") { - $stream = [System.IO.File]::OpenRead("%(path)s"); + $stream = New-Object IO.FileStream("%(path)s", [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [IO.FileShare]::ReadWrite); $stream.Seek(%(offset)d, [System.IO.SeekOrigin]::Begin) | Out-Null; $buffer = New-Object Byte[] %(buffer_size)d; $bytesRead = $stream.Read($buffer, 0, %(buffer_size)d);