Powershell Studio 2019 not parsing the script blocks
Posted: Thu Jul 25, 2019 12:08 am
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
*** 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