Video Screencast Help
Backup Exec

Get-BEMCLI

Created: 15 Jun 2012 • Updated: 28 May 2014 • 4 comments
BE_KirkFreiheit's picture
+2 2 Votes
Login to vote

Backup Exec 2012 ships with a new PowerShell module called BEMCLI.  I lead the development of BEMCLI, and am very excited about its role in making your Backup Exec tasks more automated and easier to manage.

30,000 foot view of PowerShell and BEMCLI in 30 seconds

PowerShell is an automation technology.  PowerShell contains a language.  The interface you'll start using PowerShell from is a command window, but it can also be scripted.

PowerShell commands are called "cmdlets".

Developers can write and package custom cmdlets that plug into PowerShell.  Such packages of cmdlets are called "Modules" and that's what BEMCLI is: a PowerShell module.

There are three main categories of PowerShell cmdlets:

  1. Get objects.  The topic of today's blog post.
  1. Do work -- create, change, delete objects.
  1. Filter or format output  PowerShell provides plenty of support for this area.  In later blog entries, I'll show useful examples of them.

Learning PowerShell is an investment, but it's an investment that pays.  I just got back from TechEd 2012 in Orlando, and Microsoft's commitment to the technology is unquestionable: everything in Windows Server 2012 supports PowerShell, and the audiences at every PowerShell session were very enthusiastic.

OK, maybe that's more than 30 seconds, but you get the point: PowerShell + BEMCLI is powerful glue for plugging Backup Exec into your workflows and automation.

Getting Backup Exec objects using BEMCLI

Want to get all of your Backup Exec jobs?  Try:

Get-BEJob

 

How about getting alerts?  You can probably guess:

Get-BEAlert

 

That's the whole point of PowerShell's design: conventions.  Cmdlets are named with the "Verb-Noun" pattern, and Microsoft publishes a list of approved Verbs.

BEMCLI provides the appropriate nouns, combines them with the appropriate verbs, and you have a very discoverable set of operations you can perform on the command-line or scripts.

The formula is:

[Verb]-BE[Noun]

 

So, if you want to "get" a "job" from Backup Exec, you can guess the command's name will be Get-BEJob.  The "BE" prefix on the noun name is also a Microsoft convention for module developers to follow.  Many products have "Jobs".  Backup Exec makes "BEJobs", "BEAlerts", etc.

 

Getting online help

Back to jobs for a minute...want to see only your backup jobs?  Easy:

Get-BEJob -JobType Backup

Want to know how you'd discover that "-JobType" parameter, and how to use it?

help Get-BEJob

Complete help file:

help Get-BEJob -Full

Just the examples:

help Get-BEJob -examples

 

Explore

To see a list of all the "Get-" commands in the BEMCLI module:

Get-Command -Module BEMCLI -Verb Get

Of course, you can just see all of the BEMCLI commands via:

Get-Command -Module BEMCLI

 

Each of the BEMCLI commands is documented with at least one example, usually more than one.

I look forward to hearing from everyone out there using BEMCLI to automate the monitoring and management of  their backups.  Your feedback has a direct line to features and improvements.

Next time, I'll go into the second category of cmdlets: those that 'do work'.  Stay tuned…

-Kirk out.

Comments 4 CommentsJump to latest comment

Altimate1's picture

Hi,

Could you tell where to configure followings:

(Get-Host).UI.RawUI.BackgroundColor="white"
(Get-Host).UI.RawUI.ForegroundColor="black"
(Get-Host).PrivateData.ErrorBackgroundColor="white"
(Get-Host).PrivateData.ErrorForegroundColor="Red"
 

So that is could be default setting for any new BEMCLI shell?

Also could you have a look to following question:
http://www.symantec.com/connect/forums/be2012-bemcli

Regards

Bernard

0
Login to vote
BE_KirkFreiheit's picture

Hi Altimate1,

I tried clicking on the link you provided, but it appears the author has restricted access to the thread, and I cannot see it.  Please post the question and I'll see what I can come up with!

Regarding shell configuration, PowerShell doesn't provide a mechanism to associate a profile to a specific *module* -- but you can easily create a shortcuts that launch customized PowerShell environments.

Customizing BEMCLI's shell experience

Here's what I'd do to give a custom look to my BEMCLI shells:

1. Create a file (say, C:\scripts\BEMCLI_profile.ps1) with the following:

Import-Module BEMCLI
(Get-Host).UI.RawUI.BackgroundColor="white"
(Get-Host).UI.RawUI.ForegroundColor="black"
(Get-Host).PrivateData.ErrorBackgroundColor="white"
(Get-Host).PrivateData.ErrorForegroundColor="Red"
cls

2. Make a desktop shortcut that runs the following line to launch PowerShell using only the contents of that script:

PowerShell.exe -noprofile -noexit -file "c:\scripts\BEMCLI_profile.ps1"

Notice the "-noprofile" and "-noexit" switches; you can omit "-noprofile" if you have a global profile that you want to have loaded before the contents of the BEMCLI_profile.ps1 script.

...which leads me to the next solution:

Another approach: use your global profile ($profile)

Each shell (the standard cmd.exe-style shell, and the PowerShell ISE) has its own global profile as well.  To discover where the global profile for your particular shell is, take a look at the $profile variable:

PS C:\Users\Kfreiheit> $profile
C:\Users\Kfreiheit\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

It's in your userprofile's Documents folder.  However, it's not created by default.  In fact, its containing folder isn't created, either.  Here's how I create it, edit it, and then make it 'live' in my current shell:

PS C:\Users\Kfreiheit> new-item -itemtype file $profile -force


    Directory: C:\Users\Kfreiheit\Documents\WindowsPowerShell


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         6/18/2012  10:31 AM          0 Microsoft.PowerShell_profile.ps1


PS C:\Users\Kfreiheit> notepad $profile
PS C:\Users\Kfreiheit> . $profile

The -force parameter to new-item makes it create the intermediate folders (in this case, the "WindowsPowerShell" folder).

Running "notepad $profile" does what you'd hope -- this is where I edit and save the script I want to run every time I start up a new shell.

The ". $profile" makes my current powershell session "dot-source" the new script, to make its contents run in the current scope.  That way, I don't have to exit and restart a new shell to get the benefits of my edited profile.  Every time I want to add something to my profile, I go through a similar workflow (minus the New-Item step, of course).

Now, when I launch a new PowerShell window, it has BEMCLI loaded and a while background.

Hope this helps!

-Kirk out.

-2
Login to vote
Altimate1's picture

I used the second method as I don't have makecert.exe available under the hand.

Many thanks
Regards

Bernard

0
Login to vote
Altimate1's picture

I edited the link so that it became public (it was restricted to Beta tester group!)

I will review information you gave and will probably come back later (I were busy working on new BackupExec Appliance 3600)

Thanks

Bernard

-2
Login to vote