Administration Using PowerShell Scripts

Import-Module AlembaUtils

Use Get-Help ( PowerShell Feature) to display information about each function

An example: Changing and getting the value of Time Out

get-help Set-ServiceManagerSystemProperty

In the received information, you find:

“Set-ServiceManagerSystemProperty -SystemNameproduction -Name TimeOut -Value 240” 

Change the value to the desired one and enter it as a new command:

Set-ServiceManagerSystemProperty -SystemName production -Name TimeOut -Value 300

To get the information about the new TimeOut Value: The Syntax section helps you go from:

SYNTAX
    Set-ServiceManagerSystemProperty [[-Value] ,Object>] [[-Name] ,String.] [[-SystemName] ,String.] [,CommonParameters.]
    

To:

Get- ServiceManagerSystemProperty –Name TimeOut –SystemName “production”

AlembaUtils Functions

Get-ServiceManagerSystemAdminModule

.SYNOPSIS
Get the admin module for a named ASM system

.DESCRIPTION
Get the admin module for a named ASM system

.PARAMETER SystemName
The name of the Service Manager system

.EXAMPLE
Get-ServiceManagerSystemAdminModule -SystemName production

Get-ServiceManagerSystemNames

.SYNOPSIS
Get a list of installed alemba systems

.DESCRIPTION
Get all local alemba system names as an array of strings

.EXAMPLE 
Get-ServiceManagerSystemNames

Get-ServiceManagerSystemPath

.SYNOPSIS
Get the install path for a named Service Manager System

.DESCRIPTION
Returns the path to the system folder for a named system

.PARAMETER SystemName
The name of the Service Manager system

.EXAMPLE 
Get-ServiceManagerSystemPath -SystemName production 

=> C:\alemba\Service Manager\web\systems\production\

Get-ServiceManagerSystemProperty

SYNOPSIS
Get the current value of a specified system property for a named Service Manager system

SYNTAX
Get-ServiceManagerSystemProperty [-SystemName] <Object> [-Name] <String> [<CommonParameters>]

DESCRIPTION
Returns the string value of the specified system property

REMARKS
To see the examples, type: "get-help Get-ServiceManagerSystemProperty -examples".
For more information, type: "get-help Get-ServiceManagerSystemProperty -detailed".
For technical information, type: "get-help Get-ServiceManagerSystemProperty -full".

COMMON PARAMETERS (you can press "TAB" to cycle through them in Powershell):
Timeout
TimeoutLite
DefaultDateFormat
CurrencySign
MMAURL
LicenceKey
EnableVirusCheck
EnableTracing
ConnectionString

Get-ServiceManagerVersion

.SYNOPSIS
Get the version of Alemba Service Manager 

.DESCRIPTION
Returns a Version value representing the currently installed version of Alemba Service Manager

.EXAMPLE 
Get-ServiceManagerVersion =>
Major Minor Build Revision
----- ----- ----- -------- 
10     5     1     12345

Invoke-QueryParser

.SYNOPSIS
Parse Queries for the named system

.DESCRIPTION
Executes the parse queries process for the named Alemba Service Manager system You must restart web and windows services after executing this function

.PARAMETER SystemName
The name of the Service Manager system

.EXAMPLE
Invoke-QueryParser -SystemName production

Invoke-SQL

.SYNOPSIS
Execute a sql query using the database for a Service Manager system

.DESCRIPTION
Execute a sql query using the database for a Service Manager system Does not return any results

.PARAMETER System
The name of the Service Manager system or a reference to the System Admin Module for the named system. For optimal performance, pass a reference to an existing instance of a System Admin Module when you plan to iteratively execute many sql queries 

.PARAMETER SQL
    The SQL query text. e.g. 
    select NAME from SU_CALL_PRIORITY where REF = @REF" 
    
.PARAMETER Parameters
Optional hashtable of SQL Query parameters. e.g. 

@{ REF = 1, NAME = "Priority 1" }

Types must conform to known SQL Server Data Types. These are usually [int32] and [s
tring] and in these cases the types are inferred

.EXAMPLE
Invoke-SQL -System production -SQL "select Name from SU_CALL_PRIORITY where REF = @REF" -Parameters @{ REF = 1; }

Invoke SQLReader

.SYNOPSIS
Execute a sql query using the database for a Service Manager system

.DESCRIPTION
Execute a sql query using the database for a Service Manager system Returns results as an array of hashtables. e.g. 

@(@{ REF = 1; NAME = "P1"; }; @{ REF = 2; NAME = "P2"}; )

.PARAMETER System
The name of the Service Manager system or a reference to the System Admin Module for the named system. For optimal performance, pass a reference to an existing instance of a System Admin Module when you plan to iteratively execute many sql queries

.PARAMETER SQL
    The SQL query text. e.g. 
    
    select NAME fromSU_CALL_PRIORITY where REF = @REF" 
    
.PARAMETER Parameters
Optional hashtable of SQL Query parameters. e.g. 
@{ REF = 1, NAME = "P1" }

Types must conform to known SQL Server Data Types. These are usually [int32] and [s
tring] and in these cases the types are inferred

.EXAMPLE
Invoke-SQLReader -System production -SQL "select Name from SU_CALL_PRIORITY where REF = @REF" -Parameters @{ REF = 1; }

Invoke-SQLScript

.SYNOPSIS
Execute a sql queries from a file using the database for a Service Manager system

.DESCRIPTION
Execute a sql queries from a file using the database for a Service Manager system Does not return any results
Use GO; on a new line to separate scripts within the file

.PARAMETER System
The name of the Service Manager system or a reference to the System Admin Module for the named system. For optimal performance, pass a reference to an existing instance of a System Admin Module when you plan to iteratively execute many sql queries 

.PARAMETER FileName
Path to a file containing SQL commands.
The path can be relative to the current working directory

.EXAMPLE
Invoke-SQLScript -System production -FileName ".\script.sql" 

Set-ServiceManagerUserPassword

.SYNOPSIS
Set a new password for an existing ASM user

.DESCRIPTION
Set a new password for an existing ASM user
Only applicable when using ASM Password authentication
This is intended to be used to securely restore admin access to a system when no ot her user can access ASM

.PARAMETER SystemName
The name of the Service Manager system

.PARAMETER Username
The username (USER_ID) of the ASM User Account

.PARAMETER Password
    The new password
    
.EXAMPLE
Set-ServiceManagerUserPassword -SystemName production -Username "admin.user" -
Password ********

Set-ServiceManagerSystemProperty

.SYNOPSIS
Set system properties for a Service Manager system

.DESCRIPTION
Execute a sql queries from a file using the database for a Service Manager system Does not return any results
Use GO; on a new line to separate scripts within the file

.PARAMETER SystemName
The name of the Service Manager system

.PARAMETER Name
    The name of the system property
    
.PARAMETER Value
The value of the system property

.EXAMPLE
Set-ServiceManagerSystemProperty -SystemName production -Name TimeOut -Value 240

.EXAMPLE
Set-ServiceManagerSystemProperty -SystemName production -Name CurrencySign -Value "£"

Additional Information

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format- strings

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax

Copyright 2023 Alemba, ASM EOS 10.4