We use the following script to grab an entry but get errors in linux. Doesn't seem to set a session id
$DS_URL= 'https://url/dps'
$appSecret = 'secret'
$appKey = 'key'
[securestring]$Password = ConvertTo-SecureString $appSecret -AsPlainText -Force
[pscredential]$Credential = New-Object System.Management.Automation.PSCredential ($appKey, $Password)
# Connect to Devolutions Server using an Application
New-DSSession $Credential $DS_URL -AsApplication
# Here I have set the entry id which I have gotten from the URL
$EntryId = 'entry'
$sensitivedata = Get-DSEntrySensitiveData $EntryId
Write-Output $sensitivedata
ConvertFrom-Json: /root/.local/share/powershell/Modules/Devolutions.Server/2022.3.7.4/Public/Authentication/New-DSSession.ps1:78
Line |
78 | $jsonData = ConvertFrom-Json $ServerResponse.Content -Depth 1 …
| ~~~~~~~~~~~~~~~~~~~~~~~
| Cannot bind argument to parameter 'InputObject' because it is null.
InvalidOperation: /root/.local/share/powershell/Modules/Devolutions.Server/2022.3.7.4/Public/Authentication/New-DSSession.ps1:79
Line |
79 | Set-Variable -Name DSInstanceVersion -Value $jsonData.data.ve …
| ~~~~~~~~~
| The variable '$jsonData' cannot be retrieved because it has not been set.
Hello,
Thank you for reporting this issue.
It seems that the New-DSSession cmdlet isn't working per the error message.
Do you get the same behaviour on a Windows machine?
What Linux version are you using?
I will try to reproduce that issue internally.
Best regards,
Érica Poirier
It works on a windows server with no error.
We are using centos 7
Hello,
Thank you for the information.
We will test this and will keep you posted.
Thank you for your patience.
Best regards,
Érica Poirier
Hello,
I'm sorry for this late reply. We now have a VM on CentOS 7 that is working in our test environment.
At the moment, I'm struggling with a certificate problem on our side but maybe the following could help you identify the issue.
This is the first call made in the New-DSSession cmdlet to fetch the DVLS server information.
$ServerResponse=Invoke-WebRequest-Uri "$BaseURI/api/public-instance-information"-Method 'GET'-SessionVariable Global:WebSession
So could you please this and let us know what you get? Please replace the variable's values with your information.
$DS_URL= 'https://url/dps' $appSecret = 'secret' $appKey = 'key' [securestring]$Password = ConvertTo-SecureString $appSecret -AsPlainText -Force [pscredential]$Credential = New-Object System.Management.Automation.PSCredential ($appKey, $Password) $ServerResponse=Invoke-WebRequest-Uri "$DS_URL/api/public-instance-information"-Method 'GET'-SessionVariable Global:WebSession
Best regards,
Érica Poirier
Hello,
Finally I have been able to reproduce your issue.
A ticket has been sent to our engineering team. Once an update will be available, we will post it here.
Thank you for your patience.
Best regards,
Érica Poirier
thank you for the update
Hello,
Our engineer has recently published an update on GitHub.
Could you please try to download and test this new version?
Let us know if that works on your CentOs 7 machine.
Best regards,
Érica Poirier
How do I manually update the module?
Hello,
You can download the zip package and extract its files in a folder. Then you import the Devolutions.Server.psd1 form that location in your script.
Let me know if that works.
Best regards,
Érica Poirier
That worked, when will the update be pushed to the repository?
Now we are able to get a password with powershell but it returns a lot of json with the answer, how can we get just the password or just a hash?
Thanks
Hi Dianna,
The CMDlet "Get-DSEntrySensitiveData" returns the sensitive data for a given entry. An entry can have a lot of different fields that are considered sensitive, such as the password, credentials or OTP key. You can select what property you want by piping the result to "ForEach-Object" like so;
$SensitiveData | ForEach-Object { $_.passwordItem }
The new version should be available for download on PSGallery in the following hour.
Best regards,
Alexandre Martigny
The code you gave us didn't work for our script above or we don't understand how to add it, can you please clarify?
Hello,
Thank you for your feedback.
In fact you should use the above command like this short sample. I use your script you posted in this thread and add the command my colleague provided.
$EntryId = 'entry'
$sensitivedata = Get-DSEntrySensitiveData $EntryId
$sensitivedata | ForEach-Object {$_.passwordItem}
Let us know if it works. If not, please provide any error you may have.
Best regards,
Érica Poirier
I get no output from that.
Thanks
Dianna
Hello Dianna,
If your entry is a regular username/password, you can use the following, it assumes the name of the entry is unique:
$Entry = (Get-DSEntry -FilterValue "name of the entry" -SearchAllVaults).Body.data $sensitivedata = (Get-DSEntrySensitiveData -EntryId $Entry.id).body.data $sensitivedata.credentials
In Devolutions Server :
Best regards,
Richard Boisvert
now im getting this error
Get-DSEntrySensitiveData: /home/amr2002/Devolutions_TestRead_PW.ps1:16
Line |
16 | $sensitivedata = (Get-DSEntrySensitiveData -EntryId $Entry.id).body.d …
| ~~~~~~~~~
| Cannot process argument transformation on parameter 'EntryId'. Cannot convert null to type "System.Guid".
Hello Diana,
The error is that the EntryID is null, which means the first line, the Get-DSEntry, failed. If you have the ID of the entry, you can use the following instead:
$sensitivedata = (Get-DSEntrySensitiveData -EntryId "id-of-entry").body.data $sensitivedata.credentials
To get the ID, the fastest method is to go to the web interface, click on the entry, and then copy the ID from the URL. The first GUID is the Vault (the default vault is always 000000...), the second one is the entry:
Best regards,
Richard Boisvert
That works, is there a way to just get just the password? if not we can work with this
Hello Diana,
Yes, just replace it with the following:
$sensitivedata = (Get-DSEntrySensitiveData -EntryId $Entry.id).body.data $sensitivedata.credentials.password
Or if you want a one line:
(Get-DSEntrySensitiveData -EntryId $Entry.id).body.data.credentials.password
Best regards,
Richard Boisvert