lørdag 26. oktober 2013

DPM: Free tape treshold reached (3305)

If you monitor your Data Protection Manager server with Operations Manager, you may see an alert i OpsMgr looking something like this:
The number of free tapes in the Tape Library IBM TotalStorage 3573 Tape Library is less than or equals the threshold value of 2. You must add tape to the library and mark it as free in order to prevent future backups from failing. (ID: 3305)
Expired tapes that are being managed by that DPM server can be reused automatically without being marked as free by the administrator. However, this alert do not take in to account the expired tapes, so you may see this alert even if the total available (free and expired) tapes are higher than the threshold value.

This is not a threshold that OpsMgr controls, it's a threshold stored within the DPM database. Currently DPM do not have any way to change this threshold. Although unsupported, you can use SQL Server Management Studio to alter the threshold value, like this:

Select the DPM database within SQL Server Management Studio and then create a New Query, type in and execute this update query (this is valid for DPM 2012):
UPDATE [dbo].[tbl_MM_MediaPool]
   SET [MinThresholdForFreePool] = 1
 WHERE ([Name] = 'Free Media Pool')

For a detailed explanation on how to mark a tape as free, look at this TechNet topic.

PowerShell: List processes currently using the most CPU

If you find yourself supporting users on Remote Desktop Session Host servers, you may want to use PowerShell to identify processes with high CPU utilization and also kill such processes if they cause problem for other users.

I have created a small PowerShell script that will help with this task. Save the script on your Session Host servers, and use PowerShell from your Workstation to invoke it.

You have to enable PowerShell Remoting on your Session Host servers to allow it, like this:
Enable-PSRemoting -Force

You should also allow unsigned scripts to be executed, like this:
Set-ExecutionPolicy RemoteSigned

If your Workstation is not in the same domain, you must tell your Workstation to trust the Remote host, like this:
Set-Item wsman:\localhost\client\trustedhosts *

This will trust all Remote hosts, but you can also specify hosts with a comma-separated list of hostnames.

To run the command on the session host, you can enter a remote PowerShell session, where you can run multiple commands, like this:
Enter-PSSession -ComputerName

To exit a Remote PowerShell session you simply type exit.

You can also use Invoke-Command, instead of Enter-PSSession, if you only need to run one command.

Now then, if you save the script as D:\Scripts\PSGetTop.ps1 on a server called, you would start PowerShell on your Workstation, and type (this will use your current credentials, so you would need to have permission, like local administrator, on that server to do this):
Enter-PSSession -ComputerName
CD D:\Scripts
# List top 5 processes with highest CPU utilization:

# List top 10 processes with highest CPU utilization:
.\PSGetTop.ps1 -ReturnCount 10

# List the WINWORD process with highest CPU utilization:
.\PSGetTop.ps1 -ProcessName WINWORD -ReturnCount 1

# List top 5 iexplore processes With highest CPU utilization, show result in a gridview:
.\PSGetTop.ps1 -ProcessName iexplore -ReturnCount 5 -GridView

# To kill a process with Process Id 1111, you can type:
(Get-Process -Id 1111).Kill()

# To get a list of all uniqe programs that run processes, try this:
Get-Process | Group-Object Name | select Count,Name | ft -AutoSize

Script PSGetTop.ps1:
Param([string]$ProcessName, [int]$SelectFirst, [switch]$GridView)

If (! $ProcessName) { $ProcessName = '*' }
If (! $SelectFirst) { $SelectFirst = 5 }

If ($ProcessName -eq '*') {
  $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process | select IDProcess,Name,PercentProcessorTime | where { $_.Name -ne "_Total" -and $_.Name -ne "Idle"} | sort PercentProcessorTime -Descending | select -First $SelectFirst
Else {
  $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process | where {$_.Name -eq $ProcessName} | select IDProcess,Name,PercentProcessorTime | sort PercentProcessorTime -Descending | select -First $SelectFirst
$TopProcess = @()
ForEach ($Process in $ProcessList) {
  $row = new-object PSObject -Property @{
    Id = $Process.IDProcess
    Name = $Process.Name
    User = (gwmi Win32_Process | where {$_.ProcessId -eq $Process.IDProcess}).GetOwner().User
    CPU = $Process.PercentProcessorTime
    Description = (Get-Process -Id $Process.IDProcess).Description
  $TopProcess += $row

If ($GridView) {
  $TopProcess | sort CPU -Descending | select Id,Name,User,CPU,Description | Out-GridView
Else {
  $TopProcess | sort CPU -Descending | select Id,Name,User,CPU,Description | ft -AutoSize

torsdag 24. oktober 2013

OpsMgr 2012: Agents not showing up in Pending Management

If you add an agent, and it is not showing up in Pending Management in the console of Operations Manager, you can try to:
  1. Check the setting under Administration > Settings > Type: Server > Security > Select Review new manual agent installations in pending management view
  2. Restart the System Center Management Health service on the agent.
  3. When installing CU updates to Operations Manager servers, make sure the user has SA rights to the OperationsManager SQL database in addition to Administrator rights to the servers.
  4. Try to use PowerShell to approve pending agent, like this:
Approve them all:
Get-SCOMPendingManagement | Approve-SCOMPendingManagement

Approve specific agent:
Get-SCOMPendingManagement | where {$_.AgentName -eq "ServernameFQDN"} | Approve-SCOMPendingManagement