Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Created March 17, 2023 19:29
Show Gist options
  • Save arcanadev/4e230023ad6280ee9ebbfb90b9f2f8fb to your computer and use it in GitHub Desktop.
Save arcanadev/4e230023ad6280ee9ebbfb90b9f2f8fb to your computer and use it in GitHub Desktop.
Set a new password for a Credential Profile #adTempus #api #version4 #powershell

This PowerShell script uses the adTempus API to retrieve a Credential Profile and set a new password for it.

Usage:

.\set-adtcredentialpassword -account userid -newpassword password
param (
[string]$server = ".",
[Parameter(Mandatory)]
[string]$account,
[Parameter(Mandatory)]
[string]$newPassword
)
# Reference for adTempus 4
add-type -path "c:\program files\arcana development\adtempus\4.0\ArcanaDevelopment.adTempus.Client.dll"
# For adTempus 5 use one of these instead:
# if running on an adTempus server:
# add-type -path "c:\program files\arcana development\adtempus\instances\default\bin\ArcanaDevelopment.adTempus.Client.dll"
# if only the Console is installed:
# add-type -path "c:\program files\arcana development\adtempus\5.0\Console\ArcanaDevelopment.adTempus.Client.dll"
try{
$adtempus=[ArcanaDevelopment.adTempus.Client.Scheduler]::Connect($server,[ArcanaDevelopment.adTempus.Shared.LoginAuthenticationType]::Windows,"","")
}
catch{
$_
exit 8
}
try{
$context=$adtempus.NewDataContext()
$profile=$context.GetCredentialProfile($account, $null, $null)
if($profile -eq $null){
Write-Output "Profile not found"
exit 8
}
$profile.SetPassword($newPassword)
$profile.Save()
Write-Output "Password updated"
}
catch{
$_
exit 8
}
finally{
$context.Dispose()
$adTempus.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment