Get-SshAgent() doesn't work #70

Closed
jchannon opened this Issue Dec 21, 2012 · 3 comments

Comments

Projects
None yet
2 participants

Here is my profile:

$agent = Get-SshAgent
if ($agent -eq 0) {
    Write-Host "Starting SSH agent..."
    Start-SshAgent -Quiet       # Start agent
    Add-SshKey          # Add my default key
} else {
    Write-Host "SSH agent is running (PID $agent)"
}

When this is run PS errors with

Get-SshAgent : The term 'Get-SshAgent' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Projects\Test\posh-git\profile.example.ps1:36 char:10

  • $agent = Get-SshAgent
  •      ~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (Get-SshAgent:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

I've modified the profile just to call Get-SshAgent on its own and the same error appears.

Owner

dahlbyk commented Dec 21, 2012

Are you also loading the posh-git module in your profile, before using Get-SshAgent?

Yes, here's all of it

Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)

# Load posh-git module from current directory
Import-Module .\posh-git

# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
# Import-Module posh-git


# Set up a simple prompt, adding the git prompt parts inside git repos
function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    # Reset color, which can be messed up by Enable-GitColors
    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    Write-Host($pwd) -nonewline

    Write-VcsStatus

    $global:LASTEXITCODE = $realLASTEXITCODE
    return "> "
}

Enable-GitColors

Pop-Location

Set-Location "C:\Projects\Test"

Stop-SshAgent
Start-SshAgent -Quiet

# Start the agent if not already running; provide feedback
$agent = Get-SshAgent
#if ($agent -eq 0) {
#   Write-Host "Starting SSH agent..."
#   Start-SshAgent -Quiet       # Start agent
#   Add-SshKey          # Add my default key
#} else {
#   Write-Host "SSH agent is running (PID $agent)"
#}

dahlbyk closed this in eab1a10 Dec 22, 2012

Owner

dahlbyk commented Dec 22, 2012

On closer inspection, Get-SshAgent was not exported by the module - I see no reason why it shouldn't be...

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