“net use” in PowerShell without specifying drive

Question:

With “net use”, you could do the following:

It would then prompt for a password, and any further CIFS connections made to that server using any program (cmd, Explorer, Word, etc) would automatically use that credential.

Is there an equivalent way of doing this in PowerShell? I know New-PsDrive usually provides the answer for “net use”, but it requires a drive letter to map:

I don’t want to map a drive, I just want to say “when I connect to this server, use this credential”. Is there a way?

Answer:

The cmdlet New-SMBMapping is (by and large) functionally equivalent to New-PSDrive. However, the equivalent parameter -LocalPath (-Name in New-PSDrive) is not required so you shouldn’t get the above error.

Source:

“net use” in PowerShell without specifying drive by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply