Last active
January 26, 2023 14:41
-
-
Save SimonWahlin/9de021cbae976839647d0165c731ceef 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
#region BootstrapProfile | |
try { | |
Import-Module 'posh-git' -ErrorAction 'stop' | |
} | |
catch {} | |
if ( | |
$host.Name -eq 'Visual Studio Code Host' -or | |
(Get-Process -Id $PID).Parent.ProcessName -like 'Code*' | |
) { | |
try { | |
Import-Module 'EditorServicesCommandSuite' -ErrorAction 'stop' | |
Import-CommandSuite | |
} | |
catch {} | |
} else { | |
try { | |
$PoshTheme = '~\.simonw-oh-my-posh-theme.omp.json' | |
if(Test-Path $PoshTheme) { | |
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config $PoshTheme --print) -join "`n")) | |
$env:AZ_ENABLED=$false | |
$env:POSH_GIT_ENABLED = $false | |
} | |
} | |
catch {} | |
} | |
function Start-Teams { | |
param( | |
$ProfileName | |
) | |
$REALUSERPROFILE = $ENV:USERPROFILE | |
$TeamsPath = "$REALUSERPROFILE\AppData\Local\Microsoft\Teams\Update.exe" | |
if($PSBoundParameters.ContainsKey('ProfileName')) { | |
Write-Host "Using profile: $ProfileName" | |
$ENV:USERPROFILE = "$ENV:LOCALAPPDATA\Microsoft\Teams\CustomProfiles\$ProfileName" | |
# Ensure there is a downloads folder to avoid error described at | |
# https://gist.github.com/DanielSmon/cc3fa072857f0272257a5fd451768c3a | |
$DownloadsPath = "$ENV:USERPROFILE\Downloads" | |
if(!(Test-Path -Path $DownloadsPath -PathType 'Container')) { | |
$null = New-Item -Path $DownloadsPath -ItemType 'Directory' | |
} | |
$DesktopPath = "$ENV:USERPROFILE\Desktop" | |
if(!(Test-Path -Path $DesktopPath -PathType 'Container')) { | |
$null = New-Item -Path $DesktopPath -ItemType 'Directory' | |
} | |
} | |
Write-Host "Starting teams using profile: $ENV:USERPROFILE" | |
Start-Process -FilePath $TeamsPath -ArgumentList '--processStart Teams.exe' | |
$ENV:USERPROFILE = $REALUSERPROFILE | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment