This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi. I can see where I am having an issue here. I am trying to search for computers that havent been used in the last year, and have a name beginning with "TGNX" or "TGDX". Extremely easy using a wildcard, except we have a type named "TGIX" that I do not want included in the results. So I created my query as shown, but it seems like it is querying "not used in last 12 months and called TGNX" OR "called TGDX" and therefore giving TGDX results INCLUDING those used in the last year. I can see why, and i'm sure its down to brackets but i'm getting nowhere.
$then = (Get-Date).AddDays(-365) # The 365 is the number of days from today since the last logon.
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then -and Name -like 'TGDX*' -or Name -like 'TGNX*' } | FT Name,lastLogonDate | Out-File -FilePath C:\What_I_Found.txt
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...