Windows – net use password limitations

command-line-interfacewindows

I'm trying to mount a network folder in a script using net use, and I keep getting a bad password error. I'm using the following syntax:

use \\server\share password /User:serviceaccount

Doing it this way returns a bad password error. If I put * as the password, and enter it at the prompt, it works fine.

I've also tried enclosing the password in double quotes "" to no effect. This particular password is randomly generated and consists of 14 characters of upper, lower, digits, and special characters (in this case the only special character is $).

The script is being run on Windows Server 2008 R2, and it's connecting to Server 2003.

Are there any limitations on the kinds of passwords that can be passed to net use via command line arguments?

EDIT: This is being run in PowerShell.

Best Answer

It turns out whereas the old documentation for net use indicated that you needed to use double quotes, in PowerShell you should use single quotes around the password.