Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PSCredential.Empty.GetNetworkCredential() throws NRE instead of returning null per docs #4696

Copy link
Copy link
@Arnavion

Description

@Arnavion
Issue body actions

Steps to reproduce

> [pscredential]::Empty.GetNetworkCredential()

Expected behavior

$null

Per the docs, an "uninitialized" PSCredential object should return null

MSDN also documents it as such, though only on the page of the explicit cast operator which just calls GetNetworkCredential

Actual behavior

Exception calling "GetNetworkCredential" with "0" argument(s): "Object reference not set to an instance of an object."
At line:1 char:1
+ [pscredential]::Empty.GetNetworkCredential()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

_userName is null so SplitUserDomain throws at the IndexOf()

> $Error[0].Exception.InnerException.StackTrace

   at System.Management.Automation.PSCredential.SplitUserDomain(String input, String& user, String& domain)
   at System.Management.Automation.PSCredential.IsValidUserName(String input, String& user, String& domain)
   at System.Management.Automation.PSCredential.GetNetworkCredential()
   at CallSite.Target(Closure , CallSite , PSCredential )
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.