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 / 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 / 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 / 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 / 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 / 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.
Connect-MsolService
New-MsolDomain -Name sub.contoso.com -Authentication Federated
Connect-MsolService
New-MsolDomain -Name sub.contoso.com -Authentication Managed
# Connect to Exchange Online
$exo = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.outlook.com/powershell-liveid `
-Authentication Basic `
-AllowRedirection `
-Credential $(Get-credential)
Import-PSSession $exo
# Get all mailboxes that do not have litigation hold enabled
function Get-Office365Photo($EmailAddress,$Credential) {
$wc = New-Object System.Net.WebClient
$wc.credentials = $Credential
# Build the URL that'll return the jpeg of the user's photo
$url = "https://outlook.office365.com/ews/exchange.asmx/s/GetUserPhoto?email=$EmailAddress&size=HR96x96"
# Build a path to export it to (.\[email protected])
$outPath = "$pwd\$EmailAddress.jpg"
try {
# Download the image and save it to the current directory
$wc.DownloadFile($url,$outPath)
# Fired when a SMSSec 2000 (AuthN failure) occurs
$SmtpDetails = @{
"SmtpServer" = "smtp.margiestravel.com"
"To" = "[email protected]"
"Subject" = ""
"Body" = ""
"From" = "[email protected]"
"BodyAsHtml" = $true
"Priority" = "High"