Connect-TP

397 views 1

Description

Establishes the required connection to the license server. Providing credentials is required.

Syntax

Connect-TP -TPUrl <String> [-PSCredential <PSCredential>]

 

Parameter Description
-TPUrl URL of the ThinPrint license server
-PSCredential optional: credentials of an account that is a member of the local ThinPrint Config­uration Admins group on the license server, such as the account that installed the software

 

Example 1

If only the parameter -TPUrl is used but not the -PSCredential parameter, the login information is queried with a pop-up window. Variable values are indi­cated in orange.

Connect-TP -TPUrl http://localhost:4004

manual entry of license server logon information

manual entry of license server logon information

successfully connected to the license server

successfully connected to the license server

Example 2

If the parameter -PSCredential is only used to pass the account name, the password is still queried with a pop-up window.

Connect-TP -TPUrl http://localhost:4004 -PSCredential (Get-Credential -Message "Please enter your credentials." -UserName "ourdomain\licservice")

manual password entry

manual password entry

connection with the license server successfully established including transfer of the account name

connection with the license server successfully established including transfer of the account name

Example 3

The -PSCredential parameter is used to pass both user name and password. How­ever, the password appears in the plain text (“12345678”).

$username = "ourdomain\licservice"
$password = ConvertTo-SecureString "12345678" -AsPlain­Text -Force
$credentials = New-Object System.Management.Automa­tion.PSCredential ($username,$password)
Connect-TP -TPUrl http://localhost:4004 -PSCredential $credentials

connection with the license server with the transfer of the complete creden­tials successfully established

connection with the license server with the transfer of the complete creden­tials successfully established

Example 4

The first script EncryptPW.ps1 only needs to be executed once. It queries the pass­word and stores it encrypted in c:\scripts\template.ps1.
The second script template.ps1 then logs in to the license server using the encrypted password. This script can then be used for any login to the license server without having to enter a password. Here, the license server address is http://local­host:4004.

  • Contents of the EncryptPW.ps1 script for querying the password and generating the script template.ps1 (variable values are shown in orange):
# Path to the script to be created:
$path = 'c:\scripts\template.ps1'

# Create empty template script:
New-Item -ItemType File $path -Force -ErrorAction SilentlyContinue

$user = Read-Host 'Enter Username'
$pwd = Read-Host 'Enter Password' -AsSecureString
$key = 1..32 | ForEach-Object { Get-Random -Maximum 256 }
$pwdencrypted = $pwd | ConvertFrom-SecureString -Key $key

$private:ofs = ' '
('$password = "{0}"' -f $pwdencrypted) | Out-File $path
('$key = "{0}"' -f "$key") | Out-File $path -Append

'$passwordSecure = ConvertTo-SecureString -String $password -Key ([Byte[]]$key.Split(" "))' | Out-File $path -Append
('$cred = New-Object system.Management.Automa­tion.PSCredential("{0}", $passwordSecure)' -f $user) | Out-File $path -Append
'$cred' | Out-File $path -Append
'Import-Module TPPowershell' | Out-File $path -Append
'Connect-TP http://localhost:4004 -PSCredential $cred' | Out-File $path -Append
connection to the license server successfully established by running the two scripts EncryptPW.ps1 and template.ps1

connection to the license server successfully established by running the two scripts EncryptPW.ps1 and template.ps1

Previous Page
Next Page

Was this helpful?