User Password Expiration Date
› Forums › Desktop Info › User Password Expiration Date
Tagged: IF Password expiry date
- This topic has 16 replies, 4 voices, and was last updated 11 months ago by
rtruss.
-
AuthorPosts
-
-
11 January, 2022 at 8:37 pm #4984
I need to show the password expiration date. Can this be achieved with Desktopinfo?
-
11 January, 2022 at 9:40 pm #4985
something like this:
INI1WMI=namespace:root\cimv2,query:Win32_NetworkLoginProfile where UserType="Normal Account" and Privileges>0,text:Password Expires,display:%PasswordExpires_year%-%PasswordExpires_month%[2.0d]-%PasswordExpires_day%[2.0d] -
11 January, 2022 at 10:20 pm #4986
Your solution works fantastic. Great piece of software, by the way. One problem with your solution is with users who have the expiration date set to “Never”, desktopinfo displays <NULL>. Also, it would be nice if i could display the number of days left till expiration.
-
12 January, 2022 at 9:39 am #4997
This will return a result only if there is a password expiry date. If the date is null, ie password does not expire, then the “hide-no-result” option will cause the item to not display.
INI1WMI=interval:10,namespace:root\cimv2,query:Win32_NetworkLoginProfile where UserType="Normal Account" and Privileges>0 and NOT PasswordExpires is null,text:Password Expires,display:%PasswordExpires_year%-%PasswordExpires_month%[2.0d]-%PasswordExpires_day%[2.0d],hide-no-result:1
-
-
11 January, 2022 at 11:24 pm #4987
Another problem has arisen. On my comp all works fine, but on the terminal I’m running as a server, no WMI query gets executed. Do I have to configure something to have WMI queries run?
-
12 January, 2022 at 9:40 am #4998
probably a permission issue. try running DTI as admin.
-
-
12 January, 2022 at 12:01 am #4988
-
12 January, 2022 at 12:24 am #4990
It works when switching to version 3. But what is strange, on my comp it lists only my expiry date but on the server, it lists the expiration dates for all users. the same query in powershell:
Get-WmiObject -query "SELECT * FROM Win32_NetworkLoginProfile where UserType='Normal Account' and Privileges>0'
returns 1 result on my comp and all user expiration dates on the server.-
12 January, 2022 at 9:51 am #4999INI123HOST=set:host,hidden:1USER=set:user,hidden:1WMI=interval:10,namespace:root\cimv2,query:Win32_NetworkLoginProfile where Name="%HOST%\\%USER%" and NOT PasswordExpires is null,text:Password Expires,display:%PasswordExpires_year%-%PasswordExpires_month%[2.0d]-%PasswordExpires_day%[2.0d],hide-no-result:1
-
-
12 January, 2022 at 6:45 pm #5000
Thanks for the quick response. The filtering works fine. But unfortunately the date is not correct (or I am misinterpreting the result – I expect to get the expiration date for AD). For the expiration date, I get 22.02.2022 but the correct expiration date is 11.04.2022. The server is part of a domain. Also the query is pretty slow (1 minute – approximately 3500 users).
I get the correct date when running in the commandline:net user <USERNAME> / DOMAIN
The result gives me multiple lines for output. One is “Password expires” with the correct date and the query is instantenous. Could it somehow be possible to use this command prompt query to get the result?
-
12 January, 2022 at 7:17 pm #5001
I can’t account for the date, possibly different between the local machine and the domain server. You can use the CMD item but it returns a big chunk of unfilterable text. You can also research that query using powershell but that’s above my pay grade.
-
13 January, 2022 at 12:43 am #5002
I found that you can run this net user ‘username’ /domain | find “Password expires” It IS case sensitive sadly but I was able to get the expiration date that way. Now if only I could figure out how to do this with my Azure AD users using modern workplace Azure ad joined devices.
-
This reply was modified 1 year ago by
rtruss.
Attachments:
-
This reply was modified 1 year ago by
-
13 January, 2022 at 1:14 am #5005
So I have a mixed environment and only want to show password expiry to my hybrid computers as the azure only units simply will not work.
Here is what I have tried thus far to no avail 🙁DOMAIN=hide-no-result:1
If=value1:%DOMAIN%, value2:domain.name comp:eq
WMI=namespace:root\cimv2,query:Win32_NetworkLoginProfile where UserType=”Normal Account” and Privileges>0,color:%Green%,text:Password Expires on:,display:%PasswordExpires_month%[2.0d]/%PasswordExpires_day%[2.0d]/%PasswordExpires_year%Am I missing something as the above code will not allow the expire date to display.
Thanks in advance all.
-
13 January, 2022 at 6:16 am #5007
what does it display?
-
14 January, 2022 at 11:26 pm #5010
Solved it eventually like this:
CMD=file:cmd.exe,parameters:/c net USER %username% /DOMAIN | find "Password expires" ,text:,wide:1,color:#FF6347
The only pitfall is that I don’t know how to replace the “Password expires” text in the resulting output.
-
10 February, 2022 at 1:37 pm #5083
Here is how I do the same thing 🙂
PWSH Code, in a script “get-UserPasswordExpiration.ps1” stored in the same directory as desktopinfo64.exe1234567try{$UserDomain,$UserName=([System.Security.Principal.WindowsIdentity]::GetCurrent().Name).split("\")$NetLoginProfile = Get-WmiObject -Namespace root\cimv2 -Class Win32_NetworkLoginProfile -Filter "caption like ""$UserName""" -Property PasswordExpires$NetPwdExp =$NetLoginProfile | Select-Object -ExpandProperty PasswordExpires$PasswordExpires = [Management.ManagementDateTimeConverter]::ToDateTime($NetPwdExp)get-date -date "$PasswordExpires" -Format "M/d/yyyy h:m:ss tt"}catch{$null}Outputs the time in
3/16/2022 12:55:55 PM
Dekstopinfo.ini
CMD=file:powershell.exe,parameters:-executionpolicy bypass -noprofile -file get-UserPasswordExpiration.ps1 ,text:Password Expires,hide-no-result:1
-
This reply was modified 11 months ago by
Albert Hernandez. Reason: edit text
-
This reply was modified 11 months ago by
-
18 February, 2022 at 5:33 am #5111
sorry for the delay with a reply. someone asked for what it looks like.
whe\n I use this code: WMI=interval:600,namespace:root\cimv2,query:Win32_NetworkLoginProfile where UserType=”Normal Account” and Privileges>0,color:%Green%,text:Password Expires on:,display:%PasswordExpires_month%[2.0d]/%PasswordExpires_day%[2.0d]/%PasswordExpires_year%,hide-no-result:1i get the attached output.
If there was a option for active user or console user that may help.I will try the script idea posted by albert as well. I am trying to avoid using additional scripts with it for simplicity purposes but if that is what it takes, i will go with it. Thanks to all.
Attachments:
-
-
AuthorPosts
- You must be logged in to reply to this topic.