Password expiry bla...
 
Notifications
Clear all

We appreciate the contributions many of you have been able to make towards repairing the storm damage and keeping a roof over our heads. With your help we’ve been able to complete much of the critical work. There is still work to be done to secure the house and your continued support will be a huge help.

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

Password expiry blank

3 Posts
2 Users
0 Reactions
122 Views
(@rtruss)
Estimable Member Registered
Joined: 6 years ago
Posts: 82
Topic starter  

I have been working on upgrading to the latest version.  I am having issues getting the password expiration for users to display. 

 

I have this, which works from a manually initiated script called get-UserPasswordExpiration.ps1, from another forum poster a few years back.

[get-UserPasswordExpiration.ps1]
try{
$UserDomain,$UserName=([System.Security.Principal.WindowsIdentity]::GetCurrent().Name).split("")
$NetLoginProfile= (Get-WmiObject-Namespace root\cimv2 -Class Win32_NetworkLoginProfile |where-object caption -eq$ENV:username|Select-object 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}
 
but when i embed it into the ini all i get is the text Password Expires:

SET-SECTION=key:get-UserPasswordExpiration,value:get-UserPasswordExpiration.ps1
CMD=color:%Green%,text:Password Expires,trim:1,file:powershell.exe,parameters:%get-UserPasswordExpiration%,code-page:437,thread:1,no-wait:2,hide-no-result:1
 
Same if I call a script:
CMD=file:powershell.exe,parameters:-executionpolicy remotesigned -file get-UserPasswordExpiration.ps1,color:%Green%,text:Password Expires,no-wait:2,hide-no-result:1
 
If I use wmi it works, I just do not seem to be able to get it to display am or pm:
WMI=color:%Green%,text:Password Expires,namespace:root\CIMV2,query:Win32_NetworkLoginProfile where UserType="Normal Account",display:%PasswordExpires_month%/%PasswordExpires_day%/%PasswordExpires_year%%PasswordExpires_hour%:%PasswordExpires_minute%:%PasswordExpires_second%
 
I would like to use the embedded powershell style as it will be easier for others to work with in the future. I just cannot figure out how to make the data show.
Any advice would be greatly appreciated.
my ini is attached it it helps.
 

   
Quote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1903
 

Posted by: @rtruss

I have been working on upgrading to the latest version.  I am having issues getting the password expiration for users to display. 

 

I have this, which works from a manually initiated script called get-UserPasswordExpiration.ps1, from another forum poster a few years back.

[get-UserPasswordExpiration.ps1]
try{
$UserDomain,$UserName=([System.Security.Principal.WindowsIdentity]::GetCurrent().Name).split("")
$NetLoginProfile= (Get-WmiObject-Namespace root\cimv2 -Class Win32_NetworkLoginProfile |where-object caption -eq$ENV:username|Select-object 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}
 
but when i embed it into the ini all i get is the text Password Expires:

 

SET-SECTION=key:get-UserPasswordExpiration,value:get-UserPasswordExpiration.ps1
CMD=color:%Green%,text:Password Expires,trim:1,file:powershell.exe,parameters:%get-UserPasswordExpiration%,code-page:437,thread:1,no-wait:2,hide-no-result:1
 
Same if I call a script:
CMD=file:powershell.exe,parameters:-executionpolicy remotesigned -file get-UserPasswordExpiration.ps1,color:%Green%,text:Password Expires,no-wait:2,hide-no-result:1
 
If I use wmi it works, I just do not seem to be able to get it to display am or pm:
WMI=color:%Green%,text:Password Expires,namespace:root\CIMV2,query:Win32_NetworkLoginProfile where UserType="Normal Account",display:%PasswordExpires_month%/%PasswordExpires_day%/%PasswordExpires_year%%PasswordExpires_hour%:%PasswordExpires_minute%:%PasswordExpires_second%
 
I would like to use the embedded powershell style as it will be easier for others to work with in the future. I just cannot figure out how to make the data show.
Any advice would be greatly appreciated.
my ini is attached it it helps.
 

I'll look into this next week.  Remind me if i forget.

 


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1903
 

i've got this kind of thing:

SET-SECTION=key:get-UserPasswordExpiration,value:get-UserPasswordExpiration.ps1
CMD=color:%Green%,text:Password Expires,trim:1,file:powershell.exe,parameters:%get-UserPasswordExpiration%,display:%1 %2 %3 %4

Desktop Info needs to get it's output from Write-Host and display it using the display option. %4 is the powershell output.  I replaced your exception error with Write-Host 'Error' and that's what it displays.

[get-UserPasswordExpiration.ps1]
try{
$UserDomain,$UserName=([System.Security.Principal.WindowsIdentity]::GetCurrent().Name).split("")
$NetLoginProfile= (Get-WmiObject-Namespace root\cimv2 -Class Win32_NetworkLoginProfile |where-object caption -eq$ENV:username|Select-object 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{Write-Host 'Error'}
Write-Host $PasswordExpires

 

Password Expires : 1 0 1071664452 Error

So I think there is something wrong with the text we're sending to powershell. It gives an error when i paste that code into PowerShell ISE.

 

If i add $error[0] to the catch line it gives:

PS C:\Windows\system32> try{
$UserDomain,$UserName=([System.Security.Principal.WindowsIdentity]::GetCurrent().Name).split("")
$NetLoginProfile= (Get-WmiObject-Namespace root\cimv2 -Class Win32_NetworkLoginProfile |where-object caption -eq$ENV:username|Select-object 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{Write-Host 'Error:' $Error[0]}
Write-Host $PasswordExpires
Error: The term 'Get-WmiObject-Namespace' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or i
f a path was included, verify that the path is correct and try again.

I think there is a space missing in 'Get-WmiObject -Namespace root\cimv2 ... etc'   After that there's other errors but maybe you can take it from there.


   
ReplyQuote
Glenn's Page