get-aduser not working in PS for Web Access


This code works perfectly in Powershell ISE on the same server, but when running the same script in PS for Web Access I get an error…
$user = Get-ADUser “$user” -Properties mail

Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.

Can someone help please? Thanks!

It’s likely a multi-hop auth issue. When using PWA, you point your web browser at machine A, the PWA box. You give it credentials, which it impersonates. You also specify a machine to connect to (Machine B), and PWA uses Remoting to connect to that machine.

The AD cmdlets, in turn, need to talk to a web service on the DC, machine C. it’s possible your credential isn’t going that far - even if all 3 machines are actually one computer.

It may also not be authentication. It may be that whatever machine PWA is connecting to isn’t able to resolve the domain controller. That seems more likely given the error.