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
Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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.
- sylvain1515
- Posts: 3
- Last visit: Fri Jun 07, 2019 6:27 am
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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.
Also - I cannot reproduce your issue. "Default" is not a concise target.
- sylvain1515
- Posts: 3
- Last visit: Fri Jun 07, 2019 6:27 am
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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
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
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
I recommend using the full command which works correctly.
$cred=Get-Credential mydomain\$env:USERNAME
$cred.UserName
$cred=Get-Credential mydomain\$env:USERNAME
$cred.UserName
- sylvain1515
- Posts: 3
- Last visit: Fri Jun 07, 2019 6:27 am
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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
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
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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.
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.
SAPIEN Technologies, Inc.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Windows PowerShell ISE vs PowerShell Studio 2017 v5.4.136 result are different
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!
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.
SAPIEN Technologies, Inc.