Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Last active February 6, 2025 22:06
Show Gist options
  • Save arcanadev/9d3b570806c1c4ad1f06018443e41552 to your computer and use it in GitHub Desktop.
Save arcanadev/9d3b570806c1c4ad1f06018443e41552 to your computer and use it in GitHub Desktop.
Set a new password for a File Server definition #adTempus #api #version4 #powershell

This PowerShell script uses the adTempus API to retrieve a File Server definition and set a new password for it.

Usage:

.\set-ADTFileServerPassword -fileServer serverName -newpassword password
param (
[Parameter(HelpMessage="adTempus server to connect to. Defaults to local default instance.")]
[string]$server = ".",
[Parameter(Mandatory,HelpMessage="Name of the File Server definition to update")]
[string]$fileServer,
[Parameter(Mandatory,HelpMessage="New password for the File Server")]
[string]$newPassword
)
# see https://www.arcanadev.com/support/CodeSamples/9d3b570806c1c4ad1f06018443e41552 for more information.
# 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"
add-type -path "c:\program files\arcana development\adtempus\instances\default\bin\ArcanaDevelopment.adTempus.Shared.dll"
add-type -path "c:\program files\arcana development\adtempus\instances\default\bin\ArcanaDevelopment.adTempus.Resources.dll"
# if only the Console is installed:
# add-type -path "c:\program files\arcana development\adtempus\5.0\Console\ArcanaDevelopment.adTempus.Client.dll"
# add-type -path "c:\program files\arcana development\adtempus\5.0\Console\ArcanaDevelopment.adTempus.Shared.dll"
# add-type -path "c:\program files\arcana development\adtempus\5.0\Console\ArcanaDevelopment.adTempus.Resources.dll"
try{
$adtempus=[ArcanaDevelopment.adTempus.Client.Scheduler]::Connect($server,[ArcanaDevelopment.adTempus.Shared.LoginAuthenticationType]::Windows,"","")
}
catch{
$_
exit 8
}
try{
$context=$adtempus.NewDataContext()
$serverDef=$context.GetFileServiceProvider($fileServer);
if($serverDef -eq $null){
Write-Output "File server not found"
exit 8
}
$serverDef.SetPassword($newPassword)
$serverDef.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