I'm trying to get user email of current user using command line. In Powershell i paste these lines and it works
>> $searcher = [ADSISearcher] "(sAMAccountName=$env:USERNAME)"
>> $searcher.PropertiesToLoad.AddRange(@("mail"))
>> $searcher.FindOne().Properties["mail"][0]
test@gmail.com
but when i try to do this in php with exec or shell_exec
$cmd=<<<CMD
$searcher = [ADSISearcher] "(sAMAccountName=$env:USERNAME)" \
$searcher.PropertiesToLoad.AddRange(@("mail")) \
$searcher.FindOne().Properties["mail"][0]
CMD;
print_r(shell_exec($cmd));
it shows me errors undefined variable searcher
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.