If you are looking for help you will need to share your code, not just the error. I verified for you that Set-AzureADUserExtension does take pipeline input for all properties.
What I can't tell is where you set $UPN or why you are piping $user to the command since I can't see your code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…