I am trying to Log0in into Vault using API within PowerShell. Here is my code:
[System.Reflection.Assembly]::LoadFrom('C:\Program Files\Autodesk\Autodesk Vault 2024 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll')
$serverID = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
$serverID.DataServer = "<server name>"
$serverID.FileServer = "<server name>"
$VaultName = "Vault"
$UserName = "<UserName>"
$password = "<Password>""
$licenseAgent = [Autodesk.Connectivity.WebServices.LicensingAgent]::Client
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials($serverID, $VaultName, $UserName, $password, $licenseAgent)
$vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cred)
Last line causes an error:
New-Object : Exception calling ".ctor" with "1" argument(s): "The type initializer for 'Autodesk.Connectivity.WebServicesTools.WebServiceManager' threw an exception."
At G:\Software\SSDI\Vault\Temp\Test.ps1:11 char:12
+ $vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
I cannot find any help with this error. Any suggestion why this happens?
Solved! Go to Solution.
I am trying to Log0in into Vault using API within PowerShell. Here is my code:
[System.Reflection.Assembly]::LoadFrom('C:\Program Files\Autodesk\Autodesk Vault 2024 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll')
$serverID = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
$serverID.DataServer = "<server name>"
$serverID.FileServer = "<server name>"
$VaultName = "Vault"
$UserName = "<UserName>"
$password = "<Password>""
$licenseAgent = [Autodesk.Connectivity.WebServices.LicensingAgent]::Client
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials($serverID, $VaultName, $UserName, $password, $licenseAgent)
$vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cred)
Last line causes an error:
New-Object : Exception calling ".ctor" with "1" argument(s): "The type initializer for 'Autodesk.Connectivity.WebServicesTools.WebServiceManager' threw an exception."
At G:\Software\SSDI\Vault\Temp\Test.ps1:11 char:12
+ $vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
I cannot find any help with this error. Any suggestion why this happens?
Solved! Go to Solution.
Solved by Markus.Koechl. Go to Solution.
v7 licensing (Vault 2024) requires to copy 3 files to the execution folder. I updated the PowerShell template accordingly:
# NOTE - click licensing v7 requires to copy AdskLicensingSDK_7.dll, AdskIdentitySDK.config, and AdskIdentitySDK.dll to PowerShell execution folder C:\Windows\System32\WindowsPowerShell\v1.0 before Powershell runtime starts
I reproduced your error removing the additional required files and re-established the connection adding and restarting the PowerShell terminal.
v7 licensing (Vault 2024) requires to copy 3 files to the execution folder. I updated the PowerShell template accordingly:
# NOTE - click licensing v7 requires to copy AdskLicensingSDK_7.dll, AdskIdentitySDK.config, and AdskIdentitySDK.dll to PowerShell execution folder C:\Windows\System32\WindowsPowerShell\v1.0 before Powershell runtime starts
I reproduced your error removing the additional required files and re-established the connection adding and restarting the PowerShell terminal.
I have dropped the other 2 files and even (just in case) all other Autodesk.*.DLL files from C:\Program Files\Autodesk\Autodesk Vault 2024 SDK\bin\x64 folder to the PowerShell folder and still having same error...
Here is a screenshop of my PowerSell folder:
I have dropped the other 2 files and even (just in case) all other Autodesk.*.DLL files from C:\Program Files\Autodesk\Autodesk Vault 2024 SDK\bin\x64 folder to the PowerShell folder and still having same error...
Here is a screenshop of my PowerSell folder:
I am running Vault, so I am looged in into Autodesk Account. Also, I am talking to you in this Forum, so I am logged in into my account...
I am running Vault, so I am looged in into Autodesk Account. Also, I am talking to you in this Forum, so I am logged in into my account...
Sorry, that was not it either. Adding that cast or removing $Vault = completely still produces the same error...
I have a suspition that it has something to do with $Cred variable. This is the value of my $cred variable:
RequiresClientLicense : True
UserName : Eli_Admin
ReadOnly : False
RequiresSignIn : True
RequiresSignOut : True
SupportsSignIn : True
SupportsSignOut : True
ServerIdentities : Autodesk.Connectivity.WebServices.ServerIdentities
Session :
VaultName : Vault
WindowsAuthenticationNonDefaultCredentials :
Sorry, that was not it either. Adding that cast or removing $Vault = completely still produces the same error...
I have a suspition that it has something to do with $Cred variable. This is the value of my $cred variable:
RequiresClientLicense : True
UserName : Eli_Admin
ReadOnly : False
RequiresSignIn : True
RequiresSignOut : True
SupportsSignIn : True
SupportsSignOut : True
ServerIdentities : Autodesk.Connectivity.WebServices.ServerIdentities
Session :
VaultName : Vault
WindowsAuthenticationNonDefaultCredentials :
Did you manage to connect to Vault using Powershell? I have only found these two ressources but according to this thread they are already outdated as the licensing part has changed:
I wonder why nobody at Autodesk sees the need for a good public API documentation along with examples. All documentation is fragmented, hidden in a non-public CHM file that requires a Vault and SDK installation first. Reading through multiple threads in this forum this issue is persistent over years and not adressed.
The Inventor guys handle their documentation way better incl. samples and a nice public API reference.
Did you manage to connect to Vault using Powershell? I have only found these two ressources but according to this thread they are already outdated as the licensing part has changed:
I wonder why nobody at Autodesk sees the need for a good public API documentation along with examples. All documentation is fragmented, hidden in a non-public CHM file that requires a Vault and SDK installation first. Reading through multiple threads in this forum this issue is persistent over years and not adressed.
The Inventor guys handle their documentation way better incl. samples and a nice public API reference.
I has never been resolved. I have just wend around the issue...
I has never been resolved. I have just wend around the issue...
Hello @jbetz42. We regret seeing your frustration. I acknowledge that we should enhance the accessibility of documentation and samples and best aggregate federated sources. As a first step, I recently posted a series of articles targeting this on the official Autodesk PDM|PLM Blog, tagged with Vault Customization. Now, you might shout at me to start another location to search for information about Vault programming. Yes and no - yes, it is a new link. No - it matches the overall Autodesk documentation scheme, which has product documentation, a knowledge base, community forums, and an Autodesk-hosted blog for all major products.
Back to your request for an updated template to login to Vault using Powershell: this article should provide you with the required information on what you need to change for each Vault release:
I uploaded my 2024 PowerShell template for reference. The comment in line #15 matches the requirements listed before:
With that, I dare to say that logging into Vault using Powershell has been resolved. I hope you can agree by leveraging the updated template (don't forget to remove the security block after downloading the zip; otherwise, the script will not execute).
Hello @jbetz42. We regret seeing your frustration. I acknowledge that we should enhance the accessibility of documentation and samples and best aggregate federated sources. As a first step, I recently posted a series of articles targeting this on the official Autodesk PDM|PLM Blog, tagged with Vault Customization. Now, you might shout at me to start another location to search for information about Vault programming. Yes and no - yes, it is a new link. No - it matches the overall Autodesk documentation scheme, which has product documentation, a knowledge base, community forums, and an Autodesk-hosted blog for all major products.
Back to your request for an updated template to login to Vault using Powershell: this article should provide you with the required information on what you need to change for each Vault release:
I uploaded my 2024 PowerShell template for reference. The comment in line #15 matches the requirements listed before:
With that, I dare to say that logging into Vault using Powershell has been resolved. I hope you can agree by leveraging the updated template (don't forget to remove the security block after downloading the zip; otherwise, the script will not execute).
Thank you @Markus.Koechl for providing an updated example code and all the useful resources. I will not shout at you. I promise. ✌️
May I ask you one more thing regarding the Vault API? I have recently learned that Vault basically uses a SOAP API. In this forum multiple requests exist to connect to Vault besides the provided C# examples e.g. in JavaScript or Python:
Is there any Python example code in existence to connect to Vault?
Thank you @Markus.Koechl for providing an updated example code and all the useful resources. I will not shout at you. I promise. ✌️
May I ask you one more thing regarding the Vault API? I have recently learned that Vault basically uses a SOAP API. In this forum multiple requests exist to connect to Vault besides the provided C# examples e.g. in JavaScript or Python:
Is there any Python example code in existence to connect to Vault?
Thank you @Markus.Koechl for the updated Powershell example. I managed to get it to work reading useful data from the AdminService. I have one more question regarding Properties in Vault:
Let's say I have a Property called "Manufactuer_name" that contains a list of manufacturers. How can I read the list of all values from this property in PowerShell?
I basically need a function that requires the property name as input parameter and returns a list of all possible values for the given property. Can you give me a hint on how to achieve this?
Thank you @Markus.Koechl for the updated Powershell example. I managed to get it to work reading useful data from the AdminService. I have one more question regarding Properties in Vault:
Let's say I have a Property called "Manufactuer_name" that contains a list of manufacturers. How can I read the list of all values from this property in PowerShell?
I basically need a function that requires the property name as input parameter and returns a list of all possible values for the given property. Can you give me a hint on how to achieve this?
@jbetz42: Please mark this thread as resolved and start a new one, as you asked a new question. I will answer the new one. Thanks.
@jbetz42: Please mark this thread as resolved and start a new one, as you asked a new question. I will answer the new one. Thanks.
Thank you for your quick reply @Markus.Koechl . I am not the originator of the post therefore I cannot mark your provided solution as solved. @Eli_Dexter I can confirm that the provided code works on Vault 2024 so maybe you can mark this post as solved?
As requested I have opened another post: https://forums.autodesk.com/t5/vault-customization/reading-list-values-of-a-property-in-vault-using-...
Thank you for your quick reply @Markus.Koechl . I am not the originator of the post therefore I cannot mark your provided solution as solved. @Eli_Dexter I can confirm that the provided code works on Vault 2024 so maybe you can mark this post as solved?
As requested I have opened another post: https://forums.autodesk.com/t5/vault-customization/reading-list-values-of-a-property-in-vault-using-...
Can't find what you're looking for? Ask the community or share your knowledge.