Skip to content

Instantly share code, notes, and snippets.

View DanielSmon's full-sized avatar

Daniel Šmon DanielSmon

  • Brisbane, Australia
  • 14:35 (UTC +10:00)
View GitHub Profile
@DanielSmon
DanielSmon / backup-drive.cmd
Created March 15, 2021 01:29
backup-drive.cmd
@ECHO OFF
IF X%1==X GOTO INVALID_ARGS
IF X%2==X GOTO INVALID_ARGS
GOTO:RUN
:INVALID_ARGS
ECHO Invalid arguments
ECHO.
@DanielSmon
DanielSmon / Script Name.cmd
Created March 10, 2021 07:00
PowerShell launch cmd
@ECHO OFF
REM Rename this file to be the same name as your PowerShell .ps1 script.
REM This script must be in the same directory as your .ps1 script.
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -Command ""& {%~dpn0.ps1;pause}""' -Verb RunAs}"
using System;
using System.IO;
using System.Reflection;
namespace DAS.Utils
{
public static class EmbeddedResource
{
/// <summary>
///
@DanielSmon
DanielSmon / boxstarter.ps1
Last active March 8, 2021 13:30 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@DanielSmon
DanielSmon / New MS Teams Profile.cmd
Last active April 3, 2024 06:59
For running multiple MS Teams accounts side by side. Save this with the name of the MS Teams profile you wish to use. When launched, a folder will be created in your user profile. See https://danielsmon.com/2020/04/02/multiple-ms-teams-accounts-on-the-desktop/.
@ECHO OFF
REM Uses the file name as the profile name
SET MSTEAMS_PROFILE=%~n0
ECHO - Using profile "%MSTEAMS_PROFILE%"
SET "OLD_USERPROFILE=%USERPROFILE%"
SET "USERPROFILE=%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%"
REM Ensure there is a downloads folder to avoid error described at
@DanielSmon
DanielSmon / keybase.md
Created November 14, 2019 03:42
keybase.md

Keybase proof

I hereby claim:

  • I am danielsmon on github.
  • I am danielsmon (https://keybase.io/danielsmon) on keybase.
  • I have a public key ASDDsqGt-EUwIXNtuNEQbgdQQFxXms4vSS3cVHxcbwv-sgo

To claim this, I am signing this object:

@DanielSmon
DanielSmon / folder-size.cmd
Created October 7, 2019 09:33
Windows: Fastest way to get folder size with many files
robocopy %full_path% %TEMP% /S /L /BYTES /XJ /NFL /NDL /NJH
Function Test-Redirect($uri, $expectedStatusCode, $expectedRedirect) {
try {
$result = Invoke-WebRequest -MaximumRedirection 0 -Uri $uri -SkipHeaderValidation
Write-Host -ForegroundColor Red "Failed " -NoNewline
Write-Host $uri -NoNewline
Write-Host " Expected:" $expectedStatusCode $expectedRedirect " " -NoNewline
Write-Host "Received:" $result.StatusCode -BackgroundColor Yellow
} catch {
$_Exception
@DanielSmon
DanielSmon / create-azure-sql-logins-and-users.sql
Last active July 11, 2022 23:52
Azure SQL - Create logins and users
-- For more useful info on permissions, see:
-- https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-role-members-transact-sql?view=sqlallproducts-allversions
-- Create logins and users on Azure SQL databases.
-- Adjust roles and schemas appropriately
DECLARE @user varchar(255) = 'USERNAME';
DECLARE @pass varchar(255) = 'PASSWORD';
DECLARE @schema varchar(255) = '[dbo]';
IF ((SELECT DB_NAME()) = 'master')
@DanielSmon
DanielSmon / Test-WebRequestWithCookies.ps1
Last active March 10, 2019 13:32
PowerShell web request with cookies
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$uri = "https://www.domain.com/action"
# Cookies from browser
# Paste in cookie values from browser request
$allCookies = "cookie1=cookievalue1; cookie2=cookievalue2"
foreach ($cookiePair in $allCookies.Split((";"))) {
$cookieValues = $cookiePair.Trim().Split("=")