locked
Operations Manager PowerShell AutoComplete workaround fix - question RRS feed

  • Question

  • Hey,

    I have a question about the OpsMgr PowerShell AutoComplete workaround fix.
    $tabExpand = (get-item function:\tabexpansion).Definition
    if($tabExpand -match 'try {Resolve-Path.{49}(?=;)')
    {
       $tabExpand = $tabExpand.Replace($matches[0], "if((get-location).Provider.Name -ne 'OperationsManagerMonitoring'){ $($matches[0]) }" )
       invoke-expression "function TabExpansion{$tabExpand}"
    }


    Can this also somehow be put in Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1 file somehow? i tried it and it did not work, what am i doing wrong?

    Also could you please tell me if the problem will be fixed ? and maybe why this only happends on some machines ...

    Thanks a lot :)
    Thursday, January 28, 2010 12:04 PM

Answers

  • Good question.  I tried this out and sure enough if you just paste that into ClientShell.Startup.ps1 it does not work.  This is because that script is run when the console starts up, but then any functions or variables defined within it fall out of scope and are reverted to their prior value.  There is a quick fix that will force the global TabExpansion function to be modified. You can just paste this into ClientShell.Startup.ps1 and it will now work:

    $tabExpand = (get-item function:\tabexpansion).Definition
    if($tabExpand -match 'try {Resolve-Path.{49}(?=;)')
    {
       $tabExpand = $tabExpand.Replace($matches[0], "if((get-location).Provider.Name -ne 'OperationsManagerMonitoring'){ $($matches[0]) }" )
       invoke-expression "function global:TabExpansion{$tabExpand}"
    }

    Note that this is not an ideal solution for everyone since ClientShell.Startup.ps1 is digitally signed, and putting new code into it breaks the signature match.  If you are running under high security Powershell settings, it will not let you run a signed script which has been modified.

    Regarding your other question, I don't have an answer for you.  We are looking at various major and minor changes to the shell, but aren't ready to give any details.  The delay will be bad on any machine that works slower with the Ops Mgr SDK.  That can be due to slower network connection to the DB and/or RMS, or because of slower hardware on the local machine.

    Thanks,
    -Lincoln

    Thursday, January 28, 2010 3:58 PM

All replies

  • Hi,

    The reason that you can't edit the
    Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1
    file is that it's digitally signed by Microsoft. Once you edit the
    file, the signature will not be valid.

    I think it is possible to add to the script to the 'all users' profile:

    %windir%\system32\WindowsPowerShell\v1.0\profile.ps1

    See this page for details:
    http://msdn.microsoft.com/en-us/library/bb613488%28VS.85%29.aspx

    Matt

    Matt White
    ( http://systemcenterblog.hardac.co.uk/ )
    Thursday, January 28, 2010 3:52 PM
  • Good question.  I tried this out and sure enough if you just paste that into ClientShell.Startup.ps1 it does not work.  This is because that script is run when the console starts up, but then any functions or variables defined within it fall out of scope and are reverted to their prior value.  There is a quick fix that will force the global TabExpansion function to be modified. You can just paste this into ClientShell.Startup.ps1 and it will now work:

    $tabExpand = (get-item function:\tabexpansion).Definition
    if($tabExpand -match 'try {Resolve-Path.{49}(?=;)')
    {
       $tabExpand = $tabExpand.Replace($matches[0], "if((get-location).Provider.Name -ne 'OperationsManagerMonitoring'){ $($matches[0]) }" )
       invoke-expression "function global:TabExpansion{$tabExpand}"
    }

    Note that this is not an ideal solution for everyone since ClientShell.Startup.ps1 is digitally signed, and putting new code into it breaks the signature match.  If you are running under high security Powershell settings, it will not let you run a signed script which has been modified.

    Regarding your other question, I don't have an answer for you.  We are looking at various major and minor changes to the shell, but aren't ready to give any details.  The delay will be bad on any machine that works slower with the Ops Mgr SDK.  That can be due to slower network connection to the DB and/or RMS, or because of slower hardware on the local machine.

    Thanks,
    -Lincoln

    Thursday, January 28, 2010 3:58 PM
  • I was thinking that maybe some logic could be added into the global $profile.  One might be able to add enough logic to figure out if it is OpsMgr Shell that is being opened, and make the appropriate changes...
    Friday, January 29, 2010 4:26 PM