Calling a script with parameters

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 8 years and 3 weeks 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
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Calling a script with parameters

Post 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?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Calling a script with parameters

Post 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
David
SAPIEN Technologies, Inc.
This topic is 8 years and 3 weeks 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.