PowerShell Studio Feature RequestsFeature requests, product enhancement ideas, and other product-specific suggestions.
Function Builder / Editor - Add support for [ref]
PhilBenson, May. 11, 2019Under Review
Product: PowerShell Studio 2019 (64 Bit)
OS: Windows 10 Enterprise 2016 LTSB (64 Bit)
how about adding the ability to create a reference paramter (typed) in th function builder?
At the moment you can define the type, but not explicitly define that it is by refernce ( [ref] ). Perhaps I'm missing something but I had to add everything manually whilst defining a function whose paramter was to be passed by reference.
[Parameter(Mandatory = $true,
ValueFromPipeline = $false,
ValueFromPipelineByPropertyName = $false,
Position = 0,
HelpMessage = 'The Hashtable object that will contain the contents of the parsed command line. This object is passed ByRef!')]
Comment by davidc, May. 13, 2019
Within PowerShell [Ref] is a type. So, when you declare a parameter [hashtable][ref]$param, PowerShell will use the first type declared. In this case: [hashtable] and not reference type [System.Management.Automation.PSReference], which allows you to reassign the original variable / object passed to the cmdlet.
To use a reference, you must declare the parameter type [ref] only.
And access the value property of the parameter:
Please refer to the about_Ref topic.