<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PowerShell script to update user info in Vault in Vault Forum</title>
    <link>https://forums.autodesk.com/t5/vault-forum/powershell-script-to-update-user-info-in-vault/m-p/13617808#M128</link>
    <description>&lt;P&gt;Hi community,&lt;BR /&gt;iam trying to update user info from PowerShell script and iam facing some issue wile i use like permission denied and licensing type error while i use none or client as my license type&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#region Connect to Vault and Update a Single Windows User's Display Name&lt;/P&gt;&lt;P&gt;# Load Vault Web Services DLL&lt;BR /&gt;[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk Vault 2024 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll") | Out-Null #add you path if your dll is present in some other location&lt;/P&gt;&lt;P&gt;# Set Vault connection parameters&lt;BR /&gt;$serverIdentities = New-Object Autodesk.Connectivity.WebServices.ServerIdentities&lt;BR /&gt;$serverIdentities.DataServer = "" #server ip or name&lt;BR /&gt;$serverIdentities.FileServer = "" #server ip or name&lt;/P&gt;&lt;P&gt;$vaultName = "" #vault name&lt;BR /&gt;$userName = "" #username to login with&lt;BR /&gt;$securePassword = Read-Host 'Enter Vault Password' -AsSecureString&lt;BR /&gt;$passwordPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)&lt;BR /&gt;$password = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($passwordPtr)&lt;/P&gt;&lt;P&gt;# Licensing agent&lt;BR /&gt;$licenseType = [Autodesk.Connectivity.WebServices.LicensingAgent]::none #facing issue here if i use none i get permission denide error and if i use clent or server i get licenseing erroe&lt;/P&gt;&lt;P&gt;# Create credentials and connect&lt;BR /&gt;$userPasswordCredentials = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials(&lt;BR /&gt;$serverIdentities,&lt;BR /&gt;$vaultName,&lt;BR /&gt;$userName,&lt;BR /&gt;$password,&lt;BR /&gt;$licenseType&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;$serviceManager = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($userPasswordCredentials)&lt;BR /&gt;Write-Host "Connected to Vault: $vaultName"&lt;/P&gt;&lt;P&gt;# Username to update (current Vault username)&lt;BR /&gt;$targetUsername = Read-Host "Enter the current Vault username of the user you want to update"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Fetch all users&lt;BR /&gt;$users = $serviceManager.AdminService.GetAllUsers()&lt;/P&gt;&lt;P&gt;# Find target user&lt;BR /&gt;$user = $users | Where-Object { $_.Name -eq $targetUsername }&lt;/P&gt;&lt;P&gt;if ($user -eq $null) {&lt;BR /&gt;Write-Host "User '$targetUsername' not found."&lt;BR /&gt;} elseif ($user.Auth -ne [Autodesk.Connectivity.WebServices.AuthTyp]::Windows) {&lt;BR /&gt;Write-Host "User '$targetUsername' is not Windows-authenticated. Skipping."&lt;BR /&gt;} elseif (-not $user.Email -or -not $user.Email.Contains("@")) {&lt;BR /&gt;Write-Host "User '$targetUsername' does not have a valid email. Skipping."&lt;BR /&gt;} else {&lt;BR /&gt;# Extract initials from email&lt;BR /&gt;$initials = ($user.Email.Split("@")[0]).Substring(0, [Math]::Min(4, $user.Email.Split("@")[0].Length)).ToUpper()&lt;/P&gt;&lt;P&gt;# Fetch complete user info (roles, vaults, attributes)&lt;BR /&gt;$userInfo = $serviceManager.AdminService.GetUserInfoByUserId($user.Id)&lt;/P&gt;&lt;P&gt;$userId = $user.Id&lt;BR /&gt;$userName = $user.Name # Keep original username (you cannot change this in Vault)&lt;BR /&gt;$email = $user.Email&lt;BR /&gt;$isActive = $user.IsAct&lt;BR /&gt;$roleIds = $userInfo.Roles | ForEach-Object { $_.Id }&lt;BR /&gt;$vaultIds = $userInfo.Vaults | ForEach-Object { $_.Id }&lt;BR /&gt;$attributes = $userInfo.Attributes&lt;/P&gt;&lt;P&gt;# Update FullName attribute to initials&lt;BR /&gt;foreach ($attr in $attributes) {&lt;BR /&gt;if ($attr.Name -eq "FullName") {&lt;BR /&gt;$attr.Val = $initials&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Updating display name (FullName) of user '$userName' to '$initials'..."&lt;/P&gt;&lt;P&gt;# Update the user info&lt;BR /&gt;$serviceManager.AdminService.UpdateUserInfo(&lt;BR /&gt;$userId,&lt;BR /&gt;$userName,&lt;BR /&gt;$email,&lt;BR /&gt;$isActive,&lt;BR /&gt;$roleIds,&lt;BR /&gt;$vaultIds,&lt;BR /&gt;$attributes&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Write-Host "Update complete for user '$userName'."&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;} catch {&lt;BR /&gt;Write-Error "Error occurred: $_"&lt;BR /&gt;} finally {&lt;BR /&gt;if ($serviceManager -ne $null) {&lt;BR /&gt;$serviceManager.Dispose()&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#endregion&lt;BR /&gt;&lt;BR /&gt;and do review the code Onces if iam doing it in the right way&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 May 2025 10:07:46 GMT</pubDate>
    <dc:creator>MOHITSINGI</dc:creator>
    <dc:date>2025-05-07T10:07:46Z</dc:date>
    <item>
      <title>PowerShell script to update user info in Vault</title>
      <link>https://forums.autodesk.com/t5/vault-forum/powershell-script-to-update-user-info-in-vault/m-p/13617808#M128</link>
      <description>&lt;P&gt;Hi community,&lt;BR /&gt;iam trying to update user info from PowerShell script and iam facing some issue wile i use like permission denied and licensing type error while i use none or client as my license type&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#region Connect to Vault and Update a Single Windows User's Display Name&lt;/P&gt;&lt;P&gt;# Load Vault Web Services DLL&lt;BR /&gt;[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk Vault 2024 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll") | Out-Null #add you path if your dll is present in some other location&lt;/P&gt;&lt;P&gt;# Set Vault connection parameters&lt;BR /&gt;$serverIdentities = New-Object Autodesk.Connectivity.WebServices.ServerIdentities&lt;BR /&gt;$serverIdentities.DataServer = "" #server ip or name&lt;BR /&gt;$serverIdentities.FileServer = "" #server ip or name&lt;/P&gt;&lt;P&gt;$vaultName = "" #vault name&lt;BR /&gt;$userName = "" #username to login with&lt;BR /&gt;$securePassword = Read-Host 'Enter Vault Password' -AsSecureString&lt;BR /&gt;$passwordPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)&lt;BR /&gt;$password = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($passwordPtr)&lt;/P&gt;&lt;P&gt;# Licensing agent&lt;BR /&gt;$licenseType = [Autodesk.Connectivity.WebServices.LicensingAgent]::none #facing issue here if i use none i get permission denide error and if i use clent or server i get licenseing erroe&lt;/P&gt;&lt;P&gt;# Create credentials and connect&lt;BR /&gt;$userPasswordCredentials = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials(&lt;BR /&gt;$serverIdentities,&lt;BR /&gt;$vaultName,&lt;BR /&gt;$userName,&lt;BR /&gt;$password,&lt;BR /&gt;$licenseType&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;$serviceManager = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($userPasswordCredentials)&lt;BR /&gt;Write-Host "Connected to Vault: $vaultName"&lt;/P&gt;&lt;P&gt;# Username to update (current Vault username)&lt;BR /&gt;$targetUsername = Read-Host "Enter the current Vault username of the user you want to update"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Fetch all users&lt;BR /&gt;$users = $serviceManager.AdminService.GetAllUsers()&lt;/P&gt;&lt;P&gt;# Find target user&lt;BR /&gt;$user = $users | Where-Object { $_.Name -eq $targetUsername }&lt;/P&gt;&lt;P&gt;if ($user -eq $null) {&lt;BR /&gt;Write-Host "User '$targetUsername' not found."&lt;BR /&gt;} elseif ($user.Auth -ne [Autodesk.Connectivity.WebServices.AuthTyp]::Windows) {&lt;BR /&gt;Write-Host "User '$targetUsername' is not Windows-authenticated. Skipping."&lt;BR /&gt;} elseif (-not $user.Email -or -not $user.Email.Contains("@")) {&lt;BR /&gt;Write-Host "User '$targetUsername' does not have a valid email. Skipping."&lt;BR /&gt;} else {&lt;BR /&gt;# Extract initials from email&lt;BR /&gt;$initials = ($user.Email.Split("@")[0]).Substring(0, [Math]::Min(4, $user.Email.Split("@")[0].Length)).ToUpper()&lt;/P&gt;&lt;P&gt;# Fetch complete user info (roles, vaults, attributes)&lt;BR /&gt;$userInfo = $serviceManager.AdminService.GetUserInfoByUserId($user.Id)&lt;/P&gt;&lt;P&gt;$userId = $user.Id&lt;BR /&gt;$userName = $user.Name # Keep original username (you cannot change this in Vault)&lt;BR /&gt;$email = $user.Email&lt;BR /&gt;$isActive = $user.IsAct&lt;BR /&gt;$roleIds = $userInfo.Roles | ForEach-Object { $_.Id }&lt;BR /&gt;$vaultIds = $userInfo.Vaults | ForEach-Object { $_.Id }&lt;BR /&gt;$attributes = $userInfo.Attributes&lt;/P&gt;&lt;P&gt;# Update FullName attribute to initials&lt;BR /&gt;foreach ($attr in $attributes) {&lt;BR /&gt;if ($attr.Name -eq "FullName") {&lt;BR /&gt;$attr.Val = $initials&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Updating display name (FullName) of user '$userName' to '$initials'..."&lt;/P&gt;&lt;P&gt;# Update the user info&lt;BR /&gt;$serviceManager.AdminService.UpdateUserInfo(&lt;BR /&gt;$userId,&lt;BR /&gt;$userName,&lt;BR /&gt;$email,&lt;BR /&gt;$isActive,&lt;BR /&gt;$roleIds,&lt;BR /&gt;$vaultIds,&lt;BR /&gt;$attributes&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Write-Host "Update complete for user '$userName'."&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;} catch {&lt;BR /&gt;Write-Error "Error occurred: $_"&lt;BR /&gt;} finally {&lt;BR /&gt;if ($serviceManager -ne $null) {&lt;BR /&gt;$serviceManager.Dispose()&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#endregion&lt;BR /&gt;&lt;BR /&gt;and do review the code Onces if iam doing it in the right way&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 10:07:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-forum/powershell-script-to-update-user-info-in-vault/m-p/13617808#M128</guid>
      <dc:creator>MOHITSINGI</dc:creator>
      <dc:date>2025-05-07T10:07:46Z</dc:date>
    </item>
  </channel>
</rss>

