Feature Request: Import-PowershellDataFile should accept string input
See original GitHub issueSummary of the new feature/enhancement
Currently Import-PowershellDataFile takes a path to a file on disk. But what if I have the .psd1 content in memory? (Such as in a string, as downloaded from AzDO or github or such.)
Proposed technical implementation details (optional)
Another parameter set that accepts a string.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Import-PowerShellDataFile (Microsoft.PowerShell.Utility)
The Import-PowerShellDataFile cmdlet safely imports key-value pairs from hashtables defined in a .PSD1 file. The values could be imported using ...
Read more >Ways to input parameter values from file : r/PowerShell
I have several scripts with quite an extensive list of parameters, among which often long strings, to be used by the helpdesk who...
Read more >Script out a hashtable with PowerShell [duplicate]
Fundamentally, converting a hashtable instance to its equivalent source-code representation only works in simple cases, such as yours.
Read more >PowerShell Pipe Options and Functions List
The Import-PowerShellDataFile cmdlet safely imports key-value pairs from hashtables defined in a .PSD1 file. The values could be imported using ...
Read more >PSFramework.psm1 1.4.150
Loads files into the module on module import. .DESCRIPTION This helper function is used during module initialization. It should always be dotsourced itself,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

As an alternative to a new cmdlet, we could think about generalizing @JamesWTruher’s idea proposed in the context of https://github.com/PowerShell/PowerShell/issues/4332#issuecomment-643486358: To allow targeting a variable via a provider path; e.g.:
All file-processing cmdlets could benefit from this, notably
Import-CliXml/Export-CliXml, which would obviate the need to implement #3898 (separateConvertTo/From-CliXmlcmdlets).I’ve always felt that the current dichotomy - one cmdlet for in-memory operations, another for file operations - is clumsy, both in terms of UX and implementation.
Yeah looks like they explicitly check for other providers and prevent them from being used.
IMO they should just… not, really. 😂
New-WordCloudfrom my PSWordCloud module allows this kind of functionality (writing to arbitrary PSProviders). The only real issue I ran into was that not all providers (the variable provider is one of these) support theContent.Clear()operation, so you do have to catch that and (probably) swap it for anItem.Remove()operation instead (if the provider supports that) if you want to be able to doSet-Contentstyle things which clear data before writing.