A collection of assorted Powershell scriptlets that should be useful to remember.
Last active
June 24, 2018 19:19
-
-
Save mcenirm/bed276c8d316a7c805cbbeea07394f66 to your computer and use it in GitHub Desktop.
Assorted Powershell scriptlets to remember...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$alias = 'jdoe' | |
$recipient = Get-Recipient $alias | |
$dn = $recipient.DistinguishedName | |
$filter = "Members -like ""$dn""" | |
Get-DistributionGroup -Filter $filter | |
<# Results: | |
Name DisplayName GroupType PrimarySmtpAddress | |
---- ----------- --------- ------------------ | |
Staff Staff Universal, SecurityEnabled staff@example.com | |
WebTeam Web Team Universal webteam@example.com | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module ActiveDirectory | |
Search-ADAccount -LockedOut | %{ Get-ADUser $_.samaccountname -Properties * } | select samaccountname,lockedout,@{N='lockouttime'; E={[DateTime]::FromFileTime($_.lockouttime)}},@{N='lastlogon'; E={[DateTime]::FromFileTime($_.lastlogon)}} | |
<# Results: | |
samaccountname lockedout lockouttime lastlogon | |
-------------- --------- ----------- --------- | |
Guest True 6/4/2009 1:27:59 AM 12/31/1600 6:00:00 PM | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment