Skip to content

Instantly share code, notes, and snippets.

View DanielSmon's full-sized avatar

Daniel Šmon DanielSmon

  • Brisbane, Australia
  • 19:19 (UTC +10:00)
View GitHub Profile
@DanielSmon
DanielSmon / New MS Teams Profile.cmd
Last active April 29, 2024 19:23
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
using System;
using System.IO;
using System.Reflection;
namespace DAS.Utils
{
public static class EmbeddedResource
{
/// <summary>
///
Function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
Function Decrypt-SecureString {
param(
[Parameter(ValueFromPipeline=$true,Mandatory=$true,Position=0)]
[System.Security.SecureString]
$sstr
)
$marshal = [System.Runtime.InteropServices.Marshal]
$ptr = $marshal::SecureStringToBSTR( $sstr )
$str = $marshal::PtrToStringBSTR( $ptr )
$marshal::ZeroFreeBSTR( $ptr )
@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 / 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}"
@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 / 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