It is possible – unlikely but just barely possible – that the account doesn’t 
have a samaccountname. Did you check?

As Web says, the code works for me.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Todd Lemmiksoo
Sent: Wednesday, August 19, 2015 5:27 PM
To: [email protected]
Subject: [NTSysADM] PowerShell to change ad Home Directory

I still cannot get this script to work completely. It will not append the 
SamAccountName to the end of the home drive share.
#Set AD Home Folder path.
Start-Transcript -Path "C:\Temp\transcript.txt"

$targetOU = "OU=Accounts,OU=Employees,OU=BR-General,OU=Information 
Technology,DC=ghsbtr,DC=net"

Get-ADUser -ResultSetSize $null -Filter * -SearchBase 
"OU=Accounts,OU=Employees,OU=BR-General,OU=Information 
Technology,DC=ghsbtr,DC=net" | Foreach-Object {
    $sam = $_.SamAccountName
    Set-ADuser -Identity $sam -HomeDrive "K:" -HomeDirectory 
"\\ghsmsdfsfs1\UserData\$($_.SamAccountName)<file:///\\ghsmsdfsfs1\UserData\$($_.SamAccountName)>"
}
Stop-Transcript
The result it gives is \\ghsmsdfsfs1\UserData\<file:///\\ghsmsdfsfs1\UserData\>
I need it to give this result 
\\ghsmsdfsfs1\UserData\lemmitt<file:///\\ghsmsdfsfs1\UserData\lemmitt>
Any help is greatly appreciated.


--
T. Todd Lemmiksoo

Reply via email to