Home Directory This topic contains 4 replies, has 3 voices, and was last updated by Bryce McDonald 1 year ago. Author Posts May 18, 2017 at 2:53 pm #71002 Chad Nathan JonesParticipant This doesn't work... $Username = "dweatherston" set-aduser $Username -HomeDirectory "\\domain\Users\site\$Username" -HomeDrive u: But this does set-aduser dweatherston -HomeDirectory "\\domain\Users\site\$Username" -HomeDrive u: Why can't I use a variable next to set-aduser? May 18, 2017 at 4:28 pm #71008 Bryce McDonaldParticipant Hey there! I just tested this in my environment and I'm able to get this to work. Is it possible that in your variable, something is misspelled, or you're inputting a user that doesn't exist? May 18, 2017 at 4:31 pm #71011 iain BarnetsonParticipant in cases like this, I usually encapsulate the parameter in $(), so $($Username) May 18, 2017 at 6:31 pm #71012 Chad Nathan JonesParticipant Adding $($Username) resolved the issue. However, can you explain what $() does? May 18, 2017 at 6:39 pm #71014 Bryce McDonaldParticipant Basically it evaluates the value inside of the expression rather than the expression itself. Take the following code for instance: $array = @("a","b","c") $output = "$arr.length" Write-Output $output Is going to give you vastly different results than: $array = @("a","b","c") $output = "$($arr.length)" Write-Output $output Author Posts You must be logged in to reply to this topic.