Skip to content

Querying Autodesk Vault Data with PowerShell Cmdlets

Overview

MinuteView Server provides a set of PowerShell cmdlets that enable users to query and extract data directly from Autodesk Vault using the REST API. These cmdlets are designed for read-only access and do not consume Vault CAL licenses, making them ideal for automated reporting, data extraction, and integration scenarios.

This article demonstrates how to leverage custom PowerShell scripts to query Vault data via the PostData endpoint and extract information using the MinuteView PowerShell cmdlet library.


Benefits of REST API Access

  • License-Free Queries: Read-only REST API connections do not consume Autodesk Vault CAL (Client Access License) seats
  • Automation-Friendly: Perfect for scheduled reports, data exports, and integrations
  • No Vault Client Required: Scripts can run on servers or workstations without the Vault client installed
  • Secure Access: Uses token-based authentication with configurable read-only permissions

Getting Started

1. Establishing a Connection

Before querying Vault data, you must establish a connection using the Open-VaultConnReadOnly cmdlet. This creates a read-only REST API connection that does not consume a license.

powershell
# Establish a read-only connection to Vault
Open-VaultConnReadOnly -Server "vault-server.company.com" `
                       -VaultName "ProductionVault" `
                       -UserName "service-account" `
                       -Password "SecurePassword123"

Connection Parameters:

  • Server (Required): The Vault server hostname or IP address
  • VaultName (Required): The name of the Vault database to connect to
  • UserName (Required): The Vault user account for authentication
  • Password (Optional): The password for the user account. If omitted, the cmdlet will attempt integrated authentication

What Happens Behind the Scenes:

  1. The cmdlet authenticates with the Vault REST API
  2. A session token is generated and stored in the PowerShell session variable $vRestConn
  3. All subsequent cmdlets automatically use this connection
  4. The connection is read-only and does not consume a CAL license

Searching for Files

Basic Search (Contains)

For simple "contains" searches, use the BasicContainsConditions parameter with a hashtable:

powershell
# Find all files where the filename contains "Pump"
$results = Find-VaultFiles -Types "File" `
                           -LatestOnly $true `
                           -BasicContainsConditions @{
                               "NAME" = "Pump"
                           }

# Display results
$results | Format-Table

Multiple Basic Conditions:

powershell
# Search for files containing "Pump" in the name AND "Released" in the state
$results = Find-VaultFiles -Types "File" `
                           -LatestOnly $true `
                           -BasicContainsConditions @{
                               "NAME" = "Pump"
                               "State" = "Released"
                           }

Advanced Search (Exact Match and Other Operators)

For exact matches or other comparison operators, use the Create-SearchCondition cmdlet with the AdvancedSearchConditions parameter.

Available Search Operators:

  • Contains - Partial match (substring search)
  • DoesNotContain - Excludes results containing the value
  • IsExactly - Exact match (case-sensitive)
  • IsEmpty - Property has no value
  • IsNotEmpty - Property has a value
  • GreaterThan - Numeric/date comparison
  • GreaterThanOrEqualTo - Numeric/date comparison
  • LessThan - Numeric/date comparison
  • LessThanOrEqualTo - Numeric/date comparison
  • NotEqualTo - Not equal to the specified value
powershell
# Create an exact match condition for a specific part number
$condition = Create-SearchCondition -PropertyName "Part Number" `
                                   -Condition "IsExactly" `
                                   -Value "PMP-12345-REV-A"

# Execute the search
$results = Find-VaultFiles -Types "File" `
                           -LatestOnly $true `
                           -AdvancedSearchConditions @($condition)

# Display results
$results | Select-Object name, @{Name='FileId';Expression={$_.id}}, createDate

Example: Multiple Advanced Conditions

powershell
# Create multiple search conditions
$nameCondition = Create-SearchCondition -PropertyName "NAME" `
                                       -Condition "IsExactly" `
                                       -Value "Motor_Assembly.iam"

$stateCondition = Create-SearchCondition -PropertyName "State" `
                                        -Condition "IsExactly" `
                                        -Value "Released"

$dateCondition = Create-SearchCondition -PropertyName "Date Modified" `
                                       -Condition "GreaterThan" `
                                       -Value "2024-01-01"

# Combine conditions (AND logic)
$results = Find-VaultFiles -Types "File" `
                           -LatestOnly $true `
                           -AdvancedSearchConditions @($nameCondition, $stateCondition, $dateCondition)

Search Parameters

-Types (Required)

Specifies the entity type to search. Valid values:

  • "File" - Search for files
  • "Folder" - Search for folders
powershell
# Search for folders
$folders = Find-VaultFiles -Types "Folder" `
                           -LatestOnly $true `
                           -BasicContainsConditions @{"NAME" = "Drawings"}

-LatestOnly (Required)

Determines whether to return only the latest version of files:

  • $true - Returns only the latest version of each file (recommended for most queries)
  • $false - Returns all versions matching the search criteria
powershell
# Get all versions of files named "Assembly"
$allVersions = Find-VaultFiles -Types "File" `
                               -LatestOnly $false `
                               -BasicContainsConditions @{"NAME" = "Assembly"}

Practical Examples

Example 1: Export Released Drawings to CSV

powershell
# Connect to Vault
Open-VaultConnReadOnly -Server "vault.company.com" `
                       -VaultName "Engineering" `
                       -UserName "report-service"

# Search for released drawings
$stateCondition = Create-SearchCondition -PropertyName "State" `
                                        -Condition "IsExactly" `
                                        -Value "Released"

$extensionCondition = Create-SearchCondition -PropertyName "File Extension" `
                                            -Condition "IsExactly" `
                                            -Value "dwg"

$drawings = Find-VaultFiles -Types "File" `
                            -LatestOnly $true `
                            -AdvancedSearchConditions @($stateCondition, $extensionCondition)

# Export to CSV
$drawings | Select-Object name,
                         @{Name='FileId';Expression={$_.id}},
                         createDate,
                         @{Name='CreatedBy';Expression={$_.createUserName}},
                         @{Name='Size';Expression={$_.fileSize}} |
           Export-Csv -Path "C:\Reports\ReleasedDrawings.csv" -NoTypeInformation

Write-Host "Exported $($drawings.Count) drawings to CSV"

Example 2: Find Files Modified in the Last 30 Days

powershell
# Calculate date 30 days ago
$thirtyDaysAgo = (Get-Date).AddDays(-30).ToString("yyyy-MM-dd")

# Create search condition
$dateCondition = Create-SearchCondition -PropertyName "Date Modified" `
                                       -Condition "GreaterThanOrEqualTo" `
                                       -Value $thirtyDaysAgo

# Find recent files
$recentFiles = Find-VaultFiles -Types "File" `
                               -LatestOnly $true `
                               -AdvancedSearchConditions @($dateCondition)

# Group by user
$recentFiles | Group-Object -Property modifyUserName |
              Select-Object Name, Count |
              Sort-Object Count -Descending

Example 3: Find Empty or Missing Properties

powershell
# Find files where "Description" property is empty
$emptyDescCondition = Create-SearchCondition -PropertyName "Description" `
                                            -Condition "IsEmpty" `
                                            -Value ""

$filesNeedingDesc = Find-VaultFiles -Types "File" `
                                    -LatestOnly $true `
                                    -AdvancedSearchConditions @($emptyDescCondition)

Write-Host "Found $($filesNeedingDesc.Count) files missing descriptions"

Example 4: Query by Custom Properties

powershell
# Search by custom Vault properties
$projectCondition = Create-SearchCondition -PropertyName "Project Code" `
                                          -Condition "IsExactly" `
                                          -Value "PRJ-2024-001"

$costCenterCondition = Create-SearchCondition -PropertyName "Cost Center" `
                                             -Condition "Contains" `
                                             -Value "Engineering"

$projectFiles = Find-VaultFiles -Types "File" `
                                -LatestOnly $true `
                                -AdvancedSearchConditions @($projectCondition, $costCenterCondition)

# Calculate total file count and size
$totalSize = ($projectFiles | Measure-Object -Property fileSize -Sum).Sum
Write-Host "Project has $($projectFiles.Count) files totaling $([math]::Round($totalSize/1MB, 2)) MB"

Integration with PostData Endpoint

These cmdlets work seamlessly with MinuteView's PostData endpoint for Vault. You can call custom PowerShell scripts via the API to extract data on-demand:

powershell
# Example script that can be invoked via PostData endpoint
param(
    [string]$PartNumber
)

# Connection is already established by the PostData handler
# Query for the specific part
$condition = Create-SearchCondition -PropertyName "Part Number" `
                                   -Condition "IsExactly" `
                                   -Value $PartNumber

$results = Find-VaultFiles -Types "File" `
                           -LatestOnly $true `
                           -AdvancedSearchConditions @($condition)

# Return results as JSON for the API response
$results | ConvertTo-Json -Depth 10

Property Names Reference

Property names must match the display names shown in the Vault UI. Common properties include:

Standard File Properties:

  • NAME - File name
  • State - Lifecycle state
  • File Extension - File extension (.dwg, .ipt, etc.)
  • Date Modified - Last modification date
  • Date Created - Creation date
  • Revision - File revision
  • Description - File description
  • Comment - File comment

System Properties:

  • File Size - Size in bytes
  • Folder - Parent folder path
  • Category - File category
  • Classification - File classification

Custom Properties:

Any custom properties defined in your Vault configuration can be queried using their display names.

Finding Property Names

To find exact property names, log into Vault and check the property dialog or contact your Vault administrator.


Important Notes

License Consumption

  • Read-only REST connections DO NOT consume CAL licenses
  • ✅ Safe for automation, scheduled tasks, and service accounts
  • ✅ Multiple concurrent connections are supported without license impact

Best Practices

  1. Use Service Accounts: Create dedicated service accounts for automation scripts
  2. LatestOnly: Use $true for most queries to avoid retrieving all file versions
  3. Specific Conditions: Use exact matches when possible to improve query performance
  4. Property Names: Verify property display names in Vault UI before querying
  5. Error Handling: Wrap queries in try/catch blocks for production scripts

Performance Considerations

  • Large result sets may take time to return
  • Consider adding date ranges or other filters to narrow results
  • Test queries interactively before scheduling automated runs

Troubleshooting

"Connection to Vault Failed"

  • Verify server name and vault name are correct
  • Check network connectivity to Vault server
  • Ensure user account has read permissions in Vault

"Failed to get property definition for: [PropertyName]"

  • Property name must match the display name exactly (case-sensitive)
  • Check spelling and capitalization in Vault UI
  • Ensure the property exists for the file type being queried

"You must provide at least one search condition"

  • Either BasicContainsConditions or AdvancedSearchConditions must be provided
  • Ensure hashtables/arrays are not empty

Additional Resources

For more advanced Vault querying capabilities, see:

  • Get-VaultFile - Retrieve specific files by FileId or MasterId
  • Get-VaultFolderByPath - Get folder details by path
  • Get-VaultFilesInFolder - List all files in a specific folder
  • Get-VaultFileUses - Get file dependencies and relationships

Need Help?

If you have questions about using PowerShell cmdlets with MinuteView Server, contact support or check our FAQ section.

Tentech