Skip to content

Instantly share code, notes, and snippets.

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
#Create default config if one does not exist
function Write-DefaultConfig
{
if ( -not (Test-Path $scriptDir\Config.xml -PathType Leaf))
{
"<root>
<Variable1>Value1</Variable1>
<Variable2>Value2</Variable2>
function Use-RunAs
{
# Check if script is running as Adminstrator and if not use RunAs
# Use Check Switch to check if admin
param([Switch]$Check)
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()`
).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
@NoShotz
NoShotz / sherlock.ps1
Last active August 12, 2019 18:49
A powershell script for running Sherlock https://github.com/sherlock-project/sherlock Requires Git and Python 3.6.0 and higher installed
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
try
{
git.exe | Out-Null
}
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Host "Please install Git"
$HasReq = "False"
Start-Sleep -Seconds 2
Set-ExecutionPolicy Bypass -Scope Process -Force
function Use-RunAs
{
# Check if script is running as Adminstrator and if not use RunAs
# Use Check Switch to check if admin
param([Switch]$Check)
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()`
@NoShotz
NoShotz / Show-DynamicMenu.ps1
Last active June 2, 2020 19:12
Creates a menu based on an array passed to the function, the contents of the array can be pretty much anything, such as the full name of files in a folder you get from Get-ChildItem.
Function Show-DynamicMenu
{
Param ([array] $Items, [string] $Title = "Menu", [string] $ExitMessage = "Go Back")
$num = 0
if($Title -ne "")
{
$Decorator = "="
$MenuTitle = $Decorator * 10 + " " + $Title + " "