website icon indicating copy to clipboard operation
website copied to clipboard

the-ultimate-powershell-experience/

Open utterances-bot opened this issue 1 year ago • 11 comments

The Ultimate Powershell Experience

Having Fun with Technology

https://christitus.com/the-ultimate-powershell-experience/

utterances-bot avatar May 04 '24 14:05 utterances-bot

I always get at launch of my terminal: Skipping PowerShell update check due to GitHub.com not responding within 1 second.

akvariefisk avatar May 04 '24 14:05 akvariefisk

Very nice. Would be fine to have a section for custom functions which wouldn't be lost during the update or at least some way to load some custom.ps1 :)

tommyq86 avatar May 05 '24 10:05 tommyq86

@akvariefisk You must be using powershell 5.1 swithc to powershell 7.4 and it will be fixed. I had the same issue

SMJ804 avatar May 07 '24 05:05 SMJ804

Every time I try to change my oh-my-posh profile, the Update-Profile function overwrites the change and reverts back to the original. Any way to change this?

nairbd avatar May 07 '24 19:05 nairbd

Okay, so for me the script was saved on C:\Users\[USER NAME]\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 . if you cannot find the powershell script just search it on Everything. There is a line at the bottom that says

## Final Line to set prompt oh-my-posh init pwsh --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/cobalt2.omp.json | Invoke-Expression

change that to your theme, for me changed the word cobalt2 to amro and it worked

After changing

## Final Line to set prompt oh-my-posh init pwsh --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/amro.omp.json | Invoke-Expression

Hope this works

SMJ804 avatar May 08 '24 08:05 SMJ804

UPDATE

The profile updating function in the script resets the changes we made in the script so I again edited it to stop checking for profile updates

** CAUTION :I am not a programmer and I am no expert in this **

What I ended up doing was to put a return statement under Update-Profile function which skips the whole profile update checking. It worked for me and I think it is a solution till Chris comes and fixes this bug.

# Check for Profile Updates
function Update-Profile {
    Write-Host "Skipping Update to Preserve Theme"
    return
    if (-not $global:canConnectToGitHub) {
        Write-Host "Skipping profile update check due to GitHub.com not responding within 1 second." -ForegroundColor Yellow
        return
    }

SMJ804 avatar May 08 '24 08:05 SMJ804

Thank you @SMJ804 your solution worked for me

nairbd avatar May 08 '24 16:05 nairbd

PowerShell 7.4.1

A new PowerShell stable release is available: v7.4.5 Upgrade now, or check out the release page at: https://aka.ms/PowerShell-Release?tag=v7.4.5

Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.

Checking for PowerShell updates... Updating PowerShell... No installed package found matching input criteria. PowerShell has been updated. Please restart your shell to reflect changes Use 'Show-Help' to display help Loading personal and system profiles took 5639ms.

Restarting Powershell 7 does not load 7.4.5., keeps reopenign 7.4.1

tgaguy avatar Sep 16 '24 02:09 tgaguy

The command irm “https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1” | iex generated the following output in powershell: Invoke-Expression: Missing closing '}' in statement block or type definition. I'm using PowerShell 7.4.6

Scarring4994 avatar Dec 09 '24 16:12 Scarring4994

I have tried a lot but whenever I made changes, I am stuck with this error. Invoke-Expression: C:\Users\Haseeb Ul Hassan\Documents\PowerShell\profile.ps1:498 Line | 498 | Invoke-Expression $existingTheme | ~~~~~~~~~~~~~~ | Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Command'. Specified method | is not supported. Use 'Show-Help' to display help Profile is up to date. Checking for PowerShell updates... Your PowerShell is up to date. Invoke-Expression: C:\Users\Haseeb Ul Hassan\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:503 Line | 503 | Invoke-Expression $existingTheme | ~~~~~~~~~~~~~~ | Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Command'. Specified method | is not supported. Use 'Show-Help' to display help When I removed the microsoft_profile from the directory then the following error started occuring. Get-FileHash: C:\Users\Haseeb Ul Hassan\Documents\PowerShell\profile.ps1:58 Line | 58 | $oldhash = Get-FileHash $PROFILE | ~~~~~~~~~~~~~~~~~~~~~ | Cannot find path 'C:\Users\Haseeb Ul Hassan\Documents\PowerShell\Microsoft.PowerShell_profile.ps1' because it | does not exist. Profile has been updated. Please restart your shell to reflect changes Checking for PowerShell updates... Your PowerShell is up to date. Invoke-Expression: C:\Users\Haseeb Ul Hassan\Documents\PowerShell\profile.ps1:503 Line | 503 | Invoke-Expression $existingTheme | ~~~~~~~~~~~~~~ | Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Command'. Specified method | is not supported. Use 'Show-Help' to display help Profile is up to date. Checking for PowerShell updates... Your PowerShell is up to date. Invoke-Expression: C:\Users\Haseeb Ul Hassan\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:503 Line | 503 | Invoke-Expression $existingTheme | ~~~~~~~~~~~~~~ | Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Command'. Specified method | is not supported. Use 'Show-Help' to display help

I am using 7.4.6 powershell. I am also using latest profile from github.

haseeb-techsavy avatar Jan 10 '25 03:01 haseeb-techsavy

Can anyone provide any help? Trying to get this going in WT and every time I launch I get the following, starting to get into using PowerShell more and more as an admin, and I'd like to start with a good set of tools to sharpen my skill.

PowerShell 7.5.3 MethodInvocationException: C:\Users\USERPROFILE\OneDrive - OTC Industrial\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:152 Line | 152 | if (-not $debug -and | ~~~~~~~~~~~~~~~~~~ | Exception calling "ParseExact" with "3" argument(s): "String '2025-10-09T17:06:33.6500774Z' was not recognized | as a valid DateTime." MethodInvocationException: C:\Users\USERPROFILE\OneDrive - OTC Industrial\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:197 Line | 197 | if (-not $debug -and | ~~~~~~~~~~~~~~~~~~ | Exception calling "ParseExact" with "3" argument(s): "String '2025-10-09T17:06:33.6500774Z' was not recognized | as a valid DateTime." Use 'Show-Help' to display help Loading personal and system profiles took 2169ms.

pcitalian avatar Oct 09 '25 17:10 pcitalian