Chaps.
The below code is from a much larger script but I have copied it out to just get the logic bit working. To give you some understanding
In C:\ADPictures will be a .JPG that will need to match the SamAccountName of an AD user. So if my AD account logon is ABC then there should be ABC.JPG
Now what I am trying to do is perform a check. So if ABC.JPG exists then do something and if ABC.JPG does not exist then do something else. Now when I run the script I either get all found or all not found.
Now I know this is wrong because I don't have a ABC.JPG in C:\ADPictures as a test. What the hell am I doing wrong with the logic?
$ADPictures = "C:\ADPictures"
Get-ADUser -Filter * -SearchBase 'OU= blah blah blah'| ForEach {
$photoFile = Join-Path -Path $ADPictures -ChildPath "$($_.SamAccountName).jpg"
If ($PhotoFile -eq blah blah blah)
{
Write-Host "$_ found"
}
else
{
Write-Host "$_ not found"
}
}