rubrikinc / rubrik-powershell-sdk

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

Import-Module after a Update-Module/Install-Module? #138

Open SahFari opened 2 months ago

SahFari commented 2 months ago

Don't know if it's customary to run Import-Module after an Update-Module or Install-Module -RequiredVersion or not, however, this is what I have done.

P.s. I am on PowerShell 7.4.5. using the latest version of vsCode. D.s.

I updated the module


Update-Module RubrikSecurityCloud -Scope AllUsers -Force

Import-Module RubrikSecurityCloud -Force -Verbose

Connect-Rsc -IfNeeded | Out-Null

I have been able to connect to RSC, once afer that has other RSC commands failed, including Connect-Rsc.

I have closed and reopend vsCode, more than 5 times yesterday and I think another 5 times today. I have rebooted my PC as well.

I have uninstalled all other versions leaving 1.7. Same behavier after an import-module. Reinstalled version 1.5, uninstalled 1.7. New import-moudle, closed and reopend vsCode.

I have now reinstalled 1.7 and 1.8 without running import-module, closed and reopened vsCode. RSC commands I have tested works.

Connect-Rsc -IfNeeded | Out-Null

PS C:\PS> Connect-Rsc -IfNeeded | Out-Null
WARNING: Connect_Rsc: The installed RSC SDK version does not match the server version.

PS C:\PS> Get-RscEventSeries

LastActivityStatus   : RUNNING
ObjectType           : MSSQL

These are the errors:

PS C:\PS> Get-RscCluster
Invoke-Rsc: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.8\Toolkit\Public\Get-RscCluster.ps1:160:21
Line |
 160 |          $response = Invoke-Rsc $query
     |                      ~~~~~~~~~~~~~~~~~
     | One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))

PS C:\PS> Connect-Rsc
Connect-Rsc: One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))

PS C:\PS> DisConnect-Rsc
Disconnect-Rsc: One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))

Uninstall-Module RubrikSecurityCloud -MinimumVersion 1.7 -Force

Import-Module RubrikSecurityCloud -Force -Verbose

Connect-Rsc -IfNeeded | Out-Null

PS C:\PS> Connect-Rsc
Connect-Rsc: One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))

PS C:\PS> Get-RscCluster
Invoke-Rsc: C:\Program Files\PowerShell\Modules\RubrikSecurityCloud\1.8\Toolkit\Public\Get-RscCluster.ps1:160:21
Line |
 160 |          $response = Invoke-Rsc $query
     |                      ~~~~~~~~~~~~~~~~~
     | One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))

PS C:\PS> DisConnect-Rsc
Disconnect-Rsc: One or more errors occurred. (Could not load file or assembly 'Microsoft.IdentityModel.Abstractions, Version=8.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621))
rynardtspies commented 2 months ago

@SahFari

Could you let me know if you're only using the terminal in VSCode?

I am unable to reproduce this.

What OS version are you running?

In the past, I have seen inconsistencies in dependency/package resolution between the terminal in VSCode and the PowerShell Console. Could you try again using the PowerShell console outside of VSCode?

SahFari commented 2 months ago

@rynardtspies

I mostly use Editor in VsCode.

I will do new tests tomorrow:

I use WIN 10: Major Minor Build Revision


10 0 19045 0

SahFari commented 2 months ago

@rynardtspies Hi, I installed 1.9 on my PC and on a lab server. I removed all other versions from my pc not on the lab server. The lab server is on PowerShell 7.4.4. Mine PC is on PowerShell 7.4.5.

  1. I need to import the module each time I start either PowerShell 7 Console (pwsh) or VSCode. This only on my PC, not on the lab server.
  2. I get the same error in VSCode if I if use PowerShell Extension. It works fine with pwsh. This both from the console or editor. It is the same behavior on both tested PC/server.

This screenshot is from the lab server

image

These screenshot is from my pc

image

image

image

SahFari commented 2 months ago

Update: don't need to import the module each time I start VSCode/PowerShell Console!