Splat Command not inserting trailing parentheses

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

Splat Command not inserting trailing parentheses

Post by PsCustomObject » Wed Jul 31, 2019 2:35 am

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

Hello as per subject I've noticed with the latest build when using the Splat command shortcut PowerShell studio is not insertting the trailing closing parentheses, if present, int the command.

For exampleI have the following snippet:

Code: Select all

[void]::(Enable-RemoteMailbox -Identity $Identity -Archive)
If I use the Splat command I get the following (note the missing trailing parentheses):

Code: Select all

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

[void]::(Enable-RemoteMailbox @paramEnableRemoteMailbox
Casting to void is something I use rather frequently so I'm sure it used to work in previous builds.

Thanks in advance for checking this!

User avatar
mxtrinidad
Site Admin
Posts: 328
Joined: Sun Mar 03, 2013 12:42 pm

Re: Splat Command not inserting trailing parentheses

Post by mxtrinidad » Wed Jul 31, 2019 6:36 am

Notice you're on PowerShell Studio version 5.6.163.
We suggest to update to the latest version (5.6.166) as this issue was already resolved.

Thanks

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

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject » Wed Jul 31, 2019 6:56 am

Sorry that's typo on my side I'm indeed on version 5.6.166 I just copied/pasted the wrong version from another post ;-)

And can confirm issue is still present with .166 build.

User avatar
mxtrinidad
Site Admin
Posts: 328
Joined: Sun Mar 03, 2013 12:42 pm

Re: Splat Command not inserting trailing parentheses

Post by mxtrinidad » Wed Jul 31, 2019 7:11 am

Thanks for verifying the version. We'll have our team take a look at this issue and get back to you.

User avatar
brittneyr
Site Admin
Posts: 158
Joined: Thu Jun 01, 2017 7:20 am

Re: Splat Command not inserting trailing parentheses

Post by brittneyr » Fri Aug 02, 2019 12:54 pm

This issue has been resolved and will be in the next service release.
Brittney Ryn
SAPIEN Technologies, Inc.

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

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject » Mon Aug 05, 2019 8:01 am

Thanks both for checking and solving this!

User avatar
brittneyr
Site Admin
Posts: 158
Joined: Thu Jun 01, 2017 7:20 am

Re: Splat Command not inserting trailing parentheses

Post by brittneyr » Wed Aug 14, 2019 9:36 am

Please try the latest service build of PowerShell Studio (5.6.167).
Brittney Ryn
SAPIEN Technologies, Inc.

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

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject » Fri Aug 16, 2019 2:21 am

Brittney,

I can confirm the reported issue has been resolved in 5.6.167 but it seems a regression was introduced, I'm reporting it here but let me know if I should open a new thrad.

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)
		
Please let me know if I should open a new thread but guess this pertains to this one as issue is essentially the same.

Once again thanks!

**EDIT**

Something else I've noticed with the new build, while splatting to [void] is now working it is inserting an extra white space like

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)

User avatar
brittneyr
Site Admin
Posts: 158
Joined: Thu Jun 01, 2017 7:20 am

Re: Splat Command not inserting trailing parentheses

Post by brittneyr » Mon Aug 19, 2019 8:09 am

I'll only respond to this issue on the following thread to help avoid any confusion:
viewtopic.php?f=12&t=14160
Brittney Ryn
SAPIEN Technologies, Inc.