I'm getting a bit confused here. I'm probably just missing something this late at night. I have issues with a bit of my code. See the below code.
$MsolUser = Get-MsolUser -UserPrincipalName name@contonso.com
Get-ADUser -filter {emailaddress -Like "$($MsolUser.UserPrincipalName)"} -Properties EmailAddress, LastLogonDate, SamAccountName | select EmailAddress, LastLogonDate, SamAccountName
What the above portion should do, is collect the userprincipalname of the MsolUser from the variable $MsolUser, search for a corresponding emailaddress in AD and return the EmailAddress, LastLogonDate and SamAccountName.
If I try to fetch the value through the variable like above, it doesn't return what it should. It does not give me any errors. I know I have done something like this before, but I just can't wrap my head around it at the moment.
Appreciate the help!
Thanks in advance!