Example 2: Script containing New-TpmsObjSetupAgent
Description
Defines a target machine (on which Tpms.Agent is installed) to retrieve its certificate.
Syntax
New-TpmsObjSetupAgent -Name <string> -Port <uint16> [-Action <Action> {Register | Unregister}] [-Credential <pscredential>]
Parameter | Description |
-Name | Tpms.Agent address, examples: "cps47.ourdomain.local" or cps47.ourdomain.local "192.168.149.114" or 192.168.149.114 |
-Port | TCP port to connect to a Tpms.Agent (default: 5050) |
-Action | Register | Unregister (default: Register) |
-Credential | sends the credentials (stored to a variable) to the target machine; only necessary if Tpms.Agent doesn’t run on the same machine as Tpms.Service |
Example 1: cmdlet usage
The following example stores the data to access the target computer (where Tpms.Agent is installed) to $srv2. Here, -Credential requires entering the admin password to be able to connect to a remote Tpms.Agent.
$srv2 = New-TpmsObjSetupAgent ' -Name "cps47.ourdomain.local" ' -Port 5050 ' -Credential (Get-Credential -Message "Please enter your credentials." -UserName "ourdomain\Administrator")
Example 2: Script containing New-TpmsObjSetupAgent
The following script can be run on an admin computer to initiate the Tpms environment. The script must run only once per session. It imports the module Tpms.Powershell, sets the URL of Tpms.Service and sets the log level to Info, defines a target server ($srv2) running Tpms.Agent (cps47.ourdomain.local) and – finally – sends the relevant calls to the target machine with Start-TpmsSetupByAgent -Servers ($srv2).
Set-TpmsServiceUrl -Uri https://licenseserver.ourdomain.local:4040 Set-TpmsLogLevel -RelayLogLevel Info $srv2 = New-TpmsObjSetupAgent -Name "cps47.ourdomain.local" -Port 5050 -Credential (Get-Credential -Message "Please enter your credentials." -UserName "ourdomain\Administrator") Start-TpmsSetupByAgent -Servers ($srv2)