Trying to get script to work with new PowerShell module

Trying to get script to work with new PowerShell module

avatar

Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-Module -Name Devolutions.PowerShell

$DS_URL= 'https://dps'
$appSecret = ''
$appKey = ''
[securestring]$Password = ConvertTo-SecureString $appSecret -AsPlainText -Force
[pscredential]$Credential = New-Object System.Management.Automation.PSCredential ($appKey, $Password)
New-DSSession $Credential $DS_URL -AsApplication --quiet | out-null
$sensitivedata = (Get-DSEntrySensitiveData -EntryId "41981d69-6306-4f8e-9dd9-0f38cb2db1de").body.data
Write-Output $sensitivedata.credentials.password



Getting this output:

New-DSSession: /saltstack/base/development/password/DevolutionsRead.ps1:10
Line |
 10 |  New-DSSession $Credential $DS_URL -AsApplication --quiet | out-null
   |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'.
Get-DSEntrySensitiveData: /saltstack/base/development/password/DevolutionsRead.ps1:11
Line |
 11 |  … tivedata = (Get-DSEntrySensitiveData -EntryId "41981d69-6306-4f8e-9dd
   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | Session does not seem authenticated, call New-DSSession.
PS /saltstack/base/development/password> ./DevolutionsRead.ps1
New-DSSession: /saltstack/base/development/password/DevolutionsRead.ps1:10
Line |
 10 |  New-DSSession $Credential $DS_URL -AsApplication --quiet | out-null
   |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'.
Get-DSEntrySensitiveData: /saltstack/base/development/password/DevolutionsRead.ps1:11
Line |
 11 |  … tivedata = (Get-DSEntrySensitiveData -EntryId "41981d69-6306-4f8e-9dd
   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | Session does not seem authenticated, call New-DSSession.

All Comments (9)

avatar

Hello,

What DVLS version are you using?

What Devolutions.PowerShell module have you installed on the machine? You can get the information using the following command.

Get-Module -ListAvailable -Name 'Devolutions.PowerShell'


Best regards,

Érica Poirier

avatar

DVLS version:  


Get-Module -ListAvailable -Name 'Devolutions.PowerShell'

  Directory: /root/.local/share/powershell/Modules

ModuleType Version  PreRelease Name                PSEdition ExportedCommands
---------- -------  ---------- ----                --------- ----------------
Binary   2023.2.0.4      Devolutions.PowerShell       Core   {Add-RDMRoleRepositoryAccess, Add-RDMRoleToUser, Add-RDMSessionAttachment, Add…

avatar

DVLS version:  2023.1.8.0

avatar

Hello,

Thank you for the information.

Could you please try to uninstall that module version and then install the same major Devolutions.PowerShell module that correspond to your DVLS version?

Uninstall-Module -Name Devolutions.PowerShell
Install-Module -Name Devolutions.PowerShell -RequiredVersion 2023.1.0.10 -Force


Let us know if that helps.

Best regards,

Érica Poirier

avatar

Now I get this error

New-DSSession: /saltstack/base/development/password/DevolutionsRead.ps1:9    
Line |
  9 |  New-DSSession $Credential $DS_URL -AsApplication --quiet | out-null
   |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | A positional parameter cannot be found that accepts argument
   | 'System.Management.Automation.PSCredential'.
Get-DSEntrySensitiveData: /saltstack/base/development/password/DevolutionsRead.ps1:10
Line |
 10 |  … tivedata = (Get-DSEntrySensitiveData -EntryId "41981d69-6306-4f8e-9dd
   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | Session does not seem authenticated, call New-DSSession.

avatar

Hello,

Could you please try without the --quiet parameter?

It has 2 hyphen instead of one and it's not listed in the accepted parameters.

Let us know if that helps.

Best regards,

Érica Poirier

avatar

I changed line 9 to "New-DSSession $Credential $DS_URL -AsApplication"

I get this error:

New-DSSession: /saltstack/base/development/password/DevolutionsRead.ps1:9                        
Line |
  9 |  New-DSSession $Credential $DS_URL -AsApplication
   |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'.
Get-DSEntrySensitiveData: /saltstack/base/development/password/DevolutionsRead.ps1:10
Line |
 10 |  … tivedata = (Get-DSEntrySensitiveData -EntryId "41981d69-6306-4f8e-9dd
   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | Session does not seem authenticated, call New-DSSession.

avatar

any updates on this?

avatar

Hello,

Could you please try the following?

New-DSSession -Credential $Credential -BaseUri $DS_URL -AsApplication --quiet | out-null


The parameter are not properly identified and the order is important if we do not provide the proper switches for each parameters.

Let us know if that works.

Best regards,

Érica Poirier