NewBee needs some help with Get-member

rated by 0 users
This post has 1 Reply | 2 Followers

Not Ranked
Posts 1
dtougas Posted: 05-20-2010 2:34 PM

I am just beginning to learn powershell and I am trying to determine some of my older Active Directory account that have not logon in over 30 days. I have the quest snapin for Active Directory Manament added and registered. The command I am using and is not working is the follwoing.

 

Get-qaduser |get-member -lastLogon -gt 30

 

What I am having trouble with is I know that -lastlogon is a property of get-qaduser , but how do I know what the proper systax is suppose to be for -lastLogon?  Can someone help me?

Top 500 Contributor
Posts 3

Try a single user so you get only 1 instance of the object and look at the properties.  The result of Get-qaduser username |get-member should show the methods and properties.  The properties are simply values returned.  To focus on the methods and thier inputs try

Get-qaduser username |get-member -membertype method

The way you are trying, you have an array of objects (many users ) if you are not specifying one.  So you have to operate on each  (% = foreach)

 

PS > $today = [DateTime]::Today; 

 

PS> Get-QADUser  | %{$diff= $today-$_.LastLogon;write-host "`n`n$($_.Lastlogon) $($_.name) $($diff.TotalDays) " }

 

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.