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.
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!
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.
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
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.
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!