79802949

Date: 2025-10-28 14:50:48
Score: 4
Natty:
Report link

Im having the exact same issue but im using a csv file to read. here is my code.

import-module ActiveDirectory

#enabledusers2 = Get-ADUser -Filter * -SearchBase "ou=TestSite, dc=domain,dc=com"

$enabledusers = (Import-Csv "C:\temp\scripts\UsersToChange.csv")

$enabledusers += @()

Foreach ($user in $enabledusers)

{

$logon = $user.SamAccountName

$tshome = "\\fileserver1\users$\$logon"

$tshomedrive = "H:"

$x = [ADSI]"LDAP://$($user)"

$x.psbase.invokeset("terminalserviceshomedrive","$tshomedrive")

$x.psbase.invokeset("terminalserviceshomedirectory","$tshome")

$x.setinfo()

Set-ADUser -Identity $user -HomeDirectory \\fileserver1\users$\$logon -HomeDrive H:

Write-Output $logon >> C:\temp\EnabledusersForH.csv

}

my .csv file I am using to import is got from using get-aduser and exporting it to a csv. I am using .csv because I have several hundred users that I need to change in different ou's. I have spent days on this. Im a ps newbie aswell so im totally lost.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • No code block (0.5):
  • Me too answer (2.5): having the exact same issue
  • Low reputation (1):
Posted by: Paul McNulty