Splatting while returning data to a variable

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
pdearmen
Posts: 64
Joined: Sun Mar 03, 2013 12:42 pm

Splatting while returning data to a variable

Post by pdearmen » Fri Mar 03, 2017 1:44 pm

Product, version and build: 5.4.136
(*** Please do not write "latest" as a version, specify a version number ***)
32 or 64 bit version of product: 64
Operating system: Windows 10 Anniversary Update
32 or 64 bit OS: 64
PowerShell Version: 5.1

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Something I noticed when using the new function splat feature is that if I am assigning the results of a function to a variable (specifically when I am going to use that variable multiple times in the subsequent code blocks) the command in powershell studio doesn't work as I think it is intended.

Example:

Code: Select all

$BaseData = Get-VCPIAdInformation -ReportPeriod $ReportPeriod
When I right click on the function get-vcpiadinformation and splat it I get

Code: Select all

$BaseData = $parameters = @{
ReportPeriod = $ReportPeriod
}

Get-VCPIAdInformation @parameters
Just to make sure it wasn't something with the custom functions we use I tried it against Get-ACL with the same results

Code: Select all

$data = Get-Acl -Path "c:\"
Splatted:

Code: Select all

$data = $parameters = @{
Path = "c:\"
}

Get-Acl @parameters
Not a critical issue by any stretch of the imagination but it would be nice since you are already creating the $paramters = portion to correctly move the variable down to the command portion

Thanks!

User avatar
DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: Splatting while returning data to a variable

Post by DevinL » Fri Mar 03, 2017 2:12 pm

I've managed to reproduce this on my end and have filed an internal bug report.

Thank you for bringing this to our attention. When we have some news to share, we'll be sure to post it here.
DevinL
SAPIEN Technologies, Inc.

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Splatting while returning data to a variable

Post by davidc » Fri Mar 03, 2017 2:16 pm

Yes, I'm aware of this. The initial version of the tool only deals with a simple replacement of the command text. Refactoring statements get a little more complex and we try to deal with this cases in the future.
David
SAPIEN Technologies, Inc.