Basic Powershell and home drives

Associate
Joined
6 Jun 2005
Posts
1,856
Location
Cambridge
Hi all,

I'm fairly new to powershell but I'm attempting to write a query to modify the home drive and location for a user. I've done this before and it's worked fine, so I'm not quite sure what I'm doing wrong. Apologies if its blatantly obvious.

So, my command:

dsquery user -name "joe bloggs" | dsmod -hmdrv Z -hmdir "\\File01\User Drives\$username$"

I've seen examples on the internet of people using both $username$ and %username% as tokens.

if I use $username$ token and open up ADUC and locate "joe bloggs" I see the following:

Home Folder - Mapped to Z: with the path \\File01\User Drives\$

and with the %username% token:

Home Folder - Mapped to Z: with the path \\File01\User Drives\%username%

If I add a white space or delete a character, re-add it, and press apply using the %username% token, it will resolve it to the username correctly.

Anyone got any ideas?

Regards,

David
 
Back
Top Bottom