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
If ($Filter) | |
{ If ($Filter.ToUpper().IndexOf($Property.ToUpper()) -ge 0) | |
{ $Filter = $Filter.ToUpper().Replace($Property.ToUpper(),"`$Value") | |
Try { | |
[scriptblock]$Filter = [scriptblock]::Create($Filter) | |
} | |
Catch { | |
Write-Warning "$(Get-Date): ""$Filter"" caused an error, stopping script!" | |
Write-Warning $Error[0] | |
Exit |
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
For ($Num = 1; $Num -le 12: $Num ++) | |
{ #Do stuff | |
} |
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
1..10 | ForEach { #do stuff with $_ } |
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
ForEach ($Number in (1..10)) | |
{ #Do stuff | |
} |
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
$DCs = Get-ADDomainController -Filter * | Select -ExpandProperty Name | |
$AllUsers = ForEach ($DC in $DCs) | |
{ Get-ADUser -Filter * -SearchBase "OU=People,CN=athena,CN=health" -Server $DC | |
} |
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
Search-ADAccount -AccountInactive -TimeSpan 30 | Set-ADUser -Enabled:$false |
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
Get-ADUser Martin9700 -Properties athenaStartDate,athenaOnLeave |
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
Get-ADUser martin9700 -Properties MemberOf,Description,Organization,Manager,Mail,LastLogonDate |
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
@{Name="Groups";Expression={ ($_.MemberOf | ForEach { (Get-ADGroup $_).Name }) -join ", " }} |
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
@{Name="Manager";Expression={ (Get-ADUser $_.Manager).Name }} |
OlderNewer