when using `-p` to pass a file `~` cannot be used in PowerShell
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest version
- [X] Search the existing issues.
Steps to reproduce
When testing out the new parameter -p and -path inside PowerShell I was unable to use the ~ for referencing the $HOME location, while $env:USERPROFILE worked as seen below. The tilde can be used with other commands like Get-Command, so I was expecting this to work as an alias for the user profile.
Expected behavior
dsc config get --path ~\gotstoy.dsc.config.yaml
results:
- name: All Users Configuration
type: TSToy.Example/gotstoy
result:
actualState:
ensure: present
scope: machine
updateAutomatically: true
updateFrequency: 23
- name: Current User Configuration
type: TSToy.Example/gotstoy
result:
actualState:
ensure: present
scope: user
updateAutomatically: true
messages: []
hadErrors: false
Actual behavior
dsc config get --path ~\gotstoy.dsc.config.yaml
2024-03-16T23:59:13.854146Z ERROR dsc::util: 385: Error: Failed to read input file: The system cannot find the path specified. (os error 3)
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
dsc 3.0.0-alpha.5
Visuals
I see there is already a known issue with relative path, which may be a similar issue.
~ expansion is the job of the shell, not the exe so dsc.exe has no idea what ~ means. However, PS7.5 has a new experimental feature to make this work. For older PS, you can use (resolve-path ~\gotstoy.dsc.config.yaml) to force resolving the ~.