Add Exchange to PowerShell ISE

Welcome Forums General PowerShell Q&A Add Exchange to PowerShell ISE

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #6508

    Points: 0
    Rank: Member

    by ewkilian at 2013-01-30 02:23:50

    I'm French, my english is very Bad sorry.

    To administre my Exchange with Powershell, I want add Exchange to Powershell ISE.
    I try to add a subMenu to Powershell ISE as the site explains :

    I execute the script :

    "Connexion vers Exchange", {
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
    . $env:C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1
    Connect-ExchangeServer –auto

    Result the error ( sorry french error ) :

    Vous ne pouvez pas appeler de méthode sur une expression ayant la valeur Null.
    Au niveau de C:\connecteur_Exchange_PS_ISE.ps1 : 1 Caractère : 52
    + $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add < <<< (
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    I thinks that the problem become from the code :
    . $env

    I don't know.
    I thank you in advance for your help

    by DonJ at 2013-02-01 14:28:53

    I'm sorry, I don't know enough French to understand what the error is telling you. It seems to say you're passing a Null value to a method.

    The ". $env" is "dot-sourcing" a script. That is, it is running a script without creating a scope around it. The script path follows – and I think that may be your problem. $env represents PowerShell's environment variable drive, but you're giving it a full path and filename. Have you tried just removing the $env?

    In the post you reference, the authored used $env:ExchangeInstallPath\bin\RemoteExchange.ps1. That's because he's referring to the ExchangeInstallPath environment variable. You're not referring to an environment variable, you're giving it a complete path that starts with C:\. So the $env seems superfluous.

    by AsifSaif at 2013-02-10 10:53:44

    As DonJ said, either change the path remove $env, or if its just loading exchange snapin, i have simplified it like this one liner,

    $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("Connect to Exchange", {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010}, "Control+Alt+E")

    Asif Saif

The topic ‘Add Exchange to PowerShell ISE’ is closed to new replies.