Good Afternoon,
I have written a script to check directory names with corresponding directory names in the HomeDirectory attribute in Active Directory. If they do not exist in Active Directory I would like the script to tell me. Please can you take a look and tell me where I am going wrong, I am having issues and getting an error:
Insufficient hexadecimal digits.
#Add snap-in and connect to domain
Add-PSSnapin Quest.ActiveRoles.ADManagement | Out-Null
Connect-QADService 'domain.co.uk' | Out-Null
#Ask user for local location of new home directories
Read-Host "What is the location of the folder names?"
#Get list of folder names
$HomeDrives = Get-ChildItem $LocalHomeLocation | ?{ $_.PSIsContainer } | Select-Object Name, FullName
#Get home directories from Active Directory
$Server = Read-Host "Which server do the home directories exist on in AD?"
#Format response
$OriginalServer = "\\$Server*"
#Get list of users from AD that have a home drive on the original server
$HomeDriveUsers = Get-QADUser -SizeLimit 0 -SearchRoot 'domain.co.uk' -SearchScope Subtree | Where {$_.HomeDirectory -like $Server}
#Go through each user, checking each home directory in the user share to see if they have a matching name
ForEach ($HomeDriveFolder in $HomeDrives)
{
$i = 0
ForEach ($HomeDriveUser in $HomeDriveUsers)
{
if ([string]$HomeDriveFolder.Name -match [string]$HomeDriveUser.HomeDirectory)
{
$i = 1
}
}
if ($i -eq 0)
{
Write-Host $HomeDriveFolder.HomeDirectory
}
}