mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fixed win_file crash with hidden files (#52584)
* Fixed crash with hidden files added "-force" parameter on "Get-Item" cmdlet. this is needed to get file info if the file is "hidden" without this option modules like win_file, win_template, win_copy crashes on hidden files. this is because with "test-path" it sees that the file exists, but "get-item" can't get the file info. for more information on "-force option": https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-item * Add changelog and integration tests * fix tests for older Windows versions
This commit is contained in:
@@ -102,7 +102,7 @@ if ($state -eq "touch") {
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $path) {
|
||||
$fileinfo = Get-Item -LiteralPath $path
|
||||
$fileinfo = Get-Item -LiteralPath $path -Force
|
||||
if ($state -eq "absent") {
|
||||
Remove-File -file $fileinfo -checkmode $check_mode
|
||||
$result.changed = $true
|
||||
|
||||
Reference in New Issue
Block a user