Page 1 of 1

Splat Command not inserting trailing parentheses

Posted: Wed Jul 31, 2019 2:35 am
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!

Re: Splat Command not inserting trailing parentheses

Posted: Wed Jul 31, 2019 6:36 am
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

Re: Splat Command not inserting trailing parentheses

Posted: Wed Jul 31, 2019 6:56 am
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.

Re: Splat Command not inserting trailing parentheses

Posted: Wed Jul 31, 2019 7:11 am
by mxtrinidad
Thanks for verifying the version. We'll have our team take a look at this issue and get back to you.

Re: Splat Command not inserting trailing parentheses

Posted: Fri Aug 02, 2019 12:54 pm
by brittneyr
This issue has been resolved and will be in the next service release.

Re: Splat Command not inserting trailing parentheses

Posted: Mon Aug 05, 2019 8:01 am
by PsCustomObject
Thanks both for checking and solving this!

Re: Splat Command not inserting trailing parentheses

Posted: Wed Aug 14, 2019 9:36 am
by brittneyr
Please try the latest service build of PowerShell Studio (5.6.167).

Re: Splat Command not inserting trailing parentheses

Posted: Fri Aug 16, 2019 2:21 am
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)

Re: Splat Command not inserting trailing parentheses

Posted: Mon Aug 19, 2019 8:09 am
by brittneyr
I'll only respond to this issue on the following thread to help avoid any confusion:
viewtopic.php?f=12&t=14160