DVLS Module: Create or change Entry Type to get a Website Entry

DVLS Module: Create or change Entry Type to get a Website Entry

avatar

Hi

Im trying to create a Web Entry with the DVLS PowerShell module (2021.7.0).

Since there is no option for the Web Entry (only for Password Entries) i tried it by creating a Password Entry and then modify the Entry Body:

$NewEntry = New-DSCredentialEntry -EntryName $CredName -Domain $CredDomain -Username $CredUser -Password $CredPass -Folder $CredFolder -Description $CredDescription -VaultID $Vault.id
$NewEntryBody = $(ConvertFrom-Json $NewEntry.originalResponse).data

# Getting values from a working template
$TemplateBody = $(ConvertFrom-Json $(Get-DSEntry -EntryID $TemplateId).originalResponse).data

$NewEntryBody.imageBytesUrl = $TemplateBody.imageBytesUrl
		$NewEntryBody.imageBytesUrl = $TemplateBody.imageBytesUrl
		$NewEntryBody.largeImageBytesUrl = $TemplateBody.largeImageBytesUrl
		$NewEntryBody.connectionSubType = $TemplateBody.connectionSubType
		$NewEntryBody.connectionType = $TemplateBody.connectionType
		$NewEntryBody.typeId = $TemplateBody.typeId
		$NewEntryBody.typeDescription = $TemplateBody.typeDescription
		$NewEntryBody.domain = $CredDomain
		$NewEntryBody.data = $TemplateBody.data
		$NewEntryBody.data.url = $CredURL
		$NewEntryBody.data.webDomain = $CredDomain
		$NewEntryBody.data.webUserName = $CredUser

Update-DSEntryBase -jsonBody (ConvertTo-Json $NewEntryBody -Depth 3)

To be sure, i get all Values directly from the working template.
But i cannot get this working:

Unexpected exception. Please see server logs for details.

Error:
ArgumentException - Requested value 'Web' was not found. 


It looks like, the Server doesnt like the connectionSubType.

Is there a known Way to create a Website Entry via DVLS Module?

Thanks,
Andreas

All Comments (8)

avatar

Hello,

As the Web entry is still not available in the list of the cmdlets, creating it may requires some assistance from our engineering team.

I will do some tests to know if it is possible to create it and will get back to you early next week.

Thank you for your patience.

Best regards,

Érica Poirier

avatar

Hi Erica

Thanks for your Reply.

I finally got it working by getting the Entry Body from a Template and creating a new entry with New-DSEntryBase.
But it needs a function which is getting the repositoryId from the specific Folder (find the Id by Name).

function findFolderIdByName($name, $allFolders)
{
    # loop trough all folders and search for specific name to return the id
    # if the folder name dont match, check if partialConnections are existent and call the function for the subfolders again
    $allFolders | Foreach-Object {
        # be sure type is folder
        if($_.typeDescription -eq "Folder")
        {
            # check if the folder name is matching the search
            if($_.group -eq $name)
            {
                # folder found - return id
                return $_.id
            }else
            {
                # check if partial connections are existens
                if($_.partialConnections)
                {
                    # recall this function for subfolders
                    findFolderIdByName $name $_.partialConnections
                }
            }
        }
    }
}


Getting the repo id by name via:

$repositoryId = findFolderIdByName $CredFolder $AllVaultFolders


Creating the Web Entry:

# get body from website template
$TemplateBody = $(ConvertFrom-Json $(Get-DSEntry -EntryID baf91709-1866-4e1e-aee0-4223d5d916cc).originalResponse).data

# modify body
$TemplateBody.repositoryId = $repositoryId
$TemplateBody.name = $CredName
$TemplateBody.group = $CredFolder
$TemplateBody.originalGroup = "$CredFolder\$CredName"
$TemplateBody.domain = $CredDomain

$TemplateBody.data.url = $CredURL
$TemplateBody.data.webDomain = $CredDomain
$TemplateBody.data.webUserName = $CredUser
$TemplateBody.data.passwordItem = @{"hasSensitiveData" = $true; "sensitiveData" = $CredPass }

$TemplateBody.PSObject.Properties.Remove('TemplateName')

# create entry
$NewEntry = New-DSEntryBase -Body $TemplateBody


I dont like this Method, but its the only way i found at the moment with the Devolutions Powershell Module.

Please let me know, if there is an Update!

Thanks,
Andreas

avatar

Hi Andreas,

Thank you for your feedback and glad you've successfully created the Web with New-DSEntryBase cmdlet.

And thank you for the function you have posted here to get the vault ID.

A workaround if you know the name of the vault you want to get would be to use the Get-DSVaults cmdlet and then fetch the vault ID from that list.

Let me know what you think about it.

Best regards,

Érica Poirier

avatar

Hi Erica

Its not the Vault Id i need to get, but the Group Id, in which the Entry should be created.
Thats why i needed this additional function. When i only add the Vault Id in Repository, then the Entry will be created in Root.

Best Regards,
Andreas

avatar

Hi Andreas,

You are right if the destination folder isn't located in the Default vault (GUID = 00000000-0000-0000-0000-000000000000). As soon as we want to save the entry in another vault, then we must use the folder's ID in order to save the entry in the proper destination.

I will bring this to the engineering team and if another method exist or could be created, we will keep you posted.

Best regards,

Érica Poirier

avatar

Hi Andreas,

Instead of your function, you can use the following command to extract the ID of the destination folder.

$repositoryId = (($res = Get-DSFolders ([guid]::Empty) -IncludeSubFolders).Body.data | Where-Object {$_.Name -eq $CredFolder}).ID

Best regards,

Érica Poirier

avatar

Hi Erica

Thanks for your Input.
Youre right! I will build this Snipped into my Script.

Best Regards,
Andreas

avatar

Hello

It looks like the above Code doesnt work anymore.
When i try to create a Web Entry via Template Body and putting the Informations via New-DSEntryBase (ConvertTo-Json $TemplateBody) im getting a Unhandled Error:

forum image

Im using the newest DVLS Module from GitHub.
What is the correct Way to create a Web Entry at the moment?

Edit: I just updated to the newest DVLS Server Version and everything looks much better. I will check and come again if i have still Problems!

Best Regards,
Andreas