DPM CLI Tips 'n Tricks: Powershell Basics - Part II
Published Feb 14 2019 08:28 PM 640 Views
First published on TECHNET on Jun 30, 2008

Tab Completion





The most fascinating part of DPM Management Shell is Tab Completion of cmdlets. By learning the common verbs in Powershell (like Get, Set, Start etc.), a Windows or an Exchange admin can easily use that knowledge and learn the DPM cmdlets. This is because the same verbs are used in DPM Management Shell too.





For example: To get the list of protected servers backed-up by a DPM server, one needs to just type Get-P and keep pressing tab. This would result in Powershell suggesting the various cmdlets, and you can choose the right one needed. The ones that you would see in this example are - Get-Process, Get-ProductionCluster, Get-ProductionServer etc.





In addition, if you can also tab complete the various parameter names too in the same way, by typing a “-“ after the cmdlet name and pressing tab.







Examples of cmdlet usage(Get-Help <cmdlet> -example)





Getting directly to the example usage of a cmdlet can be done easily with optional parameters in Get-Help - Get-help <cmdletname> -example. This will directly print only the example usages of the cmdlet:





For example:





PS D:\> Get-help Get-ProtectionGroup -example





NAME



Get-ProtectionGroup





SYNOPSIS



Retrieves the list of protection groups on the DPM server.





EXAMPLE 1



Get-ProtectionGroup -DPMServerName TestingServer





This command returns the protection group on a DPM server.





Getting only the cmdlet syntax (Get-Command <cmdlet> -syntax)



Another quick help about the syntax of cmdlet would be get by typing





PS D:\> Get-Command Get-Datasource -syntax





Get-Datasource [-DPMServerName] <String> [-Inactive] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]





Get-Datasource [-ProductionServer] <ProductionServer> [-Async] [-Inquire] [-Replica] [-Tag <Object>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]





Get-Datasource [-ProtectionGroup] <ProtectionGroup> [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]





Get-Datasource [-DPMServerName] <String> [-SearchPath] <String> [[-ProductionServerName] <String>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]







Using the object member properties (Get-Member)



With the help of get-member you can verify/set the property of the object.





PS D:\> $pg = Get-ProtectionGroup “MyDPMServerName”



PS D:\> $pg | get-member





TypeName: Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup





Name                                  MemberType    Definition



----                                    ----------       ----------



AddProtectableObject             Method           System.Void AddProtecta...



AddProtectionOptions             Method           System.Void AddProtecti...



.



.



FriendlyName                        Property           System.String FriendlyN...



InitializationType                   Property           Microsoft.Internal.Ente...





Now these properties can be used to filter and get a specific PG.





For Example:





$clipg = Get-ProtectionGroup $dpmname | where { $_.FriendlyName -eq $pgname }







CLI Help Updates and Errata



Any additional help information or errata gets updated per cmdlet and is available at http://go.microsoft.com/fwlink/?LinkId=95130 .





- Mukul Shekhawat , Balaji Hariharan

Version history
Last update:
‎Mar 11 2019 08:04 AM
Updated by: