diff --git a/lib/ansible/modules/windows/win_lineinfile.ps1 b/lib/ansible/modules/windows/win_lineinfile.ps1 index 4ba9086a6e9..968f66bae4d 100644 --- a/lib/ansible/modules/windows/win_lineinfile.ps1 +++ b/lib/ansible/modules/windows/win_lineinfile.ps1 @@ -96,7 +96,8 @@ function WriteLines($outlines, $dest, $linesep, $encodingobj, $validate) { # Commit changes to the destination file $cleandest = $dest.Replace("/", "\"); - Move-Item $temppath $cleandest -force; + Copy-Item $temppath $cleandest -force; + Remove-Item $temppath -force; }