Skip to content

Instantly share code, notes, and snippets.

@kristianrl
kristianrl / docker_creation.sh
Created January 19, 2024 07:41
Docker - List of container creation times
View docker_creation.sh
docker ps -a --format "table {{.Names}}\t{{.CreatedAt}}\t{{.Status}}"
@kristianrl
kristianrl / backup_machine.bat
Created September 18, 2023 12:21
Backup windows computer
View backup_machine.bat
REM Kristian Risager Larsen, 2023-09
echo %date%
"C:\Program Files\7-Zip\7z.exe" a -t7z -v3g c:\backup\backup_%date%.7z c:\ -mx9 -xr!*.sys -xr!*Backup*
echo %date%
pause
@kristianrl
kristianrl / synology-dsm-docker-container-age.sh
Created February 4, 2023 06:29
Docker container age - to be run as eg a weekly task for Synology's docker.
View synology-dsm-docker-container-age.sh
docker ps -a --format "table {{.Names}}\t{{.CreatedAt}}\t{{.Status}}"
@kristianrl
kristianrl / compare_user_security_groups.ps1
Last active August 17, 2022 07:22
Compare two users' security group memberships using PowerShell
View compare_user_security_groups.ps1
Compare-Object -ReferenceObject (get-aduser USER1 -Properties memberof | select -expand memberof | sort) -DifferenceObject (get-aduser USER2 -Properties memberof | select -expand memberof | sort) -IncludeEqual | sort SideIndicator
@kristianrl
kristianrl / remove_old_files.bat
Created November 30, 2021 07:45
Remove old files
View remove_old_files.bat
REM Deleting all .log-files (older than 30 days) recursively
forfiles -p "d:\logs" -s -m *.xlsx -d -30 -c "cmd /c if @isdir==FALSE del @path"
@kristianrl
kristianrl / unused_databases.sql
Created November 18, 2021 13:33
List potentially unused MSSQL databases
View unused_databases.sql
'' List potentially unused MSSQL databases
'' for a single database
EXECUTE sp_msforeachdb 'SELECT TOP 1 * FROM [?].sys.objects ORDER BY modify_date DESC'
'' for all databases
CREATE TABLE #database_age (db_name VARCHAR(255), name VARCHAR(255), modify_date DATETIME, type_desc VARCHAR(255))
EXECUTE sp_msforeachdb 'INSERT INTO #database_age SELECT TOP 1 ''[?]'' AS db_name, name, modify_date, type_desc FROM [?].sys.objects WHERE type_desc NOT IN (''INTERNAL_TABLE'',''SYSTEM_TABLE'', ''SERVICE_QUEUE'') ORDER BY modify_date DESC'
SELECT * FROM #database_age ORDER BY modify_date
@kristianrl
kristianrl / new-browser-tab-for-each-line.html
Created January 14, 2021 07:23
Paste the URLs you want to open in new tabs in the list below, with one URL per line. Note that this is not working on Google Chrome, but works in Internet Explorer.
View new-browser-tab-for-each-line.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>New browser tab for each line</title>
<script>
function searchgoogle () {
var searchlines = document.getElementById("searchfield").value;
searchlines = searchlines.split("\n");
@kristianrl
kristianrl / blue_prism_schedule_overview.sql
Last active August 10, 2020 09:14
Blue Prism: Overview of schedule entries' last run state
View blue_prism_schedule_overview.sql
-- Lists all active schedules
-- Tested with Blue Prism version 6.4
-- List of all active schedules including Termination Reason (my company's MSSQL version does not support the STRING_AGG function, so this could be prettier)
SELECT bpaschedule.name,
logkolonner.instancetime,
logentrykolonner.terminationreason
FROM bpaschedule
CROSS apply (SELECT TOP 1 bpaschedulelog.scheduleid,
bpaschedulelog.instancetime,
@kristianrl
kristianrl / google-search-for-each-line.html
Created November 12, 2015 11:38
Google search in new tab for each line in a textfield
View google-search-for-each-line.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>New Google search for each line</title>
<script>
function searchgoogle () {
var searchlines = document.getElementById("searchfield").value;
searchlines = searchlines.split("\n");
@kristianrl
kristianrl / remove_picasaoriginals.command
Last active November 9, 2015 10:22
Remove .picasaoriginals-folders (script for Picasa on OS X)
View remove_picasaoriginals.command
echo "*** Removes all '.picasaoriginals'-folders and their contents"
find . -iname '.picasaoriginals' -exec rm -rfv '{}' \;
echo "*** Done"