Open mgreenegit opened 4 weeks ago
Same behavior when run in the context of a configuration
I have the same behavior locally.
As far as I can tell from traces, the DSCv3/PSAdapter layer is doing everything right.
It feels like the problem is somewhere in the resource or PSDesiredStateConfiguration module. If you can make the composite File
resource work using Invoke-DscResource
cmdlet, then the bug is in DSCv3/PSAdapter.
Also, FYI:
1) in the traces I saw following message from the resource: The path cannot point to the root directory or to the root of a net share.
2) a better command syntax is moving resource type to set -r
parameter: '{DestinationPath: c:\Temp\test.txt, type: File, contents: test, Ensure: present}' | dsc -l trace resource set -r 'PSDesiredStateConfiguration/File'
I ran into the same that @mgreenegit has experienced with a config. I haven;t been successful with invoke-DscResource, but I think thats my mistake. Using Preview 7.
# Example configuration mixing native app resources with classic PS resources
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Use Windows PowerShell resources
type: Microsoft.Windows/WindowsPowerShell
properties:
resources:
- name: Default web page
type: PSDesiredStateConfiguration/File
properties:
Ensure: Present
Type: Directory
SourcePath: c:\website\
DestinationPath: 'c:\inetpub\wwwroot'
@anmenaga fyi, confirmed the no repro when calling invoke-dsc directly
Invoke-DscResource -Name File -Method Set -ModuleName PSDesiredStateConfiguration -Property @{Ensure = 'Present'; DestinationPath = 'c:\test.txt'; Contents = 'Hello, World!'}
RebootRequired
--------------
False
- a better command syntax is moving resource type to
set -r
parameter:'{DestinationPath: c:\Temp\test.txt, type: File, contents: test, Ensure: present}' | dsc -l trace resource set -r 'PSDesiredStateConfiguration/File'
Please note, this is a config set not a resource set
Prerequisites
Summary
Running the Set operation with the File resource from the Windows PowerShell adapter is not resulting in a changed state.
Steps to reproduce
sudo pwsh {'{"DestinationPath": "c:\test.txt", "type": "File", "contents": "test", "type": "PSDesiredStateConfiguration/File"}' | dsc resource set -r 'Microsoft.Windows/WindowsPowerShell'}
Expected behavior
Actual behavior
Error details
No response
Environment data
Version
dsc 3.0.0-preview.8
Visuals
No response