Creating A SCE 2007 PowerShell Profile

 

OpsMgr 2007 unlike its counterpart SCE 2007 comes with a PowerShell Command Shell console built in by default. However if you have PowerShell for Windows 2003 server installed on your SCE Management Server you can access the PowerShell (.Net) binaries by loading them into your PowerShell profile.

 

Located in the Program Files\System Center Essentials 2007\SDK Binaries directory are two Dll files that allow you to use PowerShell similar to using the Command Shell in OpsMgr 2007:

 

Microsoft.EnterpriseManagement.OperationsManager.Common.dll

Microsoft.EnterpriseManagement.OperationsManager.dll

 

Add the following to your PowerShell profile to create a SCE 2007 PowerShell environment:

 

Note: If you have not yet created your profile from the PowerShell command window enter the following to create your personal profile: New-Item -Path $Profile -ItemType File –F then set the Execution policy by running the following: Set-ExecutionPolicy RemoteSigned. Finally copy and paste the following to your profile by running the following: Notepad $Profile to add the content below to your Microsoft.PowerShell_profile.Ps1

 

SCE 2007 PowerShell Profile

 

# Loads The Assembly File

Write-Host "Loading The Assembly Binaries...Please Wait...." -Fore Cyan

[System.Reflection.Assembly]::LoadFile("C:\Program Files\System Center Essentials 2007\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.Common.dll") 

$Null

[System.Reflection.Assembly]::LoadFile("C:\Program Files\System Center Essentials 2007\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.dll")

$Null

 

# Management Group Connection String

$SCE = [Microsoft.EnterpriseManagement.ManagementGroup]::Connect("LocalHost")

Clear

 

# Creates The Command Prompt

function Prompt

{Write-Host ("SCE:") $SCE.Name -NoNewLine

return " "}

 

To test your profile run the following: $SCE

 

 

 

Published Sunday, January 27, 2008 12:57 PM by dhite
Filed under:

Comments

# Add a PowerShell Command Shell console to Essentials 2007

Don Hite has a method for adding a PowerShell Command Shell console to an Essentials 2007 installation

Tuesday, January 29, 2008 12:10 PM by The Real World Is Messy