Powershell SDK

Easy Tune Enterprise has a Powershell SDK which makes it possible to automate common tuning activity via Powershell.

What can you do?

ActionPowerShell Cmdlet(s)

Create Tuning Packs from Management Packs

New-TuningPack -ManagementGroup $MG -ManagementPacks $MPs -Author "Team Cookdown" -TuningPackDescription "Tuning Pack for my 5 SQL MPs" -TuningPackName "Cookdown Example SQL TP" -ExportPath "c:\temp"

Set tuning at a global/group/object level

New-GlobalTuning -ManagementGroup $MG -TuningPack $SQL_TP -OverrideLevel "DiscoveryOnly" 
New-GroupTuning -ManagementGroup $MG -TuningPack $SQL_TP -OverrideLevel "Essentials" -Group $GroupToTune
New-MonitoringObjectTuning -ManagementGroup $MG -TuningPack $SQL_TP -OverrideLevel "Essentials" -MonitoringObject $ObjectToTune

Remove tuning (that was set via Easy Tune) at a global/group/object level

Remove-Tuning -ManagementGroup $MG -AppliedTuning $TuningToRemove

Capture effective tuning from group/object to a Tuning Pack

Export-GroupTuning -ManagementGroup $MG -Group $GroupToCapureEffectiveTuningFrom -TuningPackName "My Groups Effective tuning" -Author "Team Cookdown" -TuningPackDescription "The tuning captured from group 1" 
Export-MonitoringObjectTuning -ManagementGroup $MG -MonitoringObject $ObjectToCapureEffectiveTuningFrom -TuningPackName "My Object's Effective tuning" -Author "Team Cookdown" -TuningPackDescription "The tuning captured from SCOM Object 1" 

Capture possible tuning from a class to a Tuning Pack

Export-AvailableClassTuning -ManagementGroup $MG -Class $ClassToCaptureAvailableTuningFrom -Author "Team Cookdown" -TuningPackDescription "Workflows targeting the selected class that can be tuned" -TuningPackName "Class A Available Tuning" 
See config drift 
Measure-ConfigurationDrift -ManagementGroup $MG -TuningPack $SQL_TP

Get Tuning Packs

Get-TuningPacks -ManagementGroup $MG

Copy tuning pack form community store to the local store

Copy-TuningPack -ManagementGroup $MG -CommunityTuningPack $CommunityTPToCopyToLocalStore

View/set the local store location

Get-LocalStore -ManagementGroup $MG
Set-LocalStore -ManagementGroup $MG -LocalStorePath "C:\Tuning Packs"

If there is additional functionality you would like exposed via Powershell please let us know by raising a helpdesk feature request

Using the PowerShell SDK

The below script covers practical use cases for most of the cmdlets that make up the Easy Tune PRO Powershell SDK. The SDK is shipped with other practical example scripts covering them in more detail.

#Load the PowerShell SDK
Import-Module .\Cookdown.EasyTune.PSModules.psd1

#If working remote you'll need to use the -ManagementGroup parameter on every cmdlet
#Working on a machine that has a console connected doesn't require this

# You'll need to have the local store set though the UI or the below cmdlets to get the most of the product
Set-LocalStore -LocalStorePath "C:\temp\overrideTS"


## By Management Pack
$ManagementPacksToTune =  (Get-SCOMManagementPack | ? {$_.Sealed -eq $true}) | Select -First 5
New-TuningPack -ManagementPacks $ManagementPacksToTune -TuningPackName "My Sample TP" -TuningPackDescription "Some Description" -Author "ME!"

## Extract the available class options
$WindowsComputerClass = Get-SCOMClass -Name 'Microsoft.Windows.Server.Computer'
Export-AvailableClassTuning -Class $WindowsComputerClass -TuningPackName "Class Examples" -TuningPackDescription "This is what you can do with windows" -Author "A windows admin"

## Extracted from a Group, All windows computers for example
$AWCGroup = Get-SCOMGroup | ? {$_.DisplayName -eq "All Windows Computers"}
Export-GroupTuning -Group $AWCGroup -TuningPackName "My windows group extraction" -TuningPackDescription "Got these from a group!" -Author "Still Me!"

## Extracting from an instance, the first windows server we find
$MyWinServer = Get-ScomClassInstance -Class ( Get-SCOMClass -Name 'Microsoft.Windows.Server.Computer') | Select -First 1
Export-MonitoringObjectTuning -Instance $MyWinServer -TuningPackName "My Server extraction" -TuningPackDescription "Got these from a $($MyWinServer.Name)" -Author "Author is Optional!"


# Get all the packs to work with, and take a look at them
$AllTuningPacks = Get-TuningPacks

# Lets use System Center Core for these examples
$SSC_TP = $AllTuningPacks | ? {$_.TuningPackName -eq "System Center Core Monitoring"}

# Take a look at the properties
$SSC_TP | fl

# From the object you can use these

# You can also use the Cmdlet to pass it in.  All tuning is only available at the object level.
Get-GlobalTuning -TuningPack $SSC_TP
Get-GroupTuning -TuningPack $SSC_TP
Get-MonitoringObjectTuning -TuningPack $SSC_TP

## Applying tuning
# Lets globally set the System Center Core to discovery only.
New-GlobalTuning -TuningPack $SSC_TP -OverrideLevel "DiscoveryOnly"

# Next we'll apply the apajove instance to the All Windows Computer Group
$AWCGroup = Get-SCOMGroup | ? {$_.DisplayName -eq "All Windows Computers"}
New-GroupTuning -TuningPack $SSC_TP -Group $AWCGroup -OverrideLevel "Apajove"

# Lets refresh our tuning packs and we should be able to see, and remove the tuning we applied
$SSC_TP = Get-TuningPacks | ? {$_.TuningPackName -eq "System Center Core Monitoring"}

#look at the group tuning using the examples above, you should see a single 'Applied Tuning' object returned.  
#If you have more than one 'AppliedTuning' object you'll need to operate on the individually
$SSC_AppliedTuning = Get-GroupTuning -TuningPack $SSC_TP 

# or 
Remove-Tuning -AppliedTuning $SSC_AppliedTuning

# The same can be done with global or instance level or instance.  In the global case you will never get more than one 'AppliedTuning' object
$SSC_AppliedTuning = Get-GlobalTuning -TuningPack $SSC_TP 

## Checking on the status of tuning (don't forget to update you runing packs if you're looking at changes you just made)
Measure-ConfigurationDrift -TuningPack $SSC_TP