Set a new password for a Credential Profile

Language: PowerShell

View on GitHub to download or comment.

See the Client API Examples Introduction for additional information and prerequisites.

Samples index

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
set-ADTCredentialProfile.ps1
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()
}

Comments

View on GitHub to comment.