diff --git a/Setup-Profile.ps1 b/Setup-Profile.ps1 index 8acf000..4c1a869 100644 --- a/Setup-Profile.ps1 +++ b/Setup-Profile.ps1 @@ -174,7 +174,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo @" if( -not (Test-Path $(Split-Path -Parent $p)) ) { New-Item -Type Directory $(Split-Path -Parent $p) -Force }; Copy-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null; - Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction Stop + Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction SilentlyContinue "@ 2>&1) if ( $errMsg ) { Write-Error "$errMsg" @@ -223,7 +223,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . ####################################################################### function ProfileCode_common { function Get-PowerShellPath { - Get-Process -PID $PID | ForEach-Object { $_.Path, $_.Parent.Path } | Where-Object { $_ -match 'powershell|pwsh' } | Select-Object -First 1 + Get-Process -PID $PID | ForEach-Object { $_.Path, $_.Parent.Path } | Where-Object { $_ -match $('(powershell|pwsh)' + "`$") } | Select-Object -First 1 } function ConvertTo-Base64 { @@ -254,10 +254,10 @@ function Invoke-ExpressionEx { $local:sudo_exec = [string]::Empty if ( (Get-Command scoop -ErrorAction SilentlyContinue) ) { $sudo_exec = $(scoop which gsudo *>&1) - if ( $sudo_exec -match 'not found' ) { + if ( "$sudo_exec" -match 'not found' ) { $sudo_exec = $(scoop which sudo *>&1) } - if ( $sudo_exec -match 'not found' ) { $sudo_exec = [string]::Empty } + if ( "$sudo_exec" -match 'not found' ) { $sudo_exec = [string]::Empty } } if ( $sudo_exec ) { & $sudo_exec $sudo_cmd