Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. You cannot call a method on a null-valued expression.
  2. At C:commonSCRIPTSPASSWORD_EXPIRY_CUSTOM.ps1:9 char:116
  3. + ... ires | where { $_.PasswordExpires -gt $null -and `
  4. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. + CategoryInfo : InvalidOperation: (:) [], RuntimeException
  6. + FullyQualifiedErrorId : InvokeMethodOnNull
  7.  
  8. $date = Get-Date
  9.  
  10. $FirstWarning = $date.AddDays(2).ToShortDateString()
  11. $SecondWarning = $date.AddDays(7).ToShortDateString()
  12. $LastWarning = $date.AddDays(15).ToShortDateString()
  13.  
  14.  
  15.  
  16. $Users = Get-QADUser -SizeLimit 0 -SearchRoot 'mydomain.com/users' -IncludedProperties PasswordExpires |
  17. Where {
  18. $_.PasswordExpires -gt $null -and `
  19. ($_.PasswordExpires).ToShortDateString() -eq "$FirstWarning" -or `
  20. ($_.PasswordExpires).ToShortDateString() -eq "$SecondWarning" -or `
  21. ($_.PasswordExpires).ToShortDateString() -eq "$LastWarning"
  22. }
  23.  
  24. $Users = Get-QADUser -SizeLimit 0 -SearchRoot 'mydomain.com/users' -IncludedProperties PasswordExpires | where { $_.PasswordExpires -ne $null -and `
  25. ( `
  26. ($_.PasswordExpires).ToShortDateString() -eq "$FirstWarning" -or `
  27. ($_.PasswordExpires).ToShortDateString() -eq "$SecondWarning" -or `
  28. ($_.PasswordExpires).ToShortDateString() -eq "$LastWarning" `
  29. ) `
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement