Hi, I'd be happy to help you out with your question. Sorry for the inconvenience caused. To convert the given VBScript code to PowerShell, we need to make some changes to the syntax and object model used in the script. Here is the equivalent PowerShell code: $objSysInfo = New-Object -ComObject "ADSystemInfo" $strUser = $objSysInfo.UserName $objUser = [ADSI]"LDAP://$strUser" $objUser.GetInfo() $strMail = $objUser.Get("mail") Write-Output $strMail In this code, we use the New-Object cmdlet to create a new instance of the ADSystemInfo COM object, which is used to retrieve the current user's name. Then, we use the [ADSI] type accelerator to connect to the user object in Active Directory using its LDAP path. Once we have the user object, we call the GetInfo() method to retrieve the object's properties, and the Get() method to retrieve the user's email address. Finally, we use the Write-Output cmdlet to display the email address on the console. If you have any other questions or need assistance with anything, please don't hesitate to let me know. I'm here to help.
If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.