PrimalScriptHostImplementation can't read NTFS ADS

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 5 years and 11 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.
User avatar
ITZBund_WisIT
Posts: 13
Last visit: Thu Mar 14, 2024 1:11 am

PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_WisIT »

To help you better we need some information from you.

*** Please fill in the fields below. 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: Powershell Studio 2018 v5.5.150
32 or 64 bit version of product: 64bit
Operating system: Windows Server 2016
32 or 64 bit OS: 64bit

*** Please add details and screenshots as needed below. ***

Using a packaged windows forms project (no matter which of the SAPIEN Script engines I choose), I can't access the NTFS alternate data streams.
When just running it live in the PS Studio it works.

The code:

Code: Select all

Get-Content -Path $ScriptFile -Stream $Stream
The error:

Code: Select all

Get-Content : A parameter cannot be found that matches parameter name 'Stream'.
At line:960 char:37
+         if (Get-Content -Path $ScriptFile -Stream $Stream -ErrorActio ...
+                                           ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Content], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand
The command that obviously supports the -stream parameter:
https://docs.microsoft.com/en-us/powers ... rshell-5.0
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B »

Could you clarify what Script Engine are you using to package the project V2 or V5?

If you package with V2 engine, and then copy just .exe file to new location, you will get this error

You need to have .config file(it was created during packaging process) in the same directory with .exe file
User avatar
ITZBund_WisIT
Posts: 13
Last visit: Thu Mar 14, 2024 1:11 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_WisIT »

I have used both the V3 and the V5 engine and always generate the .config file (since it's a default setting anyway).
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Alexander Riedel »

The cmdlet had the -Stream parameter since 3.0. So there must be something else at play here.
I will create a script tomorrow and package it. I'll post it here so you can try that on your end then.
We take it from there.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B »

I can't reproduce it. Looks like it's project or NTFS alternate data streams related.
Could you please zip and load up the original file(s), so that we can attempt to recreate the issue:

https://www.sapien.com/support/upload
User avatar
ITZBund_WisIT
Posts: 13
Last visit: Thu Mar 14, 2024 1:11 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_WisIT »

I trimmed down the project to just the needed function and uploaded it as requested.

It is indeed true, that if I try the same in another project, it works.
So it can't be a general problem with PS Studio, but maybe something setting related.
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B »

Thanks. We will investigate it
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Alexander Riedel »

I trimmed down your sample project a little more and it works fine as a script and packaged. See attached
I think the main problem is that you use
if(!Get-Content -Path $ScriptDirectory -Stream $stream)) { ...}
which throws an error if the stream does not exist rather than just returning NULL as you expect and because of that nothing after it gets processed.
A simple
$ErrorActionPreference = 'SilentlyContinue'
will fix that, as seen in the modified code.
Attachments
TipDu.zip
(90.41 KiB) Downloaded 137 times
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
ITZBund_WisIT
Posts: 13
Last visit: Thu Mar 14, 2024 1:11 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_WisIT »

This works indeed. Very curious error I have to say.
I prefer to use the Cmdlets own -ErrorAction parameter instead of the global one, but both work the same.

Thanks for clearing that up.
This topic is 5 years and 11 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.