ncomper
asked on
Script to find all AD users with no Home Directory and set
Hi All
I have attempted to write a script to find all enabled users who have a null value for Home directory and then set one as we have a few hundred users who don't have one.
However I think my have a go mentality is greater than my powershell ability :)
I know line one works as if i look at the variable it lists all the users that do not have a Homedirectory, its the actual setting it that I cant get working
Can anyone help me out and explain were I am going wrong
Thanks
I have attempted to write a script to find all enabled users who have a null value for Home directory and then set one as we have a few hundred users who don't have one.
However I think my have a go mentality is greater than my powershell ability :)
$usersHD = Get-ADUser -Filter {(Enabled -eq "True")} -Properties * | Where-Object { $_.homedirectory -eq $null}
foreach ($user in $usersHD)
{
set-aduser -homedrive u: -homedirectory - \\server\share\%username%
}
I know line one works as if i look at the variable it lists all the users that do not have a Homedirectory, its the actual setting it that I cant get working
Can anyone help me out and explain were I am going wrong
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for ncomper's comment #a39698054
for the following reason:
Excellent worked perfect Thanks
Accepted answer: 0 points for ncomper's comment #a39698054
for the following reason:
Excellent worked perfect Thanks
ASKER
Didn't mean to to accept my own comment
ASKER
Excellent, worked perfect Thanks
ASKER