Link to home
Start Free TrialLog in
Avatar of namerg
namergFlag for United States of America

asked on

How to read/query Active Directory in real time without being read by a variable

If i query AD and add all the information on variable $ad, the contents are in memory and not a realtime stage.

So, if i do modify properties of an AD user, all those modification are done through $ad via Set-ADUser.

In every property change i prompt "are you sure about the change of this for that?" and give the opportunity of changing more properties of the same user by asking for it.

But, if i typed a wrong last name and the time comes to ask "are you sure about the change of this for that" $ad has the old value not the new value. Is there anyway to query AD in real time?

<code>
$ad = Get-ADUser -filter * -Properties sAMAccountName,sn,givenName,department,title,telephoneNumber,employeeID,employeeNumber  -SearchBase "OU=ou,DC=domain,DC=com" | Select-Object  sAMAccountName,sn,givenName,department,title,telephoneNumber,employeeID,employeeNumber
</code>

Thanks for your help,
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of namerg

ASKER

Yes, @footech I know is little hard to understand. Working on the flow chart.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of namerg

ASKER

@Subsun,
Can you check the flowchart diagram in the bottom on this question https://www.experts-exchange.com/questions/27987781/Repetitive-Menu-in-Powershell.html

Let me know what you think.. thanks