Yes the account does have a SamAccountName. Looking at WEbster's code it maybe the user ID that Powershell is using to execute the command. Will test.
Thanks for looking at it.. On Wed, Aug 19, 2015 at 5:06 PM, Michael B. Smith <[email protected]> wrote: > 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)" > } > Stop-Transcript > > The result it gives is \\ghsmsdfsfs1\UserData\ > > I need it to give this result \\ghsmsdfsfs1\UserData\lemmitt > > Any help is greatly appreciated. > > > > -- > > T. Todd Lemmiksoo > -- T. Todd Lemmiksoo
