Some users complained about their drive is not mapping on the computer.
After some researches, we found the path was blank on their Home folder in the profile.
So, I created a PowerShell script to fix it massively.
# Get all users in the OU $allfacstaff = Get-ADUser -Filter * -SearchBase "OU=FacStaff,OU=Campus,DC=mike,DC=com" # Create a new object $facstaff=@() foreach($user in $allfacstaff){ $firstletter = $($user.surname).Substring(0,1) $SSOID = $user.SamAccountName $path = "\\share\$firstletter\$SSOID" $homedriveLetter = "K:" $homeDirectory = Get-ADUser $SSOID -Properties * | Select-Object -ExpandProperty HomeDirectory # Add into object $prop=@{ 'SSOID'=$SSOID; 'HomeDirectory'=$homeDirectory; } $obj = New-Object -TypeName PSObject -Property $prop $facstaff += $obj if($homeDirectory -eq $null){ Set-ADUser -Identity $SSOID -HomeDirectory $path -HomeDrive $homedriveLetter } } # Export to CSV $facstaff | Export-Csv -Path c:\temp\mapDrive.csv -NoTypeInformation
I use the “if loop” to check if the home directory path is blank.
If it is blank, line 26 will setup the drive letter and the drive path.
You can take the line 26 out of the if loop, so it will create a home directory path for all users.
Restart the computer after applying this change, and the mapped drive was back.