Skip to content

Instantly share code, notes, and snippets.

@mortenya
Last active May 25, 2023 07:07
Show Gist options
  • Save mortenya/3bfc9a42ee40b2dfb11a to your computer and use it in GitHub Desktop.
Save mortenya/3bfc9a42ee40b2dfb11a to your computer and use it in GitHub Desktop.
if ($host.UI.RawUI.WindowTitle -like "Administrator:*")
{
Write-Host -ForegroundColor Green "PowerShell is running as 'Administrator'..."
} else {
Write-Host -ForegroundColor Magenta "PowerShell is not running as 'Administrator'..."
}
# check if current user is in BUILTIN\Administrators (from https://github.com/tomasr/dotfiles/blob/master/.profile.ps1)
function Get-IsAdministrator
{
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object Security.Principal.WindowsPrincipal($id)
return $p.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Set the location where the console starts in
Set-Location $env:USERPROFILE\Documents\PowerShell
# Sets the style of the cursor, 100 = full block (easier to see).
$host.UI.RawUI.CursorSize = "100"
# Set the buffer size.
$bs = $host.UI.RawUI.BufferSize
$bs.Width = 160
$bs.Height = 3000
$host.UI.RawUI.BufferSize = $bs
# Set the window size for the screen.
$ws = $host.UI.RawUI.WindowSize
$ws.Width = 160
$ws.Height = 65
$host.UI.RawUI.WindowSize = $ws
# Aliases that make things easier
Set-Alias npp -Value "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
# Lets me copy my last command to clipboard (ctrl+c), if I want to take it to the ISE
function Copy-LastCommand
{
(Get-History)[-1].CommandLine | clip
}
# open explorer in this directory (from https://github.com/tomasr/dotfiles/blob/master/.profile.ps1)
function Open-ExplorerHere([string]$loc = '.')
{
explorer "/e,"$loc""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment