Page 1 of 1

Calling a script with parameters

Posted: Fri Jan 29, 2016 2:29 pm
by OldLost
PowerShell Studio 2015 v4.2.99 x64
Windows Server 2012 R2 64bit

In my script I'm calling another PS1 file in the pipeline that takes named parameters. Here is the line in question:
$Data = @(Get-ChildItem -Path ($WorkfileTemplate -f '*', 'csv') | & (Join-Path (Split-Path $PSCommandPath) 'Invoke-This.ps1') -ScriptBlock { Import-Csv -LiteralPath $_.FullName | Select-Object -Property @{ Name = 'Date'; Exp = { ([datetime]($_.Date)).ToString('yyyy-MM-dd') } }, Name, IPAddress, Domain, Error | Sort-Object IPAddress -Unique } | Sort-Object Domain, Name)
My problem is that PowerShell Studio's Format Script command wants to put a space between the minus sign and "ScriptBlock" which, of course, Powershell doesn't like. I know the way I'm doing it Powershell itself doesn't have a problem with it and it works fine, but I have to go back and take out that space before it'll work.

Any way around this?

Re: Calling a script with parameters

Posted: Wed Mar 02, 2016 11:24 am
by davidc
This issue should be resolved in the next service release. Unfortunately there is no way around it until the service build is released.

David