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 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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
ITZBund_Ilmenau
Posts: 13
Joined: Thu Aug 24, 2017 11:11 pm

PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_Ilmenau » Mon Apr 09, 2018 11:53 pm

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: 120
Joined: Mon May 15, 2017 9:06 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B » Tue Apr 10, 2018 9:49 am

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_Ilmenau
Posts: 13
Joined: Thu Aug 24, 2017 11:11 pm

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_Ilmenau » Tue Apr 10, 2018 11:24 pm

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: 7053
Joined: Tue May 29, 2007 4:43 pm

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Alexander Riedel » Wed Apr 11, 2018 12:07 am

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: 120
Joined: Mon May 15, 2017 9:06 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B » Wed Apr 11, 2018 8:35 am

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_Ilmenau
Posts: 13
Joined: Thu Aug 24, 2017 11:11 pm

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_Ilmenau » Thu Apr 12, 2018 1:33 am

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: 120
Joined: Mon May 15, 2017 9:06 am

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Olga_B » Thu Apr 12, 2018 9:12 am

Thanks. We will investigate it

User avatar
Alexander Riedel
Posts: 7053
Joined: Tue May 29, 2007 4:43 pm

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by Alexander Riedel » Thu Apr 12, 2018 2:58 pm

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 34 times
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ITZBund_Ilmenau
Posts: 13
Joined: Thu Aug 24, 2017 11:11 pm

Re: PrimalScriptHostImplementation can't read NTFS ADS

Post by ITZBund_Ilmenau » Thu Apr 12, 2018 10:58 pm

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.