Skip to content

Instantly share code, notes, and snippets.

View thomasswilliams's full-sized avatar

Thomas Williams thomasswilliams

View GitHub Profile
@thomasswilliams
thomasswilliams / remote-desktop-history.ps1
Last active November 28, 2023 22:19
PowerShell script to list remote desktop logon, logoff, disconnect events from the Terminal Services event log for a passed computer, collection of computers, or computer name(s) from prompt
<#
.SYNOPSIS
Get remote desktop sessions for a specified computer or computers, from the Terminal
Services event log. Adapted from https://serverfault.com/a/687079/78216, https://ss64.com/ps/get-winevent.html
Requires appropriate permission on computers to call Get-WinEvent remotely, PowerShell Active Directory module.
If using Windows Firewall, may require enabling "Remote Event Log Management" rule (from
https://social.technet.microsoft.com/Forums/en-US/69fba4e0-a248-4d1c-9e0d-80071a2a446d/getwinevent-the-rpc-server-is-unavailable)
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
@thomasswilliams
thomasswilliams / startup-shutdown-history.ps1
Created July 17, 2020 03:30
PowerShell script to get history from Windows event log for events relating to startup & shutdown for a specified computer or computers
<#
.SYNOPSIS
Get history from Windows event log for events relating to startup & shutdown for a specified computer or computers.
Adapted from https://social.technet.microsoft.com/wiki/contents/articles/17889.powershell-script-for-shutdownreboot-events-tracker.aspx
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
Pass one or more computer names, or run without parameters to be prompted for computer name(s).
.PARAMETER computers
@thomasswilliams
thomasswilliams / server-uptime.ps1
Created July 17, 2020 03:29
PowerShell script to return the boot time and calculated uptime in days, hours and minutes for a passed computer, collection of computers, or computer name(s) from prompt
<#
.SYNOPSIS
For a passed computer, collection of computers, or computer name(s) from prompt, return the boot time
and calculated uptime in days, hours and minutes.
By Thomas Williams <https://github.com/thomasswilliams>
.DESCRIPTION
Pass one or more computer names, or run without parameters to be prompted for computer name(s). Queries
WMI/CIM Win32_OperatingSystem class "LastBootUpTime", so need appropriate permissions, and WS-Management
service needs to be running.
@thomasswilliams
thomasswilliams / .eslintignore
Created November 19, 2019 10:38
Express & TypeScript Pedals API level 2, Nov 2019 - .eslintignore
node_modules
dist
@thomasswilliams
thomasswilliams / package.json
Last active November 20, 2019 05:58
Express & TypeScript Pedals API level 2, Nov 2019 - package.json
{
"name": "pedals-api-nov-2019",
"version": "0.0.2",
"scripts": {
"serve": "npm run tsc && node ./dist/server.js",
"tsc": "tsc",
"lint": "eslint \"src/**/*.ts\""
},
"eslintConfig": {
"root": true,
@thomasswilliams
thomasswilliams / tsconfig.json
Created November 18, 2019 10:44
Express & TypeScript Pedals API base, Nov 2019 - tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
@thomasswilliams
thomasswilliams / server.ts
Last active November 18, 2019 10:58
Express & TypeScript Pedals API base, Nov 2019 - server.ts
// in src directory
import express from "express";
const app = express();
// route: get pedals collection
app.get("/pedals", (req, res) => {
console.log("Got pedals collection");
// hard-code JSON response
res.send({ pedals: [{ name: "Boss SY-1", id: 1 }] });
@thomasswilliams
thomasswilliams / package.json
Created November 18, 2019 10:43
Express & TypeScript Pedals API base, Nov 2019 - package.json
{
"name": "pedals-api-nov-2019",
"version": "0.0.1",
"scripts": {
"serve": "npm run tsc && node ./dist/server.js",
"tsc": "tsc"
},
"devDependencies": {
"@types/express": "^4.17.2",
"@types/node": "^12.12.8",