By now a lot of of us are mindful that Active Directory dates are not the easiest bits of information to resolve. Wrapping our heads roughly just how ADVERTISEMENT stores and also encounters dates is very exciting on an intellectual level, and also equally infuriating on a performance level. Accessing this information from PowerShell is a advantageous strategy to understand. If you have yet to dive deep into days it is time.

You are watching: 9,223,372,036,854,770,000

Just one quick date scenario/comment in this write-up. In Working through the AccountExpires attribute in ADVERTISEMENT tbelow is a stvariety endure that is not super intuitive. Not overly complicated, just may have actually you shaking your head.

OK, so the attribute, connected via a user object, is the date that the account will certainly expire. Makes feeling so much.

*

If I need to access this information from PowerShell (imagine looking for all accounts that will certainly expire in next 30 days) then it is additionally reasonably directly forward.

*

If the account has the ‘accountexpires’ attribute switched from a day to ‘Never’ it is likewise pretty basic to understand. The date in the photo listed below is relatively widespread. You will most likely take care of that in your script. But if you view that date it indicates the account is collection to ‘Never’ expire.

*

The trouble arises via a brand-new account wbelow that bit has never been modified. The value is the ‘accountexpires’ attribute is nonfeeling. You will certainly need to manage it in your manuscript. If the manuscript does not handle the negative information, PowerCovering throws an error at you, and then your troubleshooting starts. Many kind of MVPs and the choose have actually discussed this so it is fairly easy to discover yet at initially glance it is a little of an oversight for the cmdlets. I guess you can’t handle everything!

*

Spend some time learning around managing days in PowerCovering. It is an exciting exercise that at times has you scratching your head. Once learned though, it will certainly be simple to manage.


9 Comments
*

*

This was a good article and lead me in the ideal direction, yet didn’t quite deal with my problem. Some users expiration dates had never been touched and they were producing just blanks in my specific script. I overcame that by simply replacing any type of blank result to a details worth. Other accts that had expiration days previous or future were handled appropriately in the manuscript currently.

See more: Was R Kelly Really On The Voice, Why Drake Was Forced To Credit R

$expiry = Get-ADUser -Identity $usersam -Properties accountexpirationday | pick -expandproperty accountexpirationdateif ($expiry = ” “) set-variable -name expiry -value “No expiration date”

I currently had a provision in the manuscript to add X number of days to the current day and perform a compare day for each user.The compare function($expiry) -lt (get-date)would certainly rerotate (in this case) a True for expired and False for not. You might switch the true/false worths for your situation by replacing -lt (less than) via -gt (greater than).

Reply
CategoriesCategoriesSelect CategoryActive Directory(1)AD(8)Azure(2)Bugs(5)Cloud(3)Conferences(1)Cool New Products(42)CVE-2020-1317(1)Desired State Configuration(13)Event Logs(1)Folder Redirection(2)Freeware(7)General(1)General Stuff(93)GP Troubleshooting(15)GPMC(10)GPO Attestation(4)GPO Compare(2)GPOGUY.COM(5)GPSI(1)Group Policy(47)Group Policy(1)Group Policy Automation(11)Group Policy Blog(16)Group Policy Change Auditing(3)Group Policy Cleanup(2)Group Policy Compliance(3)Group Policy Consulting(1)Group Policy Design(9)Group Policy Management(49)Group Policy News(1)Group Policy Performance(6)Group Policy Preferences(18)Group Policy Reporting(16)Group Policy Tools(44)IE Maintenance Policy(4)IE Policy(6)Ignite(1)iPad(1)Microsoft-Related(8)MMS 2012(3)MSTeched(3)Office(3)PowerShell(68)Presentations(2)registry policy(6)RSOP(2)sdm software(59)Security Policy(10)Security-related(24)Server 2012(3)SQL CE(1)TechEd(1)Teched 2012(1)TechEd 2013(1)Technology Futures(2)Tips & Tricks(43)Training(1)Uncategorized(10)VDI(3)Videos(10)Vista-2008 stuff(3)Webinar(3)Whitepaper(12)whitepapers(5)Windows 10(2)Windows 8(14)Windows 8.1(6)Windows Intune(1)Windows RT(1)WMI(2)WMI Filters(2)
Recent Posts