PowerShell | Répertorier les comptes modifiés avec WhenChanged

Rédigé par O. Clotaire 10 commentaires
Classé dans : PowerShell Mots clés : Active Directory, PowerShell

A la demande de mon client, j'ai eu à vérifier la dernière date de modification du compte d'un utilisateur. 
Le but est de connaitre la date de désactivation du compte.


Dans la console mmc, on peut voir la date de création et de modification du compte. 
Je voulais un retour avec PowerShell pour que cela soit plus rapide la prochaine fois. 

Question. Doit-on prendre en compte l'attribut lastLogonDate ou WhenChanged ?

lastLogonDate permet de savoir si l'utilisateur s'authentifie via son compte AD, quand WhenChanged permet de connaitre la date de modification de l'objet du compte de l'utilisateur.

Je choisis donc l'attribut WhenChanged pour mon script.

Pour un utilisateurs :
# Date de modification pour un utilisateur
Get-ADUser -identity <UserName> -property Name, WhenChanged, lastLogonDate


Pour les utilisateurs depuis x mois :
# Les derniers modifiés depuis $Date mois
$Date = (Get-Date).AddMonths(-1)
Get-ADUser -Filter * -Property WhenChanged, lastLogonDate | Where-Object {$_.WhenChanged -ge $Date} | Ft Name, WhenChanged, lastLogonDate -Autosize

A PROPOS

  • Grace à mon expérience dans les Systèmes d'Information, j'ai le privilège de partager mon expérience en les centralisant sous la forme d’une base de connaissance.
  • Parfois certaines de nos questions ne trouvent pas toujours de réponse. Le domaine de l’informatique évolue rapidement, il est alors important de pouvoir profiter des solutions déjà expérimentés.
  • Ce site sera de plus en plus accessible.
  • Je vous remercie d’avance pour vos éventuelles remarques constructives permettant son amélioration.

10 commentaires

#1  - sex với con lợn a dit :

Hello to every body, it's my first visit of this weblog; this weblog consists
of awesome and actually good data in support of visitors.

Répondre
#2  - Sodo 66 a dit :

Hi fantastic website! Does running a blog like this require a massive amount work?
I have very little knowledge of programming however I had been hoping to start my own blog soon. Anyway,
should you have any suggestions or tips for new blog owners please share.
I understand this is off subject but I just wanted to ask.
Thanks a lot!

Répondre
#3  - 33wincom.sbs a dit :

I'm amazed, I have to admit. Seldom do I come
across a blog that's both educative and engaging, and let me tell
you, you have hit the nail on the head. The problem is something that not enough people are speaking intelligently about.
Now i'm very happy I came across this during
my search for something concerning this.

Répondre
#4  - win88 a dit :

Howdy just wanted to give you a quick heads up. The text in your post seem
to be running off the screen in Internet explorer. I'm not sure if this
is a format issue or something to do with browser compatibility but I thought I'd post to let you know.
The layout look great though! Hope you get the problem resolved soon. Kudos

Répondre
#5  - https://79kingcom.cyou/ a dit :

Do you have a spam problem on this site; I also am a blogger, and I was wanting
to know your situation; many of us have developed some
nice procedures and we are looking to trade strategies with other folks, be sure to shoot me an e-mail if interested.

Répondre
#6  - https://999bet.cyou/ a dit :

It's very effortless to find out any topic on web as
compared to books, as I found this piece of writing at this website.

Répondre
#7  - https://gamebai88.it.com/ a dit :

Asking questions are really pleasant thing if you are not understanding something fully, except this
article provides good understanding yet.

Répondre
#8  - c54 a dit :

I like the helpful information you provide in your articles.
I will bookmark your blog and check again here
frequently. I am quite sure I'll learn lots of new stuff right
here! Good luck for the next!

Répondre
#9  - https://sumiekanekomusic.com/ a dit :

Thank you for another fantastic post. The place
else may just anyone get that kind of information in such an ideal means of writing?

I've a presentation next week, and I am on the search for such information.

Répondre
#10  - nhacaiuytin a dit :

I think the admin of this web page is really working hard
for his site, as here every stuff is quality based data.

Répondre

Écrire un commentaire

 Se rappeler de moi sur ce site
Quelle est le deuxième caractère du mot wmlizn97 ?

Fil RSS des commentaires de cet article

↓