Azure / nxtools

Azure Automanage Machine Configuration Linux DSC resources
Other
13 stars 13 forks source link

nxFile resource broken when used for deleting files #29

Closed samartzidis closed 1 year ago

samartzidis commented 1 year ago

Hi,

This piece of code:

$commonParams = @{
    Name = 'nxFile'
    Property = @{ DestinationPath = "/tmp/dummy.txt"; Ensure = "Absent" }
    ModuleName = 'nxTools'
    Verbose = $true
}
Invoke-DscResource @commonParams -Method Set

Results in error: Remove-Item: Cannot bind argument to parameter 'Path' because it is null.

Issue is in line 410 of nxFile.ps1:

https://github.com/Azure/nxtools/blob/cbfc8880fa2dd7cf0859072100d0017e43a1e4d6/source/Classes/1.DscResources/01.nxFile.ps1#L410C36-L410C68

410: Remove-Item -Path $nxFileSystemInfo.DestinationPath -Force:($this.Force) -Recurse:($this.Recurse) -Confirm:$false

Should be:

410: Remove-Item -Path $nxFileSystemInfo.FullName -Force:($this.Force) -Recurse:($this.Recurse) -Confirm:$false

As $nxFileSystemInfo does not have a property named DestinationPath but FullName instead.

Thanks.