Error setting property only after compiling into exe

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
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
Posts: 3
Joined: Wed Oct 01, 2014 8:32 am

Error setting property only after compiling into exe

Post by vvpham@powershellstudio » 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.


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

Re: Error setting property only after compiling into exe

Post by 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.
  1. if(!(Get-Module Microsoft.PowerShell.Security)) {
  3.  Import-Module Microsoft.PowerShell.Security
  5. }
  9. $Module = Get-Module Microsoft.PowerShell.Security
  11. if($Module) {
  13.   $Module.LogPipelineExecutionDetails  = $false
  15. }
This gives you a chance to see where it fails, if it fails
Alexander Riedel
SAPIEN Technologies, Inc.