Skip to content

Instantly share code, notes, and snippets.

View MagicAndi's full-sized avatar
👹
Hard at work, coding. Ignoring all distractions, including you.

Andy P. MagicAndi

👹
Hard at work, coding. Ignoring all distractions, including you.
View GitHub Profile
@MagicAndi
MagicAndi / Organise-Photos.ps1
Created July 21, 2021 21:17
A PowerShell script to organise my photo backups.
# =============================================================================
#
# Script Name: Organise-Photos
#
# Author: Andy Parkhill
#
# Date Created: 09/07/2021
#
# Description: A script to organize my photos (and backups) into a coherent
# file structure, and remove duplicates, etc.
@MagicAndi
MagicAndi / Install-ProgramsTemplate.ps1
Created October 18, 2019 11:44
Template for script to install programs using Chocolatey
# ==========================================================================
#
# Script Name: Install-ProgramsTemplate.ps1
#
# Author: Andy Parkhill
#
# Date Created: 07/10/2019
#
# Description: A template setup script for Windows 10 PCs. Take the template
# and create a specific setup script for each new PC.
@MagicAndi
MagicAndi / Simple-SleepTimer.ps1
Last active November 8, 2018 11:07
A basic sleep timer with a textual progress indicator (Note, not a progress bar)
function Start-SleepTimer
{
param
(
[Alias('s')]
[int] $seconds
)
for($index = $seconds; $index -gt 0; $index--)
@MagicAndi
MagicAndi / ListSiteCollectionsAndContentDatabases.ps1
Created November 5, 2018 16:19
List site collections and associated content databases for a web application
Get-SPSite -limit all -WebApplication <Web Application URL> | Select Url, ContentDatabase
@MagicAndi
MagicAndi / Install-ProgramsForWindws10.ps1
Last active January 5, 2021 14:51
Install script for Windows 10
# ==========================================================================
#
# Script Name: Install-ProgramsForWindows10.ps1
#
# Author: Andy Parkhill
#
# Date Created: 22/09/2016
#
# Description: A simple environment setup script for Windows 10 PCs.
#
@MagicAndi
MagicAndi / List-InstalledPrograms.ps1
Created October 2, 2018 13:54
PowerShell one liner to create a CSV file of all installed programs.
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Sort-Object DisplayName | Export-CSV -Path C:\Temp\InstalledPrograms.csv -NoTypeInformation -Delimiter "|" | foreach { $_ -replace '^"','' -replace "`"|`"", "|" -replace '"$','' }
@MagicAndi
MagicAndi / ResetComputerPassword.bat
Created May 22, 2018 12:19
Reset Computer Password using NetDom.Exe. Run in an elevated command prompt.
netdom.exe resetpwd /s:<server> /ud:<user> /pd:<password>
@MagicAndi
MagicAndi / LisFoldersToSetDepth.bh
Created November 23, 2017 14:43
List folders in a directory to set depth and then output listing to file. Tested on WSL on Windows 10
tree -d -L 3 -N > /mnt/c/Temp/FolderListing.txt
@MagicAndi
MagicAndi / ListFoldersToSetDepth.ps1
Created November 23, 2017 14:42
List folders in a directory to set depth and then output listing to file. Requires PowerShell v5+
Get-ChildItem -Recurse -Directory -Depth 2 | Out-File C:\Temp\FolderListing.txt
@MagicAndi
MagicAndi / RetrieveSqlQueries.sql
Created May 18, 2017 15:40
Retrieve SQL queries from SQL Server. Taken from http://stackoverflow.com/a/15035060
SELECT execquery.last_execution_time AS [Date Time]
,execsql.text AS [Script]
FROM sys.dm_exec_query_stats AS execquery
CROSS APPLY sys.dm_exec_sql_text(execquery.sql_handle) AS execsql
WHERE execsql.text LIKE '%<text to search for>%'
ORDER BY execquery.last_execution_time DESC