Ok,
I need to get the HomeDirectory of a user and copy it to another user. Problem is I can't get JUST the home drive. Can anyone help.
Here is my code (or a sampling of a larger script):
$oldID = "WSTG0001"$newID = "WSTG0006"
$oldHome = get-aduser -LDAPFilter "(sAMAccountName=$oldID)" -Properties homeDirectory | Select-Object -Property homeDirectory
New-ADUser -Path "OU=AppServices,OU=Resources,DC=DOM,DC=ROOT,DC=DOM,DC=ORG" -UserPrincipalName $newID -Name $newID -SamAccountName $newID -DisplayName $newID -GivenName $newID -AccountPassword (ConvertTo-SecureString -AsPlainText "dmsteam" -Force) -ScriptPath msklogon -HomeDrive "G" -HomeDirectory $oldHome -Enabled $True
The problem is that $oldHome keeps getting set to @{homeDirectory=\\SERVER\home}
I just want it to be "\\SERVER\home"
Can anyone help? Thanks!