Monthly Archives: May 2013

6 data recovery tools for SD cards, USB drives and more – Computerworld

6 data recovery tools for SD cards, USB drives and more – Computerworld.

Advertisements

Never miss an appointment again with PowerShell – Virtu-Al.Net

Never miss an appointment again with PowerShell – Virtu-Al.Net.

Windows Server 2012 Virtual Labs

Windows Server 2012 Virtual Labs.

Understanding the Six PowerShell Profiles – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs

Understanding the Six PowerShell Profiles – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs.

Finding Logged On User (and Writing To Other People’s Registry) – Dreaming in PowerShell – PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources

Finding Logged On User (and Writing To Other People’s Registry) – Dreaming in PowerShell – PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources.

Hal Rottenberg – Google+ – Quick ping sweep in #powershell $ip = 1..254 | % {…

Hal Rottenberg – Google+ – Quick ping sweep in #powershell $ip = 1..254 | % {….

Get-ADUser Filter parameter example

Today I needed a list of users that:
– their logon looks like pXXXXXX (employees in our org)
– are not contacts
– are enabled
– are not members of Domain Admins group
– are not required to use smartcards

I came up with this:

$DomainAdminsDN = (Get-ADGroup -Identity 'Domain Admins').DistinguishedName

Get-ADUser -Filter ‘(samAccountName -Like “p*”) -and (ObjectClass -ne “inetOrgPerson”) -and (Enabled -eq “True”) -and (memberOf -ne $DomainsAdminsDn) -and (SmartcardLogonRequired -eq “False”)’ -Properties * |
Where-Object {$_.samAccountName -match “p\d{6}”} | select displayname, samaccountname

There is one thing I could not achive using the Filter parameter on Get-ADUser – the logon name pattern. I settled for selecting users with logon that starts with p in the Get-ADUser filter (samAccountName -Like “p*”) and then used a where-object condition with regex expression.

I found a little gotcha – when a user is not listed in any group the filter “(memberOf -ne $DomainsAdminsDn)” does not work. I will have to think of some other way to filter out Domain Admins members.

smsagent

Scripts, tools and tips, mostly around Microsoft SCCM and EMS

To The Point

Anything about Technology and Business

Brian's Power Windows Blog

Microsoft in the Enterprise. Windows, Hyper-V, Exchange, SQL, and more!

PowerScripting Podcast

Shownotes and links for the PowerScripting Podcast, a podcast to help people learn Windows Powershell

Learn Powershell | Achieve More

What is this Powershell of which you speak?