Skip to content

Instantly share code, notes, and snippets.

@DamianFlynn
DamianFlynn / ApplianceFinished.yaml
Last active April 7, 2021 22:37
Action when an Appliance has finished
blueprint:
name: Appliance has finished
description: Do something when an appliance (like a washing machine or dishwasher)
has finished as detected by a power sensor.
domain: automation
input:
power_sensor:
name: Power Sensor
description: 'Power sensor entity (e.g. from a smart plug device).'
selector:
@DamianFlynn
DamianFlynn / homeassistant_notification.yaml
Created January 22, 2021 13:55
Notification Blueprint
blueprint:
name: Doorbell - Notify Google and send camera snapshot to app
description: Make an announcement over Google devices when the doorbell is pushed
and send a camera snapshot to your app.
domain: automation
input:
doorbell:
name: Doorbell
description: This is the doorbell binary sensor
selector:
connection_messages true
allow_anonymous false
password_file /mosquitto/data/passwd
port 1883
listener 9001
protocol websockets
persistence true
@DamianFlynn
DamianFlynn / Add-ADOfficeDelegations.ps1
Last active October 7, 2015 14:32
PowerShell Function to Resize the System partition of a VM, using an offline process
 #region OU Supporting Functions
#Establish the Delegation Group if necessary
function New-ADDelegationGroup {
Param (
[string] $Site,
[string] $DelegationGroupOUPath,
[string] $DelegationRole = "OU Admin"
)
begin {
@DamianFlynn
DamianFlynn / Blog_Compress-DiskImage.ps1
Created September 2, 2014 14:41
Blog: Compress VHD Disk Image Function [http://www.damianflynn.com/?p=5731]
Function Compress-DiskImage {
param (
[string]$VHDFile
)
process {
Write-Progress "Compress-DiskImage" "Calculating Current Metrics for $VHDFile" -id 1 -percentComplete 10
$FileSizeStart = Get-ChildItem $VHDFile | select length
Write-Progress "Compress-DiskImage - Pass 1" "Mounting Virtual Hard Disk $VHDFile in Read and Write Mode" -id 1 -percentComplete 10
@DamianFlynn
DamianFlynn / Blog_New-VMReferenceImage.ps1
Created September 2, 2014 14:39
Blog: PS Function to create a new VM Reference Image [http://www.damianflynn.com/?p=5731]
Function New-VMReferenceImage {
param (
[string]$VMName = "REF_2012R2_RTM_G1",
[string]$VMPath = "V:\Resources\Pool 1\Resources\",
[string]$SourceVHD = "V:\Resources\Pool 1\Parents\REF_2012R2_RTM_G1.vhdx",
[string]$VSwith = "Corpnet01",
[string]$VMVLanID = 110,
[switch]$PrepareNow
)
# Import Time
# First import the metadata in question from the exported xml file
$exportedquery = Import-Clixml "exportedproperties.xml"
# Now we have the same query as set above during export time in our hands in a variable called exportedquery
# let's do some setting of values
# first, get all the VMs that currently exist in the system
$currentVMs = get-vm | ? {$_.HostName -like "bil-vm-opsc1*"} | sort-object Name -descending
Function global:Add-Path()
{
[Cmdletbinding()]
param (
[parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0)]
[String[]]$AddedFolder
)
# Get the current search path from the environment keys in the registry.
$OldPath=(Get-ItemProperty –Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' –Name PATH).Path
Function Online()
Dim objWmiProvider
Dim objService
Dim strServiceState
Dim iResponse
'Check to see if the service is running
set objWmiProvider = GetObject("winmgmts:/root/cimv2")
set objService = objWmiProvider.get("win32_service='FIMSynchronizationService'")
Function LooksAlive( )
Dim objWmiProvider
Dim objService
Dim strServiceState
set objWmiProvider = GetObject("winmgmts:/root/cimv2")
set objService = objWmiProvider.get("win32_service='FIMSynchronizationService'")
strServiceState = objService.state