Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Sean O'Sullivan seanosullivanuk

👋
View GitHub Profile
@seanosullivanuk
seanosullivanuk / calperm.ps1
Created Oct 15, 2020
Manage Calendar permissions on an Exchange Online mailbox
View calperm.ps1
# View the existing Calendar permissions on the Break Room mailbox
Get-MailboxFolderPermission -Identity breakroom@example.co.uk:\Calendar
# Add John Smith to the Break Room mailbox's calendar, as Reviewer
Add-MailboxFolderPermission -Identity breakroom@example.co.uk:\Calendar -User john.smith@example.co.uk -AccessRights Reviewer
# You can change existing access to the Break Room calendar, with the Set commandlet
Set-MailboxFolderPermission -Identity breakroom@example.co.uk:\Calendar -User john.smith@example.co.uk -AccessRights Editor
# When you are done, use the Remove commandlet
@seanosullivanuk
seanosullivanuk / changeIcon.js
Created Oct 11, 2020
Changing the icon within a Chromium extension, depending upon the OS' dark mode status
View changeIcon.js
// Functions to change the app icon depending upon light or dark mode
function updateIconLightMode() {
chrome.browserAction.setIcon({
path : {
"32": "assets/appicons/32.png",
"24": "assets/appicons/24.png",
"16": "assets/appicons/16.png"
}
});
@seanosullivanuk
seanosullivanuk / exportaduseraccountscsv.ps1
Created Oct 2, 2020
Export a list of Active Directory user accounts to a CSV, grabbing specific properties.
View exportaduseraccountscsv.ps1
Get-ADUser -Filter 'title -ne 0' -Properties givenName,sn,title,mail,sAMAccountName |select-object givenName,sn,title,mail,sAMAccountName | convertto-csv -Delimiter "`t" -NoTypeInformation | Select-Object -Skip 1 | % { $_ -replace '"', ""} | out-file "EmployeeExport.csv" -fo -en ascii
@seanosullivanuk
seanosullivanuk / customdomaindkim.ps1
Created Sep 26, 2020
Enable DKIM on a custom domain, with Microsoft 365 Exchange Online
View customdomaindkim.ps1
# First, create a new DKIM Signing config for your custom domain
New-DkimSigningConfig -DomainName novelica.co.uk -Enabled $true
# Next, output the necessary CNAME records you need to create
Get-DkimSigningConfig -Identity novelica.co.uk | Format-List Selector1CNAME, Selector2CNAME
# Once the CNAME records are in your DNS, enable DKIM signing
@seanosullivanuk
seanosullivanuk / exoimappop.ps1
Created Sep 18, 2020
Filter out any mailbox that has IMAP or POP enabled, with Exchange Online
View exoimappop.ps1
Get-CASMailbox -Filter {ImapEnabled -eq "True" -or PopEnabled -eq "True"} | Select-Object @{n = "identity"; e = {$_.primarysmtpaddress}}
@seanosullivanuk
seanosullivanuk / adcomputerexport.ps1
Created Aug 11, 2020
Export all Computer records from Active Directory to a CSV
View adcomputerexport.ps1
Import-Module ActiveDirectory
Get-ADComputer -Filter * -Properties * |
Select -Property Name,DNSHostName,Enabled,Description |
Export-CSV "C:\Temp\AllComputers.csv" -NoTypeInformation -Encoding UTF8
@seanosullivanuk
seanosullivanuk / passmandatoryparameter.ps1
Created Apr 13, 2019
Pass a mandatory parameter to a PowerShell script
View passmandatoryparameter.ps1
# Pass a mandatory parameter to a PowerShell script
# This example requests a single string, stored as a variable
# e.g. .\passmandatoryparameter.ps1 -FavouriteColour Purple
# If the parameter isn't provided (e.g. .\passmandatoryparameter.ps1), the script will request it,
# but if nothing is passed the script will throw an error.
param(
[Parameter(Mandatory=$true)]
[string]$FavouriteColour
@seanosullivanuk
seanosullivanuk / passparameter.ps1
Created Apr 13, 2019
Pass a parameter to a PowerShell script
View passparameter.ps1
# Pass a parameter to a PowerShell script
# This example requests a single string, stored as a variable
# e.g. .\passparameter.ps1 -FavouriteColour Purple
# If the parameter isn't provided (e.g. .\passparameter.ps1), the script will request it
param (
[string]$FavouriteColour = "$(Read-Host 'Tell me your favourite colour')"
)
@seanosullivanuk
seanosullivanuk / sign.md
Created Oct 19, 2018
Sign PowerShell scripts (Windows)
View sign.md

First, check the code signing certificate(s) are present in the Personal Store:

gci cert:\CurrentUser\My -codesigning

To sign, run the following code block:

$acert =(dir Cert:\CurrentUser\My -CodeSigningCert)[0]
Set-AuthenticodeSignature .\FileName.ps1 -Certificate $acert -TimestampServer http://timestamp.comodoca.com/authenticode
You can’t perform that action at this time.