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() | |
} |