MBS - Piqued my curiosity. How can you create a user without a samAccountName?
It’s broadly documented as mandatory and the providers I’m aware of account for it. From: [email protected] [mailto:[email protected]] On Behalf Of Michael B. Smith Sent: Wednesday, August 19, 2015 3:07 PM To: [email protected] Subject: RE: [NTSysADM] PowerShell to change ad Home Directory 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]> [mailto:[email protected]] On Behalf Of Todd Lemmiksoo Sent: Wednesday, August 19, 2015 5:27 PM To: [email protected]<mailto:[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
