Skip to content

Instantly share code, notes, and snippets.

View martin9700's full-sized avatar
💭
Updated Set-CellColor -- CICD built too. Now need to make a module out of this.

MartinPugh martin9700

💭
Updated Set-CellColor -- CICD built too. Now need to make a module out of this.
View GitHub Profile
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
For ($Num = 1; $Num -le 12: $Num ++)
{ #Do stuff
}
1..10 | ForEach { #do stuff with $_ }
ForEach ($Number in (1..10))
{ #Do stuff
}
$DCs = Get-ADDomainController -Filter * | Select -ExpandProperty Name
$AllUsers = ForEach ($DC in $DCs)
{ Get-ADUser -Filter * -SearchBase "OU=People,CN=athena,CN=health" -Server $DC
}
Search-ADAccount -AccountInactive -TimeSpan 30 | Set-ADUser -Enabled:$false
Get-ADUser Martin9700 -Properties athenaStartDate,athenaOnLeave
Get-ADUser martin9700 -Properties MemberOf,Description,Organization,Manager,Mail,LastLogonDate
@{Name="Groups";Expression={ ($_.MemberOf | ForEach { (Get-ADGroup $_).Name }) -join ", " }}
@{Name="Manager";Expression={ (Get-ADUser $_.Manager).Name }}