PowerShell Scripting with the SDK
PowerShell Scripting With Repository Access
PowerShell scripts can access .NET assemblies like RepositoryAccess.
The following sample PowerShell script uses the Server class in RepositoryAccess to display a list of all current connections to a Laserfiche Server. The script does the following:
- Use the Add-Type cmdlet to load RepositoryAccess types into PowerShell.
- Use the New-Object cmdlet to create a new instance of the
Serverclass. - Use the EnumSessions method to enumerate through current sessions.
- Display the UserName and LoginTime properties for each session.
Displaying the current sessions in a Laserfiche Server
Add-Type -path 'C:\temp\Laserfiche.RepositoryAccess.dll'
Add-Type -path 'C:\temp\Laserfiche.HttpClient.dll'
$ServerName = 'MyServerName'
$MyServer = New-Object Laserfiche.RepositoryAccess.Server($ServerName)
[Laserfiche.RepositoryAccess.ServerSessionInfoReader]$AllSessions = $MyServer.EnumSessions()
foreach ($session in $AllSessions)
{
#print the user names and login times for all sessions in the specified Laserfiche server.
$session.UserName + ": " + $session.LogInTime.ToString()
}