Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

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
sylvain1515
Posts: 3
Joined: Tue Apr 12, 2016 7:44 am

Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by sylvain1515 » Wed Mar 08, 2017 2:37 pm

Hi,

Why if I execute this line $Host.ui.PromptForCredential("Windows Title", "Username + Password", "$ENV:Username", "My_Domain", "Default", "Default") with PowerShell Studio 2017 v5.4.136 I am getting username without the domain.

If I do the same command with Windows Powershell ISE the username return by the function always include "My_domain" or another domain if I input one.
Also the Windows Powershell ISE function is doing some Username validation.

Windows Powershell ISE version
Major Minor Build Revision
----- ----- ----- --------
5 1 14393 693

Thank you

User avatar
jvierra
Posts: 11056
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by jvierra » Wed Mar 08, 2017 3:05 pm

See the following:https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Also - I cannot reproduce your issue. "Default" is not a concise target.

User avatar
sylvain1515
Posts: 3
Joined: Tue Apr 12, 2016 7:44 am

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by sylvain1515 » Thu Mar 16, 2017 8:33 am

Hi,

I am running all my test on Windows 10 Enterprise 64 bits system.
The same issue with 2 workstations. On the first one Sapien Powershell Studio 2017 is activated and second one is a trial version.

File test.ps1 contents:

Clear-Host
$PSVersionTable
$CredentialType = [System.Management.Automation.PSCredentialTypes]::Domain
$ValidateOption = [System.Management.Automation.PSCredentialUIOptions]::ValidateUserNameSyntax
$credentialType
$ValidateOption
$Cred = $Host.ui.PromptForCredential("Title", "Username password", "$ENV:Username", "MyDomain", $CredentialType, $ValidateOption)
$Cred.Username

When running test.ps1 with Windows PowerShell ISE and click CANCEL when it prompt the user the output:

Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Domain
Default

When running test.ps1 from Sapien PowerShell Studio 2017 and click CANCEL when it prompt the user the output are:

>> Running (test.ps1) Script...
>> Platform: V5 64Bit

Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Domain
Default
ERROR: Exception calling "PromptForCredential" with "6" argument(s): "Object reference not set to an instance of an object."
test.ps1 (6, 1): ERROR: At Line: 6 char: 1
ERROR: + $Cred = $Host.ui.PromptForCredential("Title", "Username password", "$ ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
ERROR: + FullyQualifiedErrorId : NullReferenceException
ERROR:

>> Execution time: 00:00:02
>> Script Ended
>> Max. CPU: 1 % Max. Memory: 17.26 MB
>> Running (test.ps1) Script...

==============================================================================

Now if I rerun the test.ps1 and type a username and password.

With Windows PowerShell ISE output:

Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Domain
Default
MyDomain\guest


With Sapien PowerShell Studio 2017 output are:

>> Running (test.ps1) Script...
>> Platform: V5 64Bit

Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Domain
Default
guest

>> Execution time: 00:00:06
>> Script Ended
>> Max. CPU: 1 % Max. Memory: 14.07 MB

==============================================================================

Why I do not see the DOMAIN "MyDomain" in front of the username when running with Sapien PowerShell Studio 2017 ?
Why the error "ERROR: Exception calling "PromptForCredential" with "6" argument(s): "Object reference not set to an instance of an object."" with Sapien PowerShell Studio 2017 ?
Why there is username validation with Windows Powershell ISE ? if I enter Username with ";" example "guest ;" and nothing with with Sapien PowerShell Studio 2017 ?

Why this incompatibility ?


Thanks

User avatar
jvierra
Posts: 11056
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by jvierra » Thu Mar 16, 2017 9:33 am

I recommend using the full command which works correctly.

$cred=Get-Credential mydomain\$env:USERNAME
$cred.UserName

User avatar
sylvain1515
Posts: 3
Joined: Tue Apr 12, 2016 7:44 am

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by sylvain1515 » Thu Mar 16, 2017 11:17 am

Yes, I agree, but that does not explain why there are different results.
I liked the ability to customize and get-credential does not allow it.
By the way, the scripts that worked before under Windows Powershell ISE or PowerGUI Script Editor must be adapted to work under Powershell Studio 2017!
Weird

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

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by Alexander Riedel » Mon Mar 20, 2017 9:33 am

Different hosts have a different implementation. Since Microsoft does not exactly document these things well, it always involves guesswork.
In general calling host methods directly rather than using cmdlets will always be a source of differences. Some modification on the host are necessary to accommodate different platforms.
We will investigate and see what we can find out.
Alexander Riedel
SAPIEN Technologies, Inc.

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

Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different

Post by Alexander Riedel » Mon Mar 20, 2017 9:42 am

For future reference, if you have a product specific question please post in the corresponding product forum rather than in the general PowerShell forum.
You will get a faster answer and the PowerShell forum stays on topic for questions related to PowerShell itself. Thanks!
Alexander Riedel
SAPIEN Technologies, Inc.

Who is online

Users browsing this forum: No registered users and 2 guests