Calling WinRS when using a password with spaces

2.8k views Asked by At

I'm trying to call WinRS for some of our automated scripts. I've run into an issue when attempting to pass a password with spaces for the -p argument.

For example,

winrs http://server:5985 -p:my password -u:user dir

fails with the message

winrs.exe:The parameter is incorrect.

Quoting the argument doesn't seem to help,

winrs http://server:5985 -p:"my password" -u:user dir

it fails with the message

Winrs error:Access is denied.

If I type in my password, everything works as expected, however this is not an option for the workflow we're building.

Is it possible to pass a password containing spaces to WinRS? If not, is there a workaround that does not include manual typing?

3

There are 3 answers

0
user4996696 On

The host needs to be prefixed by "-r:" like so:

winrs -r:http://server:5985 -p:my password -u:user "dir"

1
paddy On

Try using a backtick before the space. The backtick is powershell's escape character:

winrs http://server:5985 -p:my` password -u:user dir

This should prevent the space from being interpreted as a delimiter.

0
mudasira786 On

Try using the caret escape character. I believe one of the following combinations might work:

winrs http://server:5985 ^"-p:my` password^" -u:user dir

or

winrs http://server:5985 -p:^"my` password^" -u:user dir

Courtesy of https://www.drupal.org/node/1242152