Getting Started
Note: PowerShell 3.0 or higher is required to use this functionality.
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.
Importing the module
You'll find the PowerShell module in the SentryOne program directory (which varies depending on the installed <Version>):
C:\Program Files\SentryOne\<Version>\Intercerve.SQLSentry.Powershell.psd1
Import the SentryOne PowerShell module by using the Import-Module command.
Import-Module command example for version 19.x:
Import-Module "C:\Program Files\SentryOne\19.0\Intercerve.SQLSentry.Powershell.psd1"
Import-Module command example for version 20.x:
Import-Module "C:\Program Files\SentryOne\20.0\Intercerve.SQLSentry.Powershell.psd1"
Import-Module Example with version 2020.0
Note: When using the Enhanced Platform Installer (EPI), the module location is as follows (if the machine has both a client and monitoring service installed, the module will appear in both locations):
Monitoring Service
On a machine with the monitoring service installed:
C:\ProgramData\SentryOne\monitoringservice\bin\Intercerve.SQLSentry.Powershell.psd1
Client
On a machine with the client installed:
C:\Users\<USERNAME>\Documents\sentryone\client\<SENTRYONE_SQLSERVER_INSTANCE>\<SENTRYONE_DATABASE_NAME>\bin\Intercerve.SQLSentry.Powershell.psd1
For example:
C:\Users\mconnors\Documents\sentryone\client\QA-SRV-1\SentryOne\bin\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.
Get-Module Example showing the Intercerve.SentryOne.PowerShell
Additional Information: For more information about Get-Module commands, see Microsoft Get Module Commands.
Command Details
See the Command Examples section for more information on using available commands.
Command | Description |
---|---|
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:
|
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. Information returned:
|
Get-Connection | Allows you to view connections in your environment. Available parameters:
Information returned:
|
Get-Computer | Allows you to view computers in your environment. Available Parameters:
Information returned:
|
Get-Group | Allows you to view groups in your environment. |
Get-Site | Allows you to view sites in your environment. Note: This includes both sites and groups in the return. Available Parameters:
|
Register-Computer | Allows you to register a computer to be watched with SentryOne. Available Parameters:
|
Invoke-WatchComputer | Allows you to watch a computer with SentryOne. Available Parameters:
|
Register-Connection | Allows you to register a connection to be watched with SentryOne. Available Parameters:
|
Invoke-WatchConnection | Allows you to watch a connection with SentryOne. Available Parameters:
|
Invoke-UnwatchConnection | Allows you to stop watching a connection with SentryOne. Available Parameters:
|
Additional Information: For more information about adding servers, see the Automating adding servers to SentryOne article.
Get-Help
Use Get-Help followed by a command to get information about the available commands in the table above. For example, to learn more about Get-Connection:
Get-Help Get-Connection
Get-Help Get-Connection Example
Command Examples
Import the SentryOne PowerShell Module
<# Import the SentryOne PowerShell Module #>
Import-Module "C:\Program Files\SentryOne\2020.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"
Important: For performance considerations, when using scripts to bulk add targets, we recommend limiting the text file list to batches of 50-100 targets at a time.
Watch all targets listed in text file
<#Change this to match the name of the server housing
the SentryOne database and the name of the SentryOne database
#>Connect-SQLSentry -ServerName servername -DatabaseName SentryOne <#Change this to match the name of the text file that includes all the names of all the servers you want to watch #>
$Servers = Get-Content C:\Powershell\TestWatch.txt Foreach ($Server in $Servers) { Register-Connection -ConnectionType SqlServer -Name $Server Get-Connection -Name $Server -NamedServerConnectionType SqlServer| Invoke-WatchConnection }
Watch all targets listed in text file (Azure)
<#Specify the server housing the SentryOne database and the name of the SentryOne database #>
Connect-SQLSentry -ServerName sqlserver -DatabaseName SentryOne
<#Change this to match the Site into which you are adding the targets #>
$Site= Get-Site -Name DefaultSite
<#Change this to match the name of the text file that includes all the names of the Azure SQL Database targets you want to watch #>
$Servers = Get-Content C:\Powershell\TestWatch.txt
<#Change this to match the name of the text file that includes all the names of Azure SQL Database databases #>
$DatabaseName = Get-Content C:\Powershell\Databases.txt
<#Username: change this to match the name of the Azure SQL Database login #>
$user= "login"
<#Password: change this to match the name of the Azure SQL Database password #>
$pass= "pass"
Foreach ($Server in $Servers)
{
Register-Computer -ComputerType AzureSqlDatabase -Name $Servers -DatabaseName $DatabaseName -Login $user -Password $pass -AccessLevel Full -UseIntegratedSecurity 0 -TargetSite $Site| Invoke-WatchComputer
}