Skip to content

Instantly share code, notes, and snippets.

View jcallaghan's full-sized avatar

James Callaghan jcallaghan

View GitHub Profile
<#
This Sample Code is provided for the purpose of illustration only and is not intended to be used in a production environment.
THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. We grant
You a nonexclusive, royalty-free right to use and modify the Sample Code and to reproduce and distribute the object code
form of the Sample Code, provided that You agree: (i) to not use Our name, logo, or trademarks to market Your software
product in which the Sample Code is embedded; (ii) to include a valid copyright notice on Your software product in which the
Sample Code is embedded; and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and against any claims
or lawsuits, including attorneys’ fees, that arise or result from the use or distribution of the Sample Code.
Please note: None of the conditions
# Created by SAMCOS @ MSFT, Collaboration with others!
## You must first connect to Microsoft Teams Powershell & Exchange Online Powershell for this to work.
## Links:
## Teams: https://www.powershellgallery.com/packages/MicrosoftTeams/1.0.0
## Exchange: https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps
## Have fun! Let me know if you have any comments or asks!
$AllTeamsInOrg = (Get-Team).GroupID
$TeamList = @()
Write-Output "This may take a little bit of time... Please sit back, relax and enjoy some GIFs inside of Teams!"
Write-Host ""
# Script requires AAD and CredentialManaer modules, AAD B2b user management permissions
Import-Module AzureADPreview
function Remove-PendingGuestInvites{
Param(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true)]
[switch]
# Remotely create a number of content databases using New-SPContentDatabase
# https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/new-spcontentdatabase
$SPServers = @("server1")
$webApp = "https://webapp.domain.com"
$databasesRequired = 10
$databasePrefix = "AG5Q_Prefix_Content"
$databaseServer = "DBserver.domain.com"
# Prepare remote PS session and load SP module
@jcallaghan
jcallaghan / Home-Assistant - Air Freshener Deep Sleep.yaml
Created March 13, 2020 18:41
The following is used to operate the air fresheners when they're in deep sleep mode.
Deep sleep switch
@jcallaghan
jcallaghan / Home-Assistant - Toilet Flush Automation.yaml
Created March 13, 2020 18:40
This automation is triggered in Home Assistant when the toilet is flushed. It activates the air freshener and also nags through text-to-speech to close the seat lid if it is left open.
alias: 'Bathroom - Toilet flush air freshener + tts'
trigger:
# Trigger when the toilet is flushed usng a sensor on the cistern flush arm.
platform: state
entity_id: binary_sensor.toilet_flusher_contact
to: "on"
action:
@jcallaghan
jcallaghan / ESPHome - Air Freshener Config - Deep Sleep.yaml
Created March 13, 2020 18:33
This is the ESPHome configuration I've used to enable deep sleep.
# Deep sleep yaml highlights
@jcallaghan
jcallaghan / Home-Assistant - Sonos Say - Automation.yaml
Last active March 13, 2020 16:09
I use the following components to play text-to-speech (TTS) on one or many of my Sonos speakers.
# https://www.home-assistant.io/docs/automation/
automation: !include_dir_list ../automations
alias: 'Bathroom - Bath full alarm'
id: bath_full
trigger:
# Trigger when the water sensor in the bath turns on
@jcallaghan
jcallaghan / ESPHome - Air Freshener Config.yaml
Created March 12, 2020 23:33
This is the ESPHome configuration I use for my IoT air fresheners.
substitutions:
system_name: esph_dining_room_air_freshener
friendly_name: Esph Dining Room Air Freshener
esphome:
name: ${system_name}
platform: ESP32
board: esp32doit-devkit-v1
wifi:
@jcallaghan
jcallaghan / Home-Assistant - Alexa Automation.yaml
Last active October 27, 2021 07:59
This Home Assistant automation is trigger through an Alexa automation.
alias: Alexa - It's stinky
trigger:
# Trigger based on Alexa routine turning on the light.
- platform: state
entity_id: light.alexa_virtual
to: 'on'
condition: