PowerShell Commands
###Update Your Security Policy
Navigate to the following path: C:\Windows\System32
Open a PowerShell session within this directory.
Enter gpupdate
to update the security policy on your device.
Try This: gpupdate
Updating Policy...
User Policy update has completed successfully.
Computer Policy update has completed successfully.
Navigate to the target directory.
Preface a target file with .\
and provide the file name followed by .ps1
.
Example: .\hfjUI.ps1
##################
#### START UP ####
##################
Write-Host "`tHello, welcome back.`n"
###########################
#### POWERSHELL CONFIG ####
###########################
# 'PS: MM/DD/YYYY HH:MM:SS> '
function prompt {"PS: $(get-date)> "}
# Default initial location
Set-Location C:\Users\abiagi001\Desktop
# Reset $HOME variable
Remove-Variable -Force HOME
Set-Variable HOME "C:\Users\abiagi001\Desktop"
# Reset ~ directory
$provider = get-psprovider filesystem
$provider.Home = $HOME
################################
#### CONSOLE CONFIGURATIONS ####
################################
$console = $host.UI.RawUI
$console.ForegroundColor = "white"
$console.BackgroundColor = "black"
######################
#### WINDOW TITLE ####
######################
# Default title
$host.ui.RawUI.WindowTitle = "Ave Imperator, morituri te salutant”
# Set new title at the command line
function NEW-WINDOW-TITLE
{
$host.ui.RawUI.WindowTitle = $args[0]
}
# Abbreviation of new title command
NEW-ALIAS wt NEW-WINDOW-TITLE
################################
#### LAUNCHING APPLICATIONS ####
################################
# Shortcut to launch file in it's default app
NEW-ALIAS go START-PROCESS
# Shortcut for gvim
NEW-ALIAS vi 'C:\Program Files (x86)\Vim\vim74\gvim.exe'
# Shortcut for new PowerShell window
function power
{
Invoke-Item C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
}
Open Windows Explorer at Current Directory
ii .
explorer .
Check for a PowerShell profile
New-Item -Path $Profile -Type File -Force
Edit PowerShell profile
notepad $Profile
Default text editor
vi $Profile
Gvim preferred