It works for me:
[cid:[email protected]]
**********************
Windows PowerShell transcript start
Start time: 20150819165404
Username: WEBSTERSLAB\ctxadmin
RunAs User: WEBSTERSLAB\ctxadmin
Machine: LABDC (Microsoft Windows NT 6.3.9600.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 3012
**********************
Transcript started, output file is C:\Temp\transcript.txt
**********************
Windows PowerShell transcript end
End time: 20150819165404
#Set AD Home Folder path.
Start-Transcript -Path "C:\Temp\transcript.txt"
$targetOU = "OU=Accounts,OU=Employees,OU=BR-General,OU=Information
Technology,DC=websterslab,DC=com"
Get-ADUser -ResultSetSize $null -Filter * -SearchBase
"OU=Accounts,OU=Employees,OU=BR-General,OU=Information
Technology,DC=websterslab,DC=com" | Foreach-Object {
$sam = $_.SamAccountName
Set-ADuser -Identity $sam -HomeDrive "K:" -HomeDirectory
"\\labdc\UserData\$($_.SamAccountName)"
}
Stop-Transcript
Thanks
Webster
From: [email protected] [mailto:[email protected]] On
Behalf Of Todd Lemmiksoo
Sent: Wednesday, August 19, 2015 4: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