My environment:
Windows 7 x64
PowerShell Studio 4.1.61
I tried to use the runas and impersonate features of the packager and recognized that the do not work in my sample.
I then made a simple test case with the credential object:
$username = "Test"
$secstr = ConvertTo-SecureString -String 'Pa$$w0rd' -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @($username, $secstr)
start-process -FilePath "C:\Windows\System32\notepad.exe" -Credential $cred
User "Test" with password "Pa$$w0rd" was created before.
The result: ERROR: start-process : Dieser Befehl kann aufgrund des folgenden Fehlers nicht ausgeführt werden: Der Verzeichnisname ist ungültig.
Translation: The command could not be executed for the following reason: The directoryname is invalid.
The same code works in Powershell ISE, Notepad starts up in the Test account.
Please check and give advice.
Thanks
Martin
PowerShell Studio problems with alternate credentials
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.
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.
Re: PowerShell Studio problems with alternate credentials
Additiononal Info:
A local account is used.
This happens with my privat installation with Windows 7 Pro x64 and also with my installation at work (4.1.57) on Windows 7 Enterprise x64.
I can't use alternate credentials to start a process in any way:
Are there any known workarounds?
Martin
A local account is used.
This happens with my privat installation with Windows 7 Pro x64 and also with my installation at work (4.1.57) on Windows 7 Enterprise x64.
I can't use alternate credentials to start a process in any way:
- no packaging with impersonation
no packaging with RunAs
no Start-Process -Credential ...
Are there any known workarounds?
Martin
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: PowerShell Studio problems with alternate credentials
Are you doing this in 32 bit mode? Try to package it as 64 bit executable.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio problems with alternate credentials
Hi Alexander,
it doesn't matter what mode - it's all the same.
But a fortunate coincidence brouhgt me forward. Let me explain:
Today I worked at my company on my project and I thougt that it could be a good idea to convert my psf file into a project. I created a new form project and placed the project folder somewhere outside of my profile and spreaded my code over the files.
Then I tried to execute and ... I could not believe it - it worked!
Now at home I tried to figure out what's the special circumstance.
My file path until now:
D:\Users\Mr. X\Documents\SAPIEN\PowerShell Studio 2014\Files
May the folder with dot and space confuse Powershell Studio?
I created a similar folder structure:
D:\Test\Test. 1\Documents\SAPIEN\PowerShell Studio 2014\Test2
I placed my script there and ... it worked.
Now I started to move my test.ps1 step by step one folder upward in my profile tree.
At last "D:\Users\Mr. X\Documents\test.ps1" did not work but "D:\Users\Mr. X\test.ps1" did.
So I conclude it's a permission problem.
All my problems are solved by using a different path: RunAs and impersonate works in packaging; start-process with credentials in plain scripts too.
Hope this helps some others.
Martin
it doesn't matter what mode - it's all the same.
But a fortunate coincidence brouhgt me forward. Let me explain:
Today I worked at my company on my project and I thougt that it could be a good idea to convert my psf file into a project. I created a new form project and placed the project folder somewhere outside of my profile and spreaded my code over the files.
Then I tried to execute and ... I could not believe it - it worked!
Now at home I tried to figure out what's the special circumstance.
My file path until now:
D:\Users\Mr. X\Documents\SAPIEN\PowerShell Studio 2014\Files
May the folder with dot and space confuse Powershell Studio?
I created a similar folder structure:
D:\Test\Test. 1\Documents\SAPIEN\PowerShell Studio 2014\Test2
I placed my script there and ... it worked.
Now I started to move my test.ps1 step by step one folder upward in my profile tree.
At last "D:\Users\Mr. X\Documents\test.ps1" did not work but "D:\Users\Mr. X\test.ps1" did.
So I conclude it's a permission problem.
All my problems are solved by using a different path: RunAs and impersonate works in packaging; start-process with credentials in plain scripts too.
Hope this helps some others.
Martin
Re: PowerShell Studio problems with alternate credentials
Hi,
another finding related to this issue:
I created a package and when I tried to execute it I received an "access denied" error.
I copied the file into the same directory and the copy worked.
I compared the security permissions of the files and recognized that the package created by PowerShell Studio has replaced all inherited permissions with explicit permission ("Full Control" for System, Administrators and me).
My expectation was that the created exe inherits the permissions of the folder.
Martin
another finding related to this issue:
I created a package and when I tried to execute it I received an "access denied" error.
I copied the file into the same directory and the copy worked.
I compared the security permissions of the files and recognized that the package created by PowerShell Studio has replaced all inherited permissions with explicit permission ("Full Control" for System, Administrators and me).
My expectation was that the created exe inherits the permissions of the folder.
Martin
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: PowerShell Studio problems with alternate credentials
The exe is created via the Windows API CopyFile. It does whatever is defined by the permission structure on your system.
Since it copies the base engine from a template in your installation folder it most likely will copy the permissions from there along with it.
We generally recommend building locally and then deploying to your final destination to avoid permissions problems.
We are not setting or removing any particular permissions when creating an executable.
Since it copies the base engine from a template in your installation folder it most likely will copy the permissions from there along with it.
We generally recommend building locally and then deploying to your final destination to avoid permissions problems.
We are not setting or removing any particular permissions when creating an executable.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.