0

I've a failry simple script that at some point gets to this line

$user = get-aduser -Server <server> -Filter { UserPrincipalName -eq $email } -Properties passwordlastset, passwordneverexpires, Name, DisplayName,UserPrincipalName, extensionattribute15,SamAccountName | Select-Object Name, SamAccountName, DisplayName,UserPrincipalName, extensionattribute15, passwordlastset, passwordneverexpires 
  1. If i run this script on AD1 with -Server set to AD1 it displays passwordlastset and passwordneverexpires as expected.
  2. If i run this script on AD1 with -Server set to AD2 it displays the output as expected.

I then copy the same script to AD2 and run it

  1. If i run this script on AD2 with -server set to AD1 it displays fields correctly.
  2. If i run it on AD2 with -server set to AD2 it displays no values for passwordlastset, passwordneverexpires and extensionattribute. All other fields are displayed correctly.

Why would there be a difference?

MadBoy
  • 3,725
  • 15
  • 63
  • 94
  • If you look at the same information in AD Users and Computers, does it shows blank for all those attributes as well? – shinjijai May 29 '17 at 12:04
  • @shinjijai check my answer. ISE wasn't open as Admin, the attributes are there. – MadBoy May 29 '17 at 13:24
  • Possible duplicate of [Powershell fails to retrieve pwdLastSet from Active Directory](https://serverfault.com/questions/819632/powershell-fails-to-retrieve-pwdlastset-from-active-directory) – Colyn1337 May 30 '17 at 17:23

1 Answers1

0

I didn't notice ISE wasn't open as Administrator on AD2. It was open as admin on AD1 thou. Opening up ISE in Administrative mode solves the issue.

It's weird thou because same user is used in both cases just not in elevated manner.

MadBoy
  • 3,725
  • 15
  • 63
  • 94
  • If you connect to another server, I believe permissions are elevated by default. If this solved your answer, you should mark it as the answer. – Cory Knutson May 30 '17 at 19:43
  • @CoryKnutson i will do that. There is still 14h before I can do it. – MadBoy May 30 '17 at 19:44