Skip to content

Store Credentials

lordmilko edited this page Apr 27, 2019 · 14 revisions

Contents

Overview

To facilitate connecting to and switching between PRTG Servers within PowerShell, PrtgAPI can store your connection details in your PowerShell profile and use them to automatically connect to your PRTG Server.

PrtgAPI stores your server address and username in plain text, however encrypts your passhash SecureString, preventing the value from being decrypted outside of the user account and computer under which it was created.

It is not recommended to store credentials anywhere other than your work PC. For scripting purposes it is recommended to use Get-Credential or New-Credential to retrieve your login details.

If your password changes this may cause your PRTG PassHash to change also. Your GoPrtg credential can be updated via the Update-GoPrtgCredential cmdlet (see below)

Installation

To register a connection in your PowerShell profile, once connected to your server run Install-GoPrtgServer

Install-GoPrtgServer

If you have multiple PRTG Servers in your environment, you can define an optional alias to refer to your connection

Install-GoPrtgServer dev

Connection

To connect to your server, run Connect-GoPrtgServer (alias: GoPrtg)

goprtg

If you do not specify an argument to GoPrtg, GoPrtg will automatically connect to the first server listed in your profile. To connect to a specific server, specify a server name, alias or wildcard that matches part of the server name.

goprtg dev
goprtg prtgdev*
goprtg prtgdev.example.com

Modification

To update the alias of a GoPrtg server, first connect to the server then run Set-GoPrtgAlias, specifying the new alias you wish to set for the connection.

Set-GoPrtgAlias work

If your PRTG user's password changes this may cause your PRTG PassHash to change also. The passhash stored in your GoPrtg credential can be updated via the Update-GoPrtgCredential cmdlet

Update-GoPrtgCredential

Update-GoPrtgCredential operates on the currently active GoPrtg credential, with the implication being that after connecting with GoPrtg, PrtgAPI's cmdlets are complaining you are not properly authenticated.

Update-GoPrtgCredential will automatically populate the username of the currently active credential. a PSCredential can alternatively be passed to Update-GoPrtgCredential to update the stored credential without prompting for the password.

Update-GoPrtgCredential (New-Credential username password)

The username of the active credential can be modified, however you cannot specify a username that is already associated with another GoPrtg record for the currently active server.

After entering your new credential Update-GoPrtgCredential will automatically attempt to connect using your new credentials, eliminating the need to manually reconnect after your credentials have been updated.

Uninstallation

To uninstall a GoPrtg server, run

Uninstall-GoPrtgServer

If you have more than one server registered, you will need to specify a server name, alias or wildcard matching one or more server names. When the last server is removed, PrtgAPI will remove all traces of GoPrtg's infrastructure from your PowerShell profile. To remove all GoPrtg functions at once, you can run Uninstall-GoPrtgServer specifying the -Force parameter

Uninstall-GoPrtgServer dev
Uninstall-GoPrtgServer -Force

Enumeration

To view a list of GoPrtg servers registered in your profile, use the Get-GoPrtgServer cmdlet.

C:\> Get-GoPrtgServer

[!] Server                      Alias  UserName
--- ------                      -----  --------
[*] prtg.example.com                   prtgadmin
[ ] http://ci-prtg-1            ci     prtgadmin
[ ] http://prtgdev.example.com  dev    prtgadmin

The currently active server is highlighted with an asterisk *. To view a specific subset of servers, you may also optionally specify a server name, alias or wildcard matching a server name

Get-GoPrtgServer *example.com
Clone this wiki locally