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 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
PsCustomObject
Posts: 80
Joined: Tue Apr 29, 2014 1:55 am

Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject » Mon Aug 19, 2019 12:34 am

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: 163
Joined: Thu Jun 01, 2017 7:20 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by brittneyr » Mon Aug 19, 2019 7:20 am

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 Ryn
SAPIEN Technologies, Inc.

User avatar
PsCustomObject
Posts: 80
Joined: Tue Apr 29, 2014 1:55 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject » Mon Aug 19, 2019 1:02 pm

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: 163
Joined: Thu Jun 01, 2017 7:20 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by brittneyr » Mon Aug 19, 2019 1:25 pm

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 Ryn
SAPIEN Technologies, Inc.

User avatar
PsCustomObject
Posts: 80
Joined: Tue Apr 29, 2014 1:55 am

Re: Persisting issues with Splat Command in PowerShell Studio

Post by PsCustomObject » Tue Aug 20, 2019 2:51 am

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.