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 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 7 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

Splat Command not inserting trailing parentheses

Post by PsCustomObject »

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:
  1. [void]::(Enable-RemoteMailbox -Identity $Identity -Archive)
If I use the Splat command I get the following (note the missing trailing parentheses):
  1.                 $paramEnableRemoteMailbox = @{
  2.                     Identity = $Identity
  3.                     Archive  = $true
  4.                 }
  5.                
  6.                 [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
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Splat Command not inserting trailing parentheses

Post by mxtrinidad »

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: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject »

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
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Splat Command not inserting trailing parentheses

Post by mxtrinidad »

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: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: Splat Command not inserting trailing parentheses

Post by brittneyr »

This issue has been resolved and will be in the next service release.
Brittney
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject »

Thanks both for checking and solving this!
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: Splat Command not inserting trailing parentheses

Post by brittneyr »

Please try the latest service build of PowerShell Studio (5.6.167).
Brittney
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Splat Command not inserting trailing parentheses

Post by PsCustomObject »

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: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: Splat Command not inserting trailing parentheses

Post by brittneyr »

I'll only respond to this issue on the following thread to help avoid any confusion:
viewtopic.php?f=12&t=14160
Brittney
SAPIEN Technologies, Inc.
This topic is 4 years and 7 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.