Preparing your Powershell environment to run BEMCLI and scripts
One of the changes that BE 2012 has brought about is the change in the BE commandline interface from BEMCMD to BEMCLI. BEMCLI is based on Powershell which is a more powerful scripting language than ...
I posted the following to the Backup Exec blog (Get-BEMCLI entry) about this topic:
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:
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:
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:
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.
I posted the following to the Backup Exec blog (Get-BEMCLI entry) about this topic:
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:
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:
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:
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.