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
function Export-ServerCertificate { | |
[CmdletBinding()]Param( | |
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | |
[Alias('HostName')] | |
[String] | |
$ComputerName, | |
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | |
[Alias('TCPPort')] | |
[ValidateRange(1,65000)] |
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
function Send-Mail { | |
[CmdletBinding()]Param( | |
[Parameter(Mandatory)] | |
[String] | |
$From, | |
[Parameter(Mandatory)] | |
[String[]] | |
$To, |
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
function Reset-ADPassword { | |
[CmdletBinding(SupportsShouldProcess)]Param( | |
[Parameter(Position=0,Mandatory)] | |
[String] | |
$UserName, | |
[Parameter(Position=1)] | |
[String] | |
$Domain = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).Name, |
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
[CmdletBinding()]Param( | |
[Parameter(Mandatory)] | |
[String] | |
$UserPrincipalName, | |
[Parameter(Mandatory)] | |
[AllowEmptyString()] | |
[String] | |
$NewValue, |
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
function PageMembers { | |
[CmdletBinding()]Param( | |
[Parameter(ValueFromPipeline)] | |
[System.DirectoryServices.SearchResult]$SearchResult | |
) | |
process { | |
<# | |
When getting a search result back for a group object you will likely get | |
either a member property OR a member;range=0-1499. If you get the later |
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
$arrayList = New-Object -TypeName System.Collections.Generic.List[int] | |
0..9999 | ForEach-Object { $arrayList.Add($PSItem) } | |
$iterations = 1000 | |
$results = New-Object -TypeName System.Collections.Generic.List[PSCustomObject] | |
1..$iterations | ForEach-Object { | |
$number = Get-Random -Maximum 9999 | |
$resultObject = [PSCustomObject]@{ | |
whereMethod = (Measure-Command -Expression { $arrayList.where{$PSItem -eq $number} }).Milliseconds |
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
$testTitle = 'stuff' | |
$results = New-Object System.Collections.Generic.List[PSCUstomObject] | |
0..99 | ForEach-Object { | |
# Used to store the timing of the query and the update times. | |
$testResults = [PSCustomObject]@{ | |
Test1Query = $Null | |
Test1UpdateAvgMS = $Null | |
Test2Query = $Null | |
Test2UpdateAvgMS = $Null | |
} |
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
[CmdletBinding(SupportsShouldProcess)]Param() | |
#region Collect user and group information | |
<# | |
Use a custom object to store what the group membership SHOULD look like. | |
We'll use this later to do a comparison with the current group members | |
to see who we need to add\remove. | |
#> | |
$correctGroupState = [PSCustomObject]@{ | |
Administrative = New-Object -TypeName System.Collections.Generic.List[String] |
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
[CmdletBinding(SupportsShouldProcess)]Param() | |
$date = get-date | |
$date = $date.ToString("yyyyMMdd") | |
#set log file path | |
$logFile = "c:\temp\" + $date + "_remove_disabled_users_rights.csv" | |
try { | |
$disabledUsers = Get-ADUser -Filter "enabled -eq '$false' -and name -ne 'guest' -and name -ne 'krbtgt'" -Properties memberOf -ErrorAction STOP |
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
#requires -Module ActiveDirectory | |
[CmdletBinding(SupportsShouldProcess)]Param() | |
$PSDefaultParameterValues = @{'*:ErrorAction'='STOP'} | |
$dcHash = @{} | |
try { | |
Get-ADForest | Select-Object -ExpandProperty Domains | ForEach-Object { | |
$domain = $psitem | |
$dc = Get-ADDomainController -Discover -DomainName $domain | Select-Object -ExpandProperty hostname |
NewerOlder