Persisting issues with Splat Command in PowerShell Studio

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 LICENSE NUMBERS, ACTIVATION 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.
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject »

Product, version and build: PowerShell Studio 5.6.167
32 or 64 bit version of product: 64bit
Operating system: Win 10 1903
32 or 64 bit OS: 64bit

Hello,

I'm reposting this as it seems my reply to the other thread went unnoticed, as per subject with the latest build I'm still observing issues with the way PowerShell studio pefrom command splatting.

If I try to splat the following code:

Code: Select all

$exOnlineSession = New-ExOnlineSession -UserName $userName -UserPassword (New-StringDecryption -EncryptedString $azurePassword)
It will result in this:

Code: Select all

		$paramNewExOnlineSession = @{
			UserName	 = $userName
			UserPassword = (New-StringDecryption -EncryptedString $azurePassword)
		}
		
		$exOnlineSession = New-ExOnlineSession @paramNewExOnlineSession)
Note the extra trailing parentheses in $exOnlineSession which should be:

Code: Select all

		$paramNewExOnlineSession = @{
			UserName	 = $userName
			UserPassword = (New-StringDecryption -EncryptedString $azurePassword)
		}
		
		$exOnlineSession = New-ExOnlineSession @paramNewExOnlineSession
		
		#  Or even
		$exOnlineSession = (New-ExOnlineSession @paramNewExOnlineSession)
		
The other issue is when casting to [void] which is adding an extra space to the end of the command:

Code: Select all

# Do something
[void]::(Enable-RemoteMailbox -Identity $Identity -Archive)

# Splatting will result in

$paramEnableRemoteMailbox = @{
Identity = $Identity
Archive = $true
}

# Extra trailing space after the @parameter
[void]::(Enable-RemoteMailbox @paramEnableRemoteMailbox )

# It should be
[void]::(Enable-RemoteMailbox @paramEnableRemoteMailbox)
I originally reported the issue here viewtopic.php?f=12&t=14120 affecting version .163, with the release of .167 issues have been somehow mitigated but introduced some others :)

Thanks for looking into this!
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Persisting issues with Splat Command in PowerShell Studio

Post by brittneyr »

I apologize for the delayed response as I see you messaged on the older thread. I'm looking into this and will keep you updated.
Brittney
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject »

No issues and no apolgoies needed Brittney, wasn's unsure if that went unnoticed so thought to post again here, did not mean to be pushy or anything.

Thanks for looking into this!
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Persisting issues with Splat Command in PowerShell Studio

Post by brittneyr »

Not pushy at all, this is what the forums are for :)

As for the issues you reported, I was able to reproduce the behavior and have reopened the issue in our internal bug tracking system. Should hopefully be working correctly in the next service release.
Brittney
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject »

Many thanks Brittney, really appreciate your help and work!

Please do extend this to the whole (Development and not) team, your products really make my life as a Dev REALLY easier.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: Persisting issues with Splat Command in PowerShell Studio

Post by brittneyr »

Please try service build 5.6.168. We believe this is working correctly now, however it is hard to test as there are many different variations of how this could be written. Thank you for your patience and helping us find more cases to test against.
Brittney
SAPIEN Technologies, Inc.
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.