Powershell Studio 2019 not parsing the script blocks

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
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.
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.
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

To help you better we need some information from you.

*** Please fill in the fields below if you are currently using a Trial Version of the Product. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
32 or 64 bit version of product:64 bit
Operating system: 64 bit
32 or 64 bit OS:

*** Please add details and screenshots as needed below. ***
Powershell studio is not detecting and parsing the script block properly @" "@

see sample code below

$remoteCommand1 =@"
function Get-Todaysfile
{
[CmdletBinding()]
Param (

[Parameter(Position = 0, Mandatory = $true)]
[string]$FolderToTrack,
[Parameter(Position = 1, Mandatory = $true)]
[string]$FileExtensionToTrack,
[Parameter(Position = 2, Mandatory = $true)]
[string]$logfile
)
Process
{
$TodaysDate = Get-Date
$TodaysDate = $TodaysDate.AddSeconds(-$TodaysDate.second)
$TodaysDate = $TodaysDate.AddMinutes(-$TodaysDate.Minute)
$TodaysDate = $TodaysDate.AddHours(-$TodayDate.Hour)
$TomorrowsDate = $TodaysDate.AddDays(+ 1)
if ($FolderToTrack -notmatch '\\$') { $FolderToTrack += '\' }
try
{
$TodaysFile = Get-ChildItem -Path $($FolderToTrack + "*") -Include $FileExtensionToTrack | Where-Object { ($_.LastWriteTime -ge $TodaysDate) -and ($_.LastWriteTime -lt $TomorrowsDate) }

}
catch
{

Write-log -LogString "Function:Get-Todaysfile ==> Error finding todays file." -logfile $logfile
}

}
}
"@



function Find-STRinFile
{
[CmdletBinding()]
Param (

[Parameter(Position = 0, Mandatory = $true)]
[string]$FileName,
[Parameter(Position = 1, Mandatory = $true)]
[string]$StringToFind,
[Parameter(Position = 2, Mandatory = $true)]
[string]$logfile
)
Process
{
$foundmystring = $false
try
{
if (Select-String -Pattern $StringToFind -Path $FileName -Quiet)
{
$foundmystring = $true
# do some action

}

}
catch
{
Write-log -LogString "Function:Find-STRinFile ==> Error searching through the file $FileName file." -logfile $logfile
}
retrun $foundmystring

}
}
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Powershell Studio 2019 not parsing the script blocks

Post by Alexander Riedel »

*** Please fill in the fields below if you are currently using a Trial Version of the Product. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
32 or 64 bit version of product:64 bit
Operating system: 64 bit
32 or 64 bit OS:

Also, please elaborate on what "not parsing properly" means. Please keep in mind that we cannot see your screen.
Alexander Riedel
SAPIEN Technologies, Inc.
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Re: Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.166
OS: Windows 10 Pro (64 Bit)
Build: v10.0.17763.0
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Re: Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

pstudio.png
pstudio.png (53.55 KiB) Viewed 15344 times
microsoftpowershellise.png
microsoftpowershellise.png (85.31 KiB) Viewed 15344 times
see the difference in grouping, point 3 in pstudio shows its parsing the items after "@ as string. in ms ise, its parsed properly
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Powershell Studio 2019 not parsing the script blocks

Post by brittneyr »

So far I haven't been able to reproduce the parsing issue you are having.
script-coloring.png
script-coloring.png (101.28 KiB) Viewed 15338 times
Could you please upload the your script here:
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Re: Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

Hello Brittney

The file is now uploaded

Regards
Binu B K
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Re: Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

Are you able to reproduce the issue ?
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Powershell Studio 2019 not parsing the script blocks

Post by brittneyr »

I have been able to reproduce your issue and have filed an internal bug report.

Thank you for bringing this to our attention. When I have some news to share, I'll be sure to post it here.

As for a temporary solution, the issue was fixed when using Format Script:
SPS_formatScript.png
SPS_formatScript.png (58.18 KiB) Viewed 15095 times
Brittney
SAPIEN Technologies, Inc.
Binu.Bk
Posts: 6
Last visit: Tue Apr 13, 2021 10:29 pm

Re: Powershell Studio 2019 not parsing the script blocks

Post by Binu.Bk »

Hello Brittney

Thanks for the update... i will put a tail on this thread.

Regard
Binu B K
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Powershell Studio 2019 not parsing the script blocks

Post by brittneyr »

This issue has been resolved and will be in the next service release.
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.