Skip to content

Instantly share code, notes, and snippets.

View chrisbrownie's full-sized avatar
🛩️
computering

Chris Brown chrisbrownie

🛩️
computering
View GitHub Profile
@chrisbrownie
chrisbrownie / Get-WebSiteCertificateThumbprint.ps1
Created October 18, 2016 06:20
Gets the thumbprint of a web site's HTTPS certificate
<#
.SYNOPSIS
Returns the SSL thumbprint for the certificate of the website
.DESCRIPTION
The certificate's thumbprint is a hash of the certificate's properties and keys. It is, in theory, a globally unique identifier.
.OUTPUTS
System.String
Get-WebSiteCertificateThumbprint returns a string with the certificate's thumbprint.
@chrisbrownie
chrisbrownie / Get-ComputersWithCertificate.ps1
Created October 18, 2016 03:40
Gets computers that have a certificate matching a thumbprint
$thumbprintsToSearchFor = @(
"aabbccddeeffgg"
)
$OUs = @(
"OU=Servers,DC=contoso,DC=com",
"OU=OtherServers,DC=contoso,DC=com"
)
$logonHistoryDays = 90
@chrisbrownie
chrisbrownie / EncryptBasedonSubject.ps1
Created October 6, 2016 08:20
Encrypt Messages with OME based on Message Subject
New-TransportRule -Name "Encrypt mail with [encrypt] in subject" `
-RuleErrorAction Defer `
-SubjectMatchesPatterns '(?:^|\W|\w)\[encrypt\](?:$|\W|\w)'
-SetAuditSeverity Low `
-ApplyOME $true
@chrisbrownie
chrisbrownie / EncryptBasedonRecipientDomain.ps1
Created October 6, 2016 08:19
Encrypt Messages with OME based on Recipient Domain
New-TransportRule -Name "Encrypt mail to Woodgrove Bank" `
-RuleErrorAction Defer `
-RecipientAddressMatchesPatterns '^[A-Z0-9._%+-][email protected]$'
-SetAuditSeverity Low `
-ApplyOME $true
@chrisbrownie
chrisbrownie / EncryptBasedonMessageSensitivity.ps1
Last active October 6, 2016 08:19
Encrypt Messages with OME based on Message Sensitivity
New-TransportRule -Name "Encrypt mail marked as Private or Confidential" `
-RuleErrorAction Defer `
-HeaderMatchesMessageHeader "Sensitivity"`
-HeaderMatchesPatterns "Private","Company-Confidential" `
-SetAuditSeverity Low `
-ApplyOME $true
@chrisbrownie
chrisbrownie / EncryptBasedOnSenderGroupMembership.ps1
Created October 6, 2016 08:17
Encrypt Messages with OME based on Sender Group Membership
New-TransportRule -Name "Encrypt mail from the Security team" `
-RuleErrorAction Defer `
-FromMemberOf '[email protected]' `
-SetAuditSeverity Low `
-ApplyOME $true
@chrisbrownie
chrisbrownie / AddOrUpdateInTextFile.ps1
Created September 20, 2016 23:07
Adds or updates text between two markers in a text file.
function AddOrUpdateTextInFile() {
Param(
$File,
[string]$StartString,
[string]$EndString,
[string]$ReplacementString
)
$fileContent = Get-Content $File -ReadCount 512
@chrisbrownie
chrisbrownie / Get-RandomPhoneNumber.ps1
Created September 19, 2016 03:45
Generates a random phone number (completely random, not necessarily a valid one)
function Get-RandomNumber ([int]$min,[int]$max,[switch]$leadingZeroes) {
$number = Get-Random -Minimum $min -Maximum $max
if ($leadingZeroes) {
if ($number.ToString().Length -lt $max.ToString().Length) {
$number.Tostring().PadLeft($max.ToString().Length,"0")
} else {
$number.ToString()
}
} else {
$number.ToString()
@chrisbrownie
chrisbrownie / GetExchange2003SmtpAddresses.vbs
Created September 19, 2016 03:43
Returns all SMTP proxy addresses for all users in a given domain or OU in CSV format
'======================================================================
' ListAllSMTPAddresses.vbs
'======================================================================
' Author: Chris Brown ([email protected])
' Date: 07/10/2014
' Details: Returns all SMTP proxy addresses for all users in a given
' domain or OU in CSV format
' Source: Unknown (I forget if I wrote this myself or found it somewhere)
'
'
@chrisbrownie
chrisbrownie / GetExchange2003DistributionGroups.vbs
Created September 19, 2016 03:42
Returns all mail-enabled groups in the domain
'======================================================================
' GetDistributionGroups.vbs
'======================================================================
' Author: Chris Brown ([email protected])
' Date: 09/10/2014
' Details: Returns all mail-enabled groups in the domain
' Source: Unknown (I forget if I wrote this myself or found it somewhere)
'======================================================================
' Everything below this will be searched. Must be in the format