Question Details

No question body available.

Tags

powershell new-psdrive

Answers (1)

Accepted Answer Available
Accepted Answer
September 17, 2025 Score: 2 Rep: 453,773 Quality: High Completeness: 100%

The administrative share named IPC$, as its names suggests, is used for IPC (inter-process communication), and not itself part of the file-system, so it isn't surprising that you cannot map a drive letter / name to it, which is what New-PSDrive by definition requires.

It follows that you cannot prevent New-PSDrive from reporting an error, and while you could just suppress the error, you wouldn't be able to distinguish the expected, irrelevant error from a true error, such as the target UNC path being non-existent or unreachable.

Thus, the simpler solution is to avoid New-PSDrive and to instead call net use (a direct call to the external executable net.exe), as it does not require a drive letter for connecting to the IPC$ share:

$username = 'administrator'
$target = '\\target-win\ipc$'
$password = Read-Host -Prompt 'Enter password:' -AsSecureString

net use $target /user:$username ([Net.NetworkCredential]::new('', $password).Password)

if ($LASTEXITCODE) { throw "Connecting to $target as user $username failed with exit code $LASTEXITCODE" }

Note:

  • [Net.NetworkCredential]::new('', $password).Password (using type System.Net.NetworkCredential) is a simple way to convert a [securestring] instance such as returned by Read-Host -AsSecureString to its plain-text equivalent.

  • For a PowerShell (Core) 7 alternative and a discussion of the risks of using plain-text passwords (unavoidable with use of net.exe), see this answer.

  • To readers wondering what the purpose of a net use call targeting the (inherently non-file-system) IPC$ share is: per your own feedback, it can be used to indirectly verify user credentials, i.e. a successful connection implies that the supplied credentials are valid.