Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You cannot call a method on a null-valued expression.
- At C:commonSCRIPTSPASSWORD_EXPIRY_CUSTOM.ps1:9 char:116
- + ... ires | where { $_.PasswordExpires -gt $null -and `
- + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- + CategoryInfo : InvalidOperation: (:) [], RuntimeException
- + FullyQualifiedErrorId : InvokeMethodOnNull
- $date = Get-Date
- $FirstWarning = $date.AddDays(2).ToShortDateString()
- $SecondWarning = $date.AddDays(7).ToShortDateString()
- $LastWarning = $date.AddDays(15).ToShortDateString()
- $Users = Get-QADUser -SizeLimit 0 -SearchRoot 'mydomain.com/users' -IncludedProperties PasswordExpires |
- Where {
- $_.PasswordExpires -gt $null -and `
- ($_.PasswordExpires).ToShortDateString() -eq "$FirstWarning" -or `
- ($_.PasswordExpires).ToShortDateString() -eq "$SecondWarning" -or `
- ($_.PasswordExpires).ToShortDateString() -eq "$LastWarning"
- }
- $Users = Get-QADUser -SizeLimit 0 -SearchRoot 'mydomain.com/users' -IncludedProperties PasswordExpires | where { $_.PasswordExpires -ne $null -and `
- ( `
- ($_.PasswordExpires).ToShortDateString() -eq "$FirstWarning" -or `
- ($_.PasswordExpires).ToShortDateString() -eq "$SecondWarning" -or `
- ($_.PasswordExpires).ToShortDateString() -eq "$LastWarning" `
- ) `
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement