Hi,
I am trying to add credentials (username/password) after creating a new folder using Powershell. I am not getting which object to use for this purpose?
Like first create a folder, then create credentials under this folder.
Any pointers or idea on how can I achieve this?
Hi mytmpmaza
I'll check for some documentation/tips to help you use the command "New-HubEntry" in the best way possible.
Have a good day!
Hi Nathan,
Wondering if you got any update on this.
Hi mytmpmaza
I'll check for some documentation/tips to help you use the command "New-HubEntry" in the best way possible.
Have a good day!
Hi mytmpmaza,
Thanks for your patience. We are actually working on some bugs with this command. I'll keep you updated when the fix will be released.
Thank you for your comprehension.
Hi mytmpmaza,
Thanks again for your patience. The fix is finally released with this new version 2021.12.13.
To answer your question, the object for this purpose is the same for a folder and an entry: PSDecryptedEntry. The difference between them is the type you'll set in it. So in your case, you'll need to create 2 PSDecryptedEntry(1 of type folder and the other of type credential) and add them to your vault.
So below, here's an example on how to create/add a folder and create/add a credential in your newly created folder:
- Connect to your Hub with the PowerShell module
- Add a folder
- Set a variable with the "folder object". Ex:
$newFolder = [Devolutions.Hub.PowerShell.Entities.Hub.PSDecryptedEntry]@{ PsMetadata = [Devolutions.Hub.PowerShell.Entities.Hub.PSMetadata]@{ Name = "Folder"; ConnectionType = [Devolutions.Generated.Enums.ConnectionType]::Group }; Connection = [Devolutions.Generated.Models.Connection]@{ } }
- Add your folder to your vault. Ex:
$folderAdded = New-HubEntry -VaultId 9ac943e3-0e81-4257-8ff1-bac4490fdb37 -PSDecryptedEntry $newFolder
- Add a credential in your folder
- Set a variable with a "credential object" and use the newly added folder Id in "ParentId". Ex:
$newCredential = [Devolutions.Hub.PowerShell.Entities.Hub.PSDecryptedEntry]@{ PsMetadata = [Devolutions.Hub.PowerShell.Entities.Hub.PSMetadata]@{ Name = "Credential"; ParentId = $folderAdded.Connection.ID; ConnectionType = [Devolutions.Generated.Enums.ConnectionType]::Credential }; Connection = [Devolutions.Generated.Models.Connection]@{ Credentials = [Devolutions.Generated.Models.CredentialsConnection]@{ CredentialType = [Devolutions.Generated.Enums.CredentialResolverConnectionType]::Default; Password = "Password" } } }
- Finally, add your credential to your vault. Ex:
New-HubEntry -VaultId 9ac943e3-0e81-4257-8ff1-bac4490fdb37 -PSDecryptedEntry $newCredential
Hope this will help you. Don't hesitate if you have any other questions.
Have a good day and a happy new year!
Hi Nathan,
Thanks a lot for your reply.
I am unable to find documentation on somethings which I want to achieve.
Also, I tried above mentioned steps by you which worked perfectly. It created new folder and new credential under it. But when I ran the same cmdlets again, it was able to create the folder with same name again. Ideally it should throw an error. Correct?
Thanks and looking forward to your assistance here.
Hi mytmpmaza
We've got documentation about PowerShell module with some examples with commands here. But before I answer your questions. PSDecryptedEntry(Wrapper for connection) is a complex object. So we don't have, for now, documentation/examples for all possible cases/types to create/edit an entry. So in my previous post, I gave you an example of how to create a folder, a credential, and also how to "add it under" a new folder. That been said:
I hope my examples and explanation are clear and will help you. If not or you have more questions, don't hesitate.