Skip to content

Instantly share code, notes, and snippets.

View lwsrbrts's full-sized avatar

Lewis Roberts lwsrbrts

View GitHub Profile
@lwsrbrts
lwsrbrts / kuduSiteUpload.ps1
Last active May 14, 2017 21:39 — forked from davideicardi/kuduSiteUpload.ps1
Upload a local directory to an Azure Website using kudu and powershell
Param(
[Parameter(Mandatory = $true)]
[string]$websiteName,
[Parameter(Mandatory = $true)]
[string]$resourceGroupName,
[Parameter(Mandatory = $true)]
[string]$sourceDir,
[string]$destinationPath = "/site/wwwroot"
)
@lwsrbrts
lwsrbrts / DCReplicationPesterTest.ps1
Created July 23, 2018 14:41
A pester test to check domain controller replications, grouping by source DC. Obviously requires repadmin.
Describe 'Domain Controllers' {
Context 'Replication Link Status' {
$results = repadmin /showrepl * /csv | ConvertFrom-Csv # Get the results of all replications between all DCs
$groups = $results | Group-Object -Property 'Source DSA' # Group the results by the source DC
foreach ($sourcedsa in $groups) {
# Create a context for each source DC
@lwsrbrts
lwsrbrts / GetTeamsPresenceViaMsGraphApi.ps1
Last active April 3, 2020 14:38
Get your Microsoft Teams presence information from Graph API using an Azure AD App with PowerShell
<#
1. Logged on as a Global Administrator, create a new "App-registration" in Azure AD.
2. Add a Redirect URI. This can point to any web location you like as it isn't used.
2. Add "API permissions" for "Microsoft Graph" to the app for "Presence.Read" and "Presence.Read.All" (Must be delegated).
3. Grant admin consent for the organisation (click the button)
3. Add a new "Secret" to the app which can be used to retrieve a token for the app. Remember to copy the secret!
#>
$clientID = '8806ac69-edde-4069-8128-c01c3aa84eda' # This is the "Application (client) ID" of the application which is granted permission to read presence.
$tenantName = "mytenant.onmicrosoft.com" # This is the name of the tenant for Azure AD.
@lwsrbrts
lwsrbrts / GetCalorificAverage.ps1
Last active February 19, 2024 16:17
Used to obtain the average natural gas calorific value for UK North West region from a set date to now.
$TodayDate = Get-Date -Format "yyyy-MM-dd"
$PreviousReading = Read-Host -Prompt 'Enter the date of the previous reading in dd/mm/yyyy format'
$PreviousReadingDate = Get-Date $PreviousReading -Format "yyyy-MM-dd"
$Soap = @"
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetPublicationDataWM xmlns="http://www.NationalGrid.com/MIPI/">
<reqObject>
@lwsrbrts
lwsrbrts / shelly_gen2_mqtt.yaml
Created January 28, 2022 11:22
shelly gen 2 mqtt
## configuration.yaml
automation: !include automation.yaml
switch: !include switches.yaml
binary_sensor: !include binary_sensors.yaml
sensor: !include sensors.yaml
## automation.yaml
- id: shellies_get_status
alias: Shellies Get Status
description: ''
@lwsrbrts
lwsrbrts / smart_home_panel.yaml
Created March 26, 2023 12:25
Ecoflow Smart Home Panel YAML configuration for Home Assistant
sensor:
# These should be used in the energy dashboard.
- platform: integration
source: sensor.shp_circuit_1_power
name: SHP Circuit 1 Consumed Energy
unit_prefix: k
round: 3
- platform: integration
source: sensor.shp_circuit_2_power
name: SHP Circuit 2 Consumed Energy
@lwsrbrts
lwsrbrts / complete-dashboard-raw-config.yaml
Last active March 30, 2024 15:25
The circuits section of my Smart Home Panel dashboard. Utilises the custom_template
views:
- theme: Backend-selected
title: Smart Home Panel
path: smart-home-panel
icon: mdi:monitor-dashboard
badges: []
cards:
- title: Smart Home Panel
square: false
columns: 1