rubrikinc / rubrik-powershell-sdk

The Rubrik Security Cloud SDK
https://www.powershellgallery.com/packages/RubrikSecurityCloud
MIT License
7 stars 8 forks source link

Cmdlets not seeing connect session when run in script #38

Closed mwpreston closed 6 months ago

mwpreston commented 7 months ago

When we use Connect-RSC within a script, the cmdlets that follow it are reporting No active session found. Use Connect-RSC

Running the commands manually within the PowerShell Console works fine.

Steps to reproduce

Create test.ps1 containing the following syntax

Import-Module RubrikSecurityCloud
$id = "clientid"
$secret = "secret"
$url = "URL to RSC"

Connect-RSC -ClientId $Id -ClientSecret ($Secret | ConvertTo-SecureString -asplaintext) -Server $url
Get-RSCSLADomain

Execute test.ps1 with ./test.ps1

This is the same behaviour I'm getting when looking to merge RSC and CDM module - the session can't be found

guirava commented 6 months ago

Version 0.23 fixes this.

This wasn't actually a bug, but it was how we imagined to use Connect-Rsc : it makes the connection object visible to the current script . So you call Connect-Rsc wherever you need it and it'll either reuse any existing connection object or create a new one.

With version 0.23 we changed the model so that once you have a successful connection , it is visible anywhere in the session.