SentryOne PowerShell Module

The SentryOne installation package includes a PowerShell module that can be used to manage your SentryOne environment through PowerShell. This topic includes a walkthrough of that functionality.

Important:  PowerShell 3.0 or higher is required to use this functionality.

Getting Started

Import the SentryOne PowerShell module. You'll find the module in the SentryOne program directory. Use the Import-Module command as follows: 

Import-Module "C:\Program Files\SentryOne\18.0\Intercerve.SQLSentry.Powershell.psd1"

Verify that the module imported correctly by running the Get-Module command. You should see a listing for Intercerve.SentryOne.Powershell

Additional Information: For more information about Get-Module commands, see Microsoft Get Module Commands.

Commands

Various commands are available for PowerShell. For more information about the commands, see the following table: 

CommandDescription
Connect-SQLSentry

Allows you to connect to a specific SentryOne installation that's required before any other actions are performed. This command is useful for navigating between repositories, and is used in environments with more than one SentryOne database.

Available parameters:

  • Database
  • NameLogin
  • Password
  • ServerName
  • UseIntegratedSecurity
Disconnect-SQLSentry

Allows you to disconnect from a specific SentryOne installation. Useful for environments with more than one SentryOne database.

Get-SQLSentryConfiguration

Allows you to view basic information about your SentryOne configuration.

Get-Connection

Allows you to view connections in your environment.

Available parameters:

  • ConnectionType
  • ID
  • Name
  • ObjectID
Get-Computer

Allows you to view computers in your environment.

Available Parameters:

  • ComputerType
  • ID
  • Name
Get-Site

Allows you to view sites in your environment. Note:  This includes both Sites and Groups in the return.

Available Parameters:

  • ID
  • Name
Register-Computer

Allows you to register a computer with SentryOne. 

Important:  Register a computer to be watched with SentryOne.

Available Parameters:

  • ComputerType
  • Name
  • AccessLevel
  • DatabaseName
  • Login
  • Password
  • Port
  • TargetSite
  • UseIntegratedSecurity
  • AllowAzureRemoteObjectInstallation
Important:  AllowAzureRemoteObjectInstallation is only valid for Azure SQL Database targets.
Invoke-WatchComputer

Allows you to watch a computer with SentryOne. 

Available Parameters:

  • Computer
  • LicenseMode
Register-Connection

Allows you to register a connection with SentryOne. 

Important:  To be watched with SentryOne, register a connection.

Available Parameters:

  • ConnectionType
  • Name
  • Login
  • Password
  • Port
  • TargetSite
  • UseIntegratedSecurity
Invoke-WatchConnection

Allows you to watch a connection with SentryOne.

Available Parameters:

  • Connection
Invoke-UnwatchConnection

Allows you to stop watching a connection with SentryOne.

Available Parameters:

  • Connection


Additional Information: For more information about adding servers, see the Automating adding servers to SentryOne article.

Examples

Import the SentryOne PowerShell Module

<# Import the SentryOne PowerShell Module #>
Import-Module "C:\Program Files\SentryOne\18.0\Intercerve.SQLSentry.Powershell.psd1"

Connect to SentryOne Installation

<# Connect to a specific SentryOne Installation #>
Connect-SQLSentry -ServerName server.domain.com -DatabaseName SentryOne

Get SentryOne Installation Information

<# Get Information about your SentryOne Installation #>
Get-SQLSentryConfiguration 

Get SentryOne Information for Sites

<# Get Information about the Sites in your SentryOne Installation -use parameters to find information for a specific site #>
Get-Site 

Get SentryOne Information for Instances

<# Get Information about the Connections (Instances) in your SentryOne Installation -use parameters to find information for a specific connection #>
Get-Connection 

Get SentryOne Information for Targets

<# Get Information about the Computers (Targets) in your SentryOne Installation -use parameters to find information for a specific connection #>
Get-Computer 

Get SentryOne Information for Specific Target

<# Get Information about the Connections in your SentryOne Installation -use parameters to find information for a specific connection #>
Get-Connection 

Register a Target

<# Register Computers (Targets), so that they can be watched in your environment #>
Register-Computer -ComputerType Windows -Name server.domain.com -AccessLevel Full Register-Computer -ComputerType Windows - Name server.domain.com -AccessLevel Limited 

Register a Target (non Windows)

<# Register a Target that cannot utilize Windows Authentication (e.g., Azure SQL Database) #>
Register-Computer -ComputerType AzureSqlDatabase -Name example.database.windows.net -DatabaseName dbName -Login username -Password password -AccessLevel Full -UseIntegratedSecurity 0 

Register Instances

<# Register Connections (Instances), so that they can be watched in your environment #>
Register-Connection -ConnectionType SqlServerAnalysisServices -Name server.domain.com Register-Connection -ConnectionType SqlServer -Name server.domain.com 

Watch a Windows Target

<# Watch Windows Computer (Target) with Performance Analysis and Event Calendar | -Pipe in the Computer #>
Get-Computer -Name server.domain.com -NamedServerComputerType Windows | Invoke-WatchComputer 

Watch a Hyper-V Host Target

<# Watch Hyper-V Host (Target) with Performance Analysis and Event Calendar (core-based licensing) | -Pipe in the Computer #>
Get-Computer -Name server.domain.com -NamedServerComputerType Windows | Invoke-WatchComputer -LicenseMode CoreBased 

Watch a SQL Server Target

<# Watch SQLServer Connection (Instance) with Performance Analysis and Event Calendar | -Pipe in the Connection #>
Get-Connection -Name server.domain.com -NamedServerConnectionType SqlServer | Invoke-WatchConnection 

Watch a SSAS Target

<# Watch SSAS Connection (Instance) with Performance Analysis and Event Calendar | -Pipe in the Connection #>
Get-Connection -Name server.domain.com -NamedServerConnectionType SqlServerAnalysisServices | Invoke-WatchConnection 

Unwatch Target

<# Unwatch Windows computer (Target) #>
Get-Computer -Name server.domain.com -NamedServerComputerType Windows | Invoke-UnwatchComputer

Unwatch SSAS Connection

<# Unwatch SSAS connection #>
Get-Connection -Name server.domain.com -NamedServerConnectionType SqlServerAnalysisServices | Invoke-UnwatchConnection

Unwatch SQL Server Connection

<# Unwatch SQLServer connection #>
Get-Connection -Name server.domain.com -NamedServerConnectionType SqlServer| Invoke-UnwatchConnection

User cmdlets

<# User cmdlets #>
 Register-User -FirstName Test -LastName user -Email tuser@test.net -PagerAddress tuser@testPager.net -Description Tester -Login domain\username Get-User -FirstName Test Get-User -Name "Test User" Disable-User -Name "Test User" Enable-User -Name "Test User" Unregister-User -Name "Test User"

Group cmdlets

<# Group cmdlets #>
Register-Group -Name "Test Group" -Description "A Group" -Login Domain\TestGroup Get-Group -Name "Test Group" Disable-Group -Name "Test Group" Enable-Group -Name "Test Group" Unregister-Group -Name "Test Group"

User and Group cmdlets

 <# User = and - to the Group cmdlets #>
Get-User -Name "Test User" | Add-GroupUser -GroupName "Test Group" Get-User -Name "Test User" | Remove-GroupUser -GroupName "Test Group"