Skip to content

Instantly share code, notes, and snippets.

@timdenholm
timdenholm / install-linux-surface-kernel-fedora.yml
Created February 12, 2022 09:59
Install linux-surface kernel for Fedora with Ansible (Microsoft Surface Po 3)
---
- name: Install linux-surface kernel for Fedora
hosts: localhost
become: true
tasks:
- name: Add repository
get_url:
url: https://pkg.surfacelinux.com/fedora/linux-surface.repo
dest: /etc/yum.repos.d/linux-surface.repo
using System.Security.Cryptography.X509Certificates;
// GetCertificate
// Gets a certificate from the user's certificate store that matches
// the specified serial number
static X509Certificate2 GetCertificate(string serialNumber)
{
using (var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser))
{
certStore.Open(OpenFlags.ReadOnly);
@timdenholm
timdenholm / SendTo-SysLog.ps1
Created February 27, 2020 06:21
Send syslog UDP messages (RFC3164, but not RFC5424)
####################################################################################
#.Synopsis
# Send syslog UDP messages (RFC3164, but not RFC5424).
#
#.Description
# Send syslog UDP message with chosen facility, severity, content and tag. These
# messages are typically sent to UNIX/Linux syslog servers, log consolidation
# servers, or perhaps to a segment with an IDS configured to examine their payloads
# for your own custom alerting scheme with integration with a SIEM.
#
@timdenholm
timdenholm / install.sh
Created June 6, 2019 10:29 — forked from mimura1133/install.sh
Enhanced Session for Kali Linux.
#!/bin/bash
# Original : https://raw.githubusercontent.com/Microsoft/linux-vm-tools/master/arch/install-config.sh
###############################################################################
# Update our machine to the latest code if we need to.
#
if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run with root privileges' >&2
exit 1
@timdenholm
timdenholm / sccm-get-su-membership.sql
Created May 1, 2019 03:42
Get SCCM Software Update Collection Membership
SELECT
fcm.Name AS 'host',
fcm.CollectionID AS 'sccm_su_collection_id',
cg.CollectionName AS 'sccm_su_colection_name'
FROM v_FullCollectionMembership fcm
JOIN Collections_G cg ON cg.SiteID = fcm.CollectionID
WHERE cg.CollectionName LIKE 'SU-%'
ORDER BY host
@timdenholm
timdenholm / sccm-get-mw-membership.sql
Last active April 30, 2019 23:16
Get SCCM Maintenance Window Memberships
SELECT
fcm.Name AS 'host',
cg.CollectionName AS 'sccm_collection_name',
fcm.CollectionID AS 'sccm_collection_id',
sw.Name AS 'sccm_mw_name',
CASE sw.ServiceWindowType
WHEN '1' THEN 'All Deployments'
WHEN '4' THEN 'Software Updates'
WHEN '5' THEN 'Task Sequences'
END AS 'sccm_mw_type',
@timdenholm
timdenholm / sccm-get-agents.sql
Last active April 30, 2019 08:48
Get SCCM Agents
SELECT distinct
SYS.Name0 AS 'host',
SYS.User_Name0 AS 'sccm_login_name',
CASE
WHEN SYS.User_Domain0 = SYS.Name0 THEN 'WORKGROUP'
ELSE SYS.User_Domain0
END AS 'sccm_domain',
CASE
WHEN SYS.Client0 = 1 THEN 'Yes'
WHEN SYS.Client0 = 0 THEN 'No'
@timdenholm
timdenholm / scom-get-agents.sql
Last active April 30, 2019 05:55
Get SCOM Agents
USE OperationsManager
GO
SELECT
CASE
WHEN LOWER(ManagedEntityGenericView.DisplayName) LIKE LOWER('%.%')
THEN REPLACE(SUBSTRING(ManagedEntityGenericView.DisplayName,1,CHARINDEX('.',ManagedEntityGenericView.DisplayName)),'.','')
ELSE ManagedEntityGenericView.DisplayName
END AS host,
CASE
WHEN InMaintenanceMode = 1 THEN 'Yes'
/(?:and)(?:\s|(?:%20))(?:"|\'|(?:%27))?(\d)(?:"|\'|(?:%27))?(?:\s|(?:%20))?(?:=|(?:%3D))?(?:\s|(?:%20))?(?:"|\'|(?:%27))?(?:\s|(?:%20))?\1/gi
@timdenholm
timdenholm / rpi-sht31.py
Created April 7, 2018 02:21
Raspberry Pi SHT31 Example
import smbus2
import time
# Get I2C bus; SHT31 address 0x44(68)
bus = smbus2.SMBus(1)
bus.write_i2c_block_data(0x44, 0x2C, [0x06])
time.sleep(0.5)
# SHT31 address 0x44(68)