[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

How to specify in powershell that property in AD is not set


Hello,

Please advice, how can I specify that value of propert in AD is "not set".

I tried $null etc..

@{N='AccountExpires';E={if  ((get-date ($_.accountexpires)) -eq $null) {write 'NOT SET!'}  else {(((get-date ($_.accountexpires)).adddays(-1)).Tostring(“dd.MM.yyyy”)) }}}

Any idea, many thanks
0
Radim88
Asked:
Radim88
  • 2
1 Solution
 
soostibiCommented:
Unfortunately this depends on the data type. For this specific attribute "never" means 9223372036854775807, so if the value of accountexpires is that number, that means it never expires.
0
 
soostibiCommented:
The other option is to use the AccountExpirationDate attribute, with this you can use:

@{N='AccountExpires';E={if  ($_.accountexpirationdate -eq $null) {write 'NOT SET!'}  else {($_.accountexpirationdate.adddays(-1).Tostring(“dd.MM.yyyy”)) }}}
0
 
Radim88Author Commented:
Thx a lot :-)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now