Support Forums

Error setting property only after compiling into exe

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum 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.
User avatar
VPham@IMF
Posts: 3
Joined: Wed Oct 01, 2014 8:32 am

Error setting property only after compiling into exe

Postby VPham@IMF » Wed Feb 10, 2016 3:12 pm

Product, version and build: SAPIEN PowerShell Studio 2015, 4.2.99
32 or 64 bit version of product: 64
Operating system: Windows 7 Enterprise SP (PowerShell v3)
32 or 64 bit OS: 64

GOAL: Create a GUI that passes sensitive credentials in an environment with PowerShell Event logging enabled but hides the details in the Event Viewer logs so the credentials cannot be reversed engineered from the event log details.

SCRIPT:

(Get-Module Microsoft.PowerShell.Security).LogPipelineExecutionDetails = $false
$user = "Domain\AdminUser"
$key = [array]"values"
$pwd = ConvertTo-SecureString "encryptedstring" -Key $key
$credentials = New-Object System.Management.Automation.PsCredential($user, $pwd)
(Get-Module Microsoft.PowerShell.Security).LogPipelineExecutionDetails = $True

ISSUE: When running the following lines in PowerShell script, the script behaves as expected: script disables event log details recording, credential object is created successfully, event log details are then re-enabled. However, the same code is then packaged in PowerShell Studio (Settings for package are: SAPIEN PowerShell V3 Host (Windows) x64, STA Mode)), the executable generates an error when ran. This error reads: ERROR: Property 'LogPipelineExecutionDetails' cannot be found on this object; make sure it exists and is settable. This error occurs when trying to set this property to false and true.

NOTES: This executable is being ran as an administrator on the system and again, the script works fine until packaged into an executable by PowerShell Studio.

Any help would be greatly appreciated. Or, if anyone has any idea on how to otherwise hide credential details from the event log so they cannot be reversed engineered. Clearing the event log (even time-based on just when the script was being ran was not considered an acceptable solution).
User avatar
Alexander Riedel
Posts: 5862
Joined: Tue May 29, 2007 4:43 pm

Re: Error setting property only after compiling into exe

Postby Alexander Riedel » Wed Feb 10, 2016 3:39 pm

"script runs fine" does not imply where you ran it. If you ran this in the powershell console, please note that the console by default runs elevated.
That is a step above logged on as administrator.

Secondly, do not write code like this:
(Get-Module Microsoft.PowerShell.Security).LogPipelineExecutionDetails

You assume that the Get-Module call ALWAYS works and that the module is actually already imported.

if(!(Get-Module Microsoft.PowerShell.Security)) {
Import-Module Microsoft.PowerShell.Security
}
 
$Module = Get-Module Microsoft.PowerShell.Security
if($Module) {
$Module.LogPipelineExecutionDetails = $false
}


This gives you a chance to see where it fails, if it fails
Alexander Riedel
SAPIEN Technologies, Inc.

Return to “PowerShell Studio”

Who is online

Users browsing this forum: No registered users and 5 guests