Skip to content

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set. At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:16 char:1 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gawronix opened this issue Jun 1, 2020 · 9 comments

Comments

@gawronix
Copy link

gawronix commented Jun 1, 2020

Help me fix this...
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:14 char:50

  • $GitPromptSettings.DefaultPromptPrefix.Text = "$([char]0x2192) " # ar ...
  •                                              ~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:15 char:1

  • $GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColo ...
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyAssignmentException
    
    

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:16 char:1

  • $GitPromptSettings.DefaultPromptPath.ForegroundColor =[ConsoleColor]: ...
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyAssignmentException
    
    

The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:17 char:50

  • $GitPromptSettings.DefaultPromptSuffix.Text = "$([char]0x203A) " # ch ...
  •                                              ~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:18 char:1

  • $GitPromptSettings.DefaultPromptSuffix.ForegroundColor = [ConsoleColo ...
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyAssignmentException
    
    

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:20 char:1

  • $GitPromptSettings.BeforeStatus.ForegroundColor = [ConsoleColor]::Blu ...
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
    
    

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:21 char:1

  • $GitPromptSettings.BranchColor.ForegroundColor = [ConsoleColor]::Blue
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
    
    

The property 'ForegroundColor' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\grzeg\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:22 char:1

  • $GitPromptSettings.AfterStatus.ForegroundColor = [ConsoleColor]::Blue
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound
    
    

error

@kevin-tong-msft
Copy link

I have the same issue.

@kevin-tong-msft
Copy link

kevin-tong-msft commented Jun 10, 2020

According to dahlbyk/posh-git#588, DefaultPromptPath.ForegroundColor only works on posh-git v1.0.0-beta2.
Running Update-Module posh-git -RequiredVersion 1.0.0-beta2 -AllowPrerelease works for me.

@leo-jansen
Copy link

eu estava com o mesmo problema, aconteceu pq não estava com posh-git, consegui instalar o posh-git seguindo a documentação no site do git, é só seguir o passo-passo.
https://git-scm.com/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-PowerShell

@gawronix
Copy link
Author

gawronix commented Jun 15, 2020

Now i get smth like this.... before you say, i get the same result in normal powershell window...
image

@waf
Copy link
Member

waf commented Aug 1, 2020

Hi @gawronix, can you please paste the output of the following two commands?

  • (get-module posh-git).Version
  • (get-module psreadline).Version

Thanks!

@kaellego
Copy link

kaellego commented Aug 5, 2020

According to dahlbyk/posh-git#588, DefaultPromptPath.ForegroundColor only works on posh-git v1.0.0-beta2.
Running Update-Module posh-git -RequiredVersion 1.0.0-beta2 -AllowPrerelease works for me.

An update for those experiencing problems
Update-Module posh-git -RequiredVersion 1.0.0-beta4 -AllowPrerelease -Force

@LukeSavefrogs
Copy link

LukeSavefrogs commented Aug 23, 2020

Problem

I encountered the same problem as well as an error saying i didn't have -AllowPrerelease. I tried to update both PSReadLine and PowerShellGet as said in the guide but that didn't work...

Solution

Turns out i had different versions running of both, so the PowerShell didn't know which to pick and insisted on using the 1.0 version.

In order to fix that i had to remove the old versions as said in this guide. After that and restarting all is working.


Edit

After running the operations described in the guide i linked before i was in a situation where typing Get-Module PowerShellGet would return nothing (so i couldn't check the version) but using Get-Module powershellget -ListAvailable i would find the correct module.

The error

Solution

To fix that i had to run Update-Module -Name PowerShellGet so that the version would stay unchanged since it was already updated but the module would be returned from the Get-Module call. You can see by yourself in the next screenshot the situation before the fix (red border) and the situation after the fix (green border)

After fixing

If the Update-Module call fails, you have to loosen the Execution Policies by sending Set-ExecutionPolicy -ExecutionPolicy Unrestricted. Now it should work fine. If you do so MAKE SURE TO REVERT TO HOW IT WAS BEFORE by sending Set-ExecutionPolicy -ExecutionPolicy Default after the Update-Module command has completed successfully!!

Final result

Now it works everything and when i start the Powershell i don't see The property 'xxxxx' cannot be found on this object. Verify that the property exists and can be set errors :)

image

Hope i can be helpful to someone ^^

@waf
Copy link
Member

waf commented Sep 6, 2020

I've reworked the install instructions, and added a link to @LukeSavefrogs's troubleshooting steps and information. Thanks for putting it together!

@waf waf closed this as completed Sep 6, 2020
@astroahad
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants