Forked from dagda1/Microsoft.PowerShell_profile.ps1
Last active
January 11, 2017 19:19
-
-
Save macintacos/7b647aeb6a2fa5d61a10120304e5f4f1 to your computer and use it in GitHub Desktop.
Powershell Profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$snapins = Get-PSSnapin -Registered | |
$snapins | Add-PSSnapin | |
Get-PSSnapin | Format-Table -autosize PSVersion, Name | |
function ff ([string] $glob) { get-childitem -recurse -include $glob } | |
function osr { shutdown -r -t 5 } | |
function osh { shutdown -h -t 5 } | |
function rmd ([string] $glob) { remove-item -recurse -force $glob } | |
function whoami { (get-content env:\userdomain) + "\" + (get-content env:\username); } | |
function strip-extension ([string] $filename) | |
{ | |
[system.io.path]::getfilenamewithoutextension($filename) | |
} | |
function New-PSSecureRemoteSession | |
{ | |
param ($sshServerName, $Cred) | |
$Session = New-PSSession $sshServerName -UseSSL -Credential $Cred -ConfigurationName C2Remote | |
Enter-PSSession -Session $Session | |
} | |
function New-PSRemoteSession | |
{ | |
param ($shServerName, $Cred) | |
$shSession = New-PSSession $shServerName -Credential $Cred -ConfigurationName C2Remote | |
Enter-PSSession -Session $shSession | |
} | |
function prompt | |
{ | |
$promptText = "------------------------------------------------" + "`nCurrent Directory: " + (get-location) + "`r`nPS>"; | |
$wi = [System.Security.Principal.WindowsIdentity]::GetCurrent() | |
$wp = new-object 'System.Security.Principal.WindowsPrincipal' $wi | |
if ( $wp.IsInRole("Administrators") -eq 1 ) | |
{ | |
$color = "Red" | |
$title = "**ADMIN** on " + (hostname); | |
} | |
else | |
{ | |
$color = "Green" | |
$title = hostname; | |
} | |
write-host $promptText -NoNewLine -ForegroundColor $color | |
$host.UI.RawUI.WindowTitle = $title; | |
return " " | |
} | |
function gotodownloads{set-location C:\Users\julian.m.torres\Downloads} | |
function mkdir{mkdir $dir; cd $dir;} | |
function updir1{$dir = (get-location).path; set-location(split-path $dir);} | |
function updir2{updir1; $dir = (get-location).path; set-location(split-path $dir);} | |
function updir3{updir2; $dir = (get-location).path; set-location(split-path $dir);} | |
function updir4{updir3; $dir = (get-location).path; set-location(split-path $dir);} | |
function updir5{updir4; $dir = (get-location).path; set-location(split-path $dir);} | |
function updir6{updir5; $dir = (get-location).path; set-location(split-path $dir);} | |
function edit-profile{subl $profile} | |
function explore{ii .} | |
set-alias zip "C:\Program Files\7-Zip\7z.exe" | |
set-alias grep select-string | |
set-alias ssh New-PSSecureRemoteSession | |
set-alias sh New-PSRemoteSession | |
set-alias grep select-string | |
set-alias downloads gotodownloads | |
set-alias chrome "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" | |
set-alias subl "C:\Program Files\Sublime Text 3\sublime_text.exe" | |
set-alias edit subl | |
set-alias cdd updir1 # Go back 1 directory level | |
set-alias cddd updir2 # Go back 2 directory levels | |
set-alias cdddd updir3 # Go back 3 directory levels | |
set-alias cddddd updir4 # Go back 4 directory levels | |
set-alias cdddddd updir5 # Go back 5 directory levels | |
set-alias cddddddd updir6 # Go back 6 directory levels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment