Showing results for 
Search instead for 
Did you mean: 

Connect-UcsCentral in profile



I'm trying to connect to ucscentral in my powershell profile that works fine. But when profile script ends the connection is not saved in the $global:DefaultUCSCentral variable, thus making it impossible for me to reuse the connection. 


How can this be overcome so that i have an active connection when my powershell is opened?

1 Reply 1

Cisco Employee
Cisco Employee

Hi Allan,


You could try using a PowerShell Runspace

You can refer the below link for runsapce:

Runspace :


I would recommend you to use the module “POSHRSJob”, it is available on PowerShell gallery. (This module internally uses runspace to run multiple jobs)


So you can do something like this

Install the module, this is a onetime install

Install-Module -Name POSHRSJob


Put this in your PowerShell Profile

Import-Module POSHRSJob

$job = Start-RSJob  -ScriptBlock{

    $password = ConvertTo-SecureString "password" -AsPlainText -Force

    $credsobj = New-Object System.Management.Automation.PSCredential ("username", $password)

Import-Module -Name Cisco.UCSCentral

Connect-UcsCentral <<IP>> -Credential $credsobj -NotDefault


Exit PowerShell session and start new session

Run UCS Central cmdlets using the returned connection


Import-Module -Name Cisco.UCSCentral

$connection = $job | Receive-RSJob

Import-Module -Name Cisco.UCSCentral

Get-UCSCentralOrg -UcsCentral $connection


To remove the connection

Disconnect-UcsCentral -UcsCentral $connection

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card