{"id":14064363,"url":"https://github.com/jimbrig/PowerShell-Profiles-Work","last_synced_at":"2025-07-29T18:32:23.364Z","repository":{"id":38271731,"uuid":"414810936","full_name":"jimbrig/PowerShell-Profiles-Work","owner":"jimbrig","description":"My PowerShell Profiles for Work","archived":false,"fork":false,"pushed_at":"2022-10-01T00:14:01.000Z","size":5092,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-28T02:22:31.173Z","etag":null,"topics":["automation","configuration","powershell","profile","setup","windows","work"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimbrig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-08T01:43:46.000Z","updated_at":"2023-09-13T08:29:07.000Z","dependencies_parsed_at":"2023-01-19T01:00:39.333Z","dependency_job_id":null,"html_url":"https://github.com/jimbrig/PowerShell-Profiles-Work","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimbrig%2FPowerShell-Profiles-Work","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimbrig%2FPowerShell-Profiles-Work/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimbrig%2FPowerShell-Profiles-Work/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimbrig%2FPowerShell-Profiles-Work/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimbrig","download_url":"https://codeload.github.com/jimbrig/PowerShell-Profiles-Work/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215155110,"owners_count":15836917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","configuration","powershell","profile","setup","windows","work"],"created_at":"2024-08-13T07:03:49.940Z","updated_at":"2024-12-04T03:30:42.067Z","avatar_url":"https://github.com/jimbrig.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# PowerShell Profiles - Work\n\nMy Customized Powershell Profiles for Work: \n- `~/Documents/PowerShell` (Core)\n- `~/Documents/WindowsPowerShell` (Windows)\n\nSee the [Changelog](CHANGELOG.md) for details on this repository's development over time.\n\n## Contents\n\n- [PowerShell](#powershell)\n  - [Contents](#contents)\n  - [$PROFILE](#profile)\n    - [Profile Features](#profile-features)\n  - [Custom Functions](#custom-functions)\n  - [Custom Aliases](#custom-aliases)\n  - [Custom Shell Completions](#custom-shell-completions)\n  - [Modules](#modules)\n  - [Scripts](#scripts)\n  - [Functions](#functions)\n\n## $PROFILE\n\nIn this repository there are the following profile files:\n\n- PowerShell Core (~/Documents/PowerShell):\n  - [profile.ps1](PowerShell/profile.ps1) - *CurrentUserAllHosts* Profile\n  - [Microsoft.PowerShell_profile.ps1](PowerShell/Microsoft.PowerShell_profile.ps1) - *CurrentUserCurrentHost* Profile - The Default `$PROFILE`\n  - [Microsoft.VSCode_profile.ps1](PowerShell/Microsoft.VSCode_profile.ps1) - VSCode Specific Host Profile\n\nHere are the `$PROFILE` path's to various PowerShell 7 Profile Locations on Windows 10 (note that I am currently *not* using OneDrive):\n\n```powershell\n➜ $PROFILE\nC:\\Users\\jbriggs010\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1\n➜ $PROFILE.CurrentUserCurrentHost\nC:\\Users\\jbriggs010\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1\n➜ $PROFILE.CurrentUserAllHosts\nC:\\Users\\jbriggs010\\Documents\\PowerShell\\profile.ps1\n➜ $PROFILE.AllUsersCurrentHost\nC:\\Program Files\\PowerShell\\7-preview\\Microsoft.PowerShell_profile.ps1\n➜ $PROFILE.AllUsersAllHosts\nC:\\Program Files\\PowerShell\\7-preview\\profile.ps1\n```\n\n### Profile Features\n\nFor [profile.ps1](PowerShell/profile.ps1):\n\n- Trust `PSGallery`\n- Import necessary modules in specific order\n- Enable `posh-git`\n- Set `prompt` theme via `oh-my-posh`\n- Return a string with details for the `ZLocation` module's known locations.\n\n\u003cdetails\u003e\u003csummary\u003e🔎 View Code\u003c/summary\u003e\n \u003cp\u003e\n\n```powershell\n#Requires -Version 7\n\n# ----------------------------------------------------\n# Current User, All Hosts Powershell Core v7 $PROFILE:\n# ----------------------------------------------------\n\n# Trust PSGallery\n$galleryinfo = Get-PSRepository | Where-Object { $_.Name -eq \"PSGallery\" }\nif (-not($galleryinfo.InstallationPolicy.Equals(\"Trusted\"))) { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted }\n\n# Import Modules\nImport-Module posh-git\nImport-Module oh-my-posh\nImport-Module Terminal-Icons\nImport-Module WslInterop\nImport-Module PSWindowsUpdate\nImport-Module PSWriteColor\n\n# Enable Posh-Git\n$env:POSH_GIT_ENABLED = $true\n\n# Prompt\nSet-PoshPrompt -Theme wopian\n\n# ZLocation must be after all prompt changes:\nImport-Module ZLocation\nWrite-Host -Foreground Green \"`n[ZLocation] knows about $((Get-ZLocation).Keys.Count) locations.`n\"\n```\n   \n  \u003c/p\u003e\n \u003c/details\u003e \n   \nOptional:\n\n- Import WSL Linux/BASH Interop Commands (ls, awk, tree, etc.)\n- Set `PSReadLine` options\n- Start custom log\n- Map custom `PSDrive`'s to common folders\n   \nFor [Microsoft.PowerShell_profile.ps1](PowerShell/Microsoft.PowerShell_profile.ps1):\n\n- Load custom [Profile Completions - completion.ps1](PowerShell/Profile/completion.ps1)\n- Load custom [Profile Functions - functions.ps1](PowerShell/Profile/functions.ps1)\n- Load custom [Profile Aliases - aliases.ps1](PowerShell/Profile/aliases.ps1)\n   \n\u003cdetails\u003e\u003csummary\u003e🔎 View Code\u003c/summary\u003e\n \u003cp\u003e\n\n```powershell\n#Requires -Version 7\n\n# -------------------------------------------------------\n# Current User, Current Host Powershell Core v7 $PROFILE:\n# -------------------------------------------------------\n\n# Load Functions, Aliases, and Completion\n$psdir = (Split-Path -parent $profile)\n\nIf (Test-Path \"$psdir\\Profile\\functions.ps1\") { . \"$psdir\\Profile\\functions.ps1\" }\nIf (Test-Path \"$psdir\\Profile\\aliases.ps1\") { . \"$psdir\\Profile\\aliases.ps1\" }\nIf (Test-Path \"$psdir\\Profile\\completion.ps1\") { . \"$psdir\\Profile\\completion.ps1\" }\n\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n   \n## Custom Functions\n\nMy suite of custom functions to be loaded for every PowerShell session:\n  - Search functions via [zquestz/s](https://github.com/zquestz/s)\n  - Google Calendar functions via [gcalcli](https://github.com/insanum/gcalcli)\n  - Directory listing functions for `lsd`\n  - System Utility Functions\n  - Symlinking Functions\n  - Network Utilities\n  - Programs\n  - PowerShell helpers\n  - Remoting\n  - Chocolatey\n  - R and RStudio\n  - GitKraken\n   \n- See [functions.ps1](PowerShell/Profile/functions.ps1):\n   \n\u003cdetails\u003e\u003csummary\u003e🔎 View Code\u003c/summary\u003e\n \u003cp\u003e\n   \n```powershell\n# ---------------------------------\n# PowerShell Core Profile Functions\n# ---------------------------------\n\n# ---------------------\n# Search via `s-cli`\n# ---------------------\n\nIf (Get-Command s -ErrorAction SilentlyContinue) {\n  ${function:Search-GitHub} = { s -p github $args }\n  ${function:Search-GitHubPwsh} = { s -p ghpwsh $args }\n  ${function:Search-GitHubR} = { s -p ghr $args }\n  ${function:Search-MyRepos} = { s -p myrepos $args }\n}\n\n# --------\n# GCalCLI\n# --------\n\nIf (Get-Command gcalcli -ErrorAction SilentlyContinue) {\n  ${function:Get-Agenda} = { \u0026 gcalcli agenda }\n  ${function:Get-CalendarMonth} = { \u0026 gcalcli calm }\n  ${function:Get-CalendarWeek} = { \u0026 gcalcli calw }\n  ${function:New-CalendarEvent} = { \u0026 gcalcli add }\n}\n\n# -----\n# LSD\n# -----\nIf (Get-Command lsd -ErrorAction SilentlyContinue) {\n  ${function:lsa} = { \u0026 lsd -a }\n}\n\n# ----------------------\n# System Utilities\n# ----------------------\n\n# Check Disk\n${function:Check-Disk} = { \u0026 chkdsk C: /f /r /x }\n\n# Update Environment\n${function:Update-Environment} = {\n  $env:Path = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\") + \";\" + [System.Environment]::GetEnvironmentVariable(\"Path\", \"User\")\n  Write-Host -ForegroundColor Green \"Sucessfully Refreshed Environment Variables For powershell.exe\"\n}\n\n# Clean System\n${function:Clean-System} = {\n  Write-Host -Message 'Emptying Recycle Bin' -ForegroundColor Yellow\n  (New-Object -ComObject Shell.Application).Namespace(0xA).items() | ForEach-Object { Remove-Item $_.path -Recurse -Confirm:$false }\n  Write-Host 'Removing Windows %TEMP% files' -ForegroundColor Yellow\n  Remove-Item c:\\Windows\\Temp\\* -Recurse -Force -ErrorAction SilentlyContinue\n  Write-Host 'Removing User %TEMP% files' -ForegroundColor Yellow\n  Remove-Item “C:\\Users\\*\\Appdata\\Local\\Temp\\*” -Recurse -Force -ErrorAction SilentlyContinue\n  Write-Host 'Removing Custome %TEMP% files (C:/Temp and C:/tmp)' -ForegroundColor Yellow\n  Remove-Item c:\\Temp\\* -Recurse -Force -ErrorAction SilentlyContinue\n  Remove-Item c:\\Tmp\\* -Recurse -Force -ErrorAction SilentlyContinue\n  Write-Host 'Launchin cleanmgr' -ForegroundColor Yellow\n  cleanmgr /sagerun:1 | Out-Null\n  Write-Host '✔️ Done.' -ForegroundColor Green\n}\n\n# New File\n${function:New-File} = { New-Item -Path $args -ItemType File -Force }\n\n# New Directory\n${function:New-Dir} = { New-Item -Path $args -ItemType Directory -Force }\n\n# Net Directory and cd into\n${function:CreateAndSet-Directory} = {\n  New-Item -Path $args -ItemType Directory -Force\n  Set-Location -Path \"$args\"\n}\n\n# Create Symlink\nFunction New-Link ($target, $link) {\n  New-Item -Path $link -ItemType SymbolicLink -Value $target\n}\n\n# Take Ownership\nFunction Invoke-TakeOwnership ( $path ) {\n  if ((Get-Item $path) -is [System.IO.DirectoryInfo]) {\n    sudo TAKEOWN /F $path /R /D Y\n  }\n  else {\n    sudo TAKEOWN /F $path\n  }\n}\n\n# Force Delete\nFunction Invoke-ForceDelete ( $path ) {\n  Take-Ownership $path\n  sudo remove-item -path $path -Force -Recurse -ErrorAction SilentlyContinue\n  if (!(Test-Path $path)) {\n    Write-Host \"✔️ Successfully Removed $path\" -ForegroundColor Green\n  }\n  else {\n    Write-Host \"❌ Failed to Remove $path\" -ForegroundColor Red\n  }\n}\n\n# ------------------\n# Network Utilities\n# ------------------\n\n# Get Public IP\n${function:Get-PublicIP} = {\n  $ip = Invoke-RestMethod -Uri 'https://api.ipify.org?format=json'\n  \"My public IP address is: $($ip.ip)\"\n}\n\n# -----------------------\n# Programs\n# -----------------------\n\n# Docker\n${function:Start-Docker} = { Start-Process \"C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe\" }\n${function:Stop-Docker} = { foreach ($dock in (get-process *docker*).ProcessName) { sudo stop-process -name $dock } }\n\n# Open GitKraken in Current Repo\n${function:krak} = {\n  $curpath = (get-location).ProviderPath\n  If (!(Test-Path \"$curpath\\.git\")) { Write-Error \"Not a git repository. Run 'git init' or select a git tracked directory to open. Exiting..\"; return }\n  $logf = \"$env:temp\\krakstart.log\"\n  $newestExe = Resolve-Path \"$env:localappdata\\gitkraken\\app-*\\gitkraken.exe\"\n  If ($newestExe.Length -gt 1) { $newestExe = $newestExe[1] }\n  Start-Process -filepath $newestExe -ArgumentList \"--path $curpath\" -redirectstandardoutput $logf\n}\n\n# Open RStudio in Current Repo\n${function:rstudio} = {\n  $curpath = (get-location).ProviderPath\n  $logf = \"$env:temp\\rstudiostart.log\"\n  $exepath = \"$env:programfiles\\RStudio\\bin\\rstudio.exe\"\n  start-process -filepath $exepath -ArgumentList \"--path $curpath\" -redirectstandardoutput $logf\n}\n\n# --------------------------\n# PowerShell Functions\n# --------------------------\n\n# Edit `profile.ps1`\n${function:Edit-Profile} = { notepad.exe $PROFILE.CurrentUserAllHosts }\n\n# Edit profile functions.ps1\n${function:Edit-Functions} = {\n  $prodir = Split-Path -Path $PROFILE -Parent\n  $funcpath = \"$prodir\\Profile\\functions.ps1\"\n  code $funcpath\n}\n\n# Edit profile aliases.ps1\n${function:Edit-Aliases} = {\n  $prodir = Split-Path -Path $PROFILE -Parent\n  $funcpath = \"$prodir\\Profile\\aliases.ps1\"\n  code $funcpath\n}\n\n# Edit profile completion.ps1\n${function:Edit-Completion} = {\n  $prodir = Split-Path -Path $PROFILE -Parent\n  $funcpath = \"$prodir\\Profile\\completion.ps1\"\n  code $funcpath\n}\n\n# Open Profile Directory in VSCode:\n${function:Open-ProDir} = {\n  $prodir = Split-Path -Path $PROFILE -Parent\n  code $prodir\n}\n\n# ------------------\n# Remoting\n# ------------------\n\n# Invoke Remote Script - Example: Invoke-RemoteScript \u003curl\u003e\nFunction Invoke-RemoteScript {\n  [CmdletBinding()]\n  param(\n    [Parameter(Position = 0)]\n    [string]$address,\n    [Parameter(ValueFromRemainingArguments = $true)]\n    $remainingArgs\n  )\n  Invoke-Expression \"\u0026 { $(Invoke-RestMethod $address) } $remainingArgs\"\n}\n\n# -----------\n# Chocolatey\n# -----------\n\n${function:chocopkgs} = { \u0026 choco list --local-only }\n${function:chococlean} = { \u0026 choco-cleaner }\n${function:chocoupgrade} = { \u0026 choco upgrade all -y }\n${function:chocobackup} = { \u0026 choco-package-list-backup }\n${function:chocosearch} = { \u0026 choco search $args }\n\n# ---------------\n# R and RStudio\n# ---------------\n\n${function:rvanilla} = { \u0026 \"C:\\Program Files\\R\\R-4.1.1\\bin\\R.exe\" --vanilla }\n${function:radianvanilla} = { \u0026 \"C:\\Python39\\Scripts\\radian.exe\" --vanilla }\n${function:openrproj} = { \u0026 C:\\bin\\openrproject.bat }\n${function:pakk} = { Rscript.exe \"C:\\bin\\pakk.R\" $args }\n   \n```\n   \n \u003c/p\u003e\n\u003c/details\u003e\n   \n## Custom Aliases\n\n- See [aliases.ps1](PowerShell/Profile/aliases.ps1):\n\n\u003cdetails\u003e\u003csummary\u003e🔎 View Code\u003c/summary\u003e\n \u003cp\u003e\n   \n```powershell\nSet-Alias -Name irs -Value Invoke-RemoteScript\nSet-Alias -Name pro -Value Edit-Profile\nSet-Alias -Name aliases -Value Get-Alias\nSet-Alias -Name cpkgs -Value chocopkgs\nSet-Alias -Name cclean -Value chococlean\nSet-Alias -Name csearch -Value chocosearch\nSet-Alias -Name cup -Value chocoupgrade\nSet-Alias -Name cbackup -Value chocobackup\nSet-Alias -Name refresh -Value refreshenv\nSet-Alias -Name touch -Value New-File\nSet-Alias -Name rproj -Value openrproj\nSet-Alias -Name chkdisk -Value Check-Disk\nSet-Alias -Name cdd -Value CreateAndSet-Directory\nSet-Alias -Name emptytrash -Value Clear-RecycleBin\nSet-Alias -Name codee -Value code-insiders\nSet-Alias -Name cpkgs -Value chocopkgs\nSet-Alias -Name cup -Value chocoupgrade\nSet-Alias -Name gcal -Value gcalcli\nSet-Alias -Name agenda -Value Get-Agenda\nSet-Alias -Name gcalm -Value Get-CalendarMonth\nSet-Alias -Name gcalw -Value Get-CalendarWeek\nSet-Alias -Name gcalnew -Value New-CalendarEvent\n\n# Ensure `R` is for launching an R Terminal:\nif (Get-Command R.exe -ErrorAction SilentlyContinue | Test-Path) {\n  Remove-Item Alias:r -ErrorAction SilentlyContinue\n  ${function:r} = { R.exe @args }\n}\n\n# Ensure GPG Points to GnuPG:\nset-alias gpg 'C:\\Program Files (x86)\\gnupg\\bin\\gpg.exe'\n```\n   \n \u003c/p\u003e\n\u003c/details\u003e\n   \n## Custom Shell Completions\n\n- Shell completion for:\n  - Docker\n  - PowerShell\n  - Scoop\n  - Chocolatey\n  - WinGet\n  - Github-CLI\n  - Git Cliff (changelog generator)\n  - Keep\n  - DotNet\n\n- See [completion.ps1](PowerShell/Profile/completion.ps1) and the [completions folder](PowerShell/Profile/completions):\n\n\u003cdetails\u003e\u003csummary\u003e🔎 View Code\u003c/summary\u003e\n \u003cp\u003e\n   \n```powershell\n# Shell Completion Modules\nImport-Module Microsoft.PowerShell.Utility\nImport-Module DockerCompletion\nImport-Module scoop-completion\n\n$psdir = (Split-Path -parent $profile)\n$completionpath = \"$HOME\\Documents\\PowerShell\\Profile\\completions\"\n$files = (Get-ChildItem -Path $completionpath).Name\n\nForEach ($file in $files) { . $psdir\\Profile\\completions\\$file } \n```\n   \n \u003c/p\u003e\n\u003c/details\u003e\n   \n## Modules\n\n## Scripts\n   \n## Other Functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimbrig%2FPowerShell-Profiles-Work","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimbrig%2FPowerShell-Profiles-Work","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimbrig%2FPowerShell-Profiles-Work/lists"}