Solved

Enable-Mailbox Not Recognised

Posted on 2010-09-17
7
4,000 Views
Last Modified: 2012-08-14
Hi All,

Im trying to run the command "Enable-Mailbox" remotely and im getting this error

"The term 'Enable-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again"

i remember something about permissions, i just cant remember what it was

Heres my code

    Shared Function EnableMailbox(ByVal username As String, ByVal aliasname As String) As String
        Dim schema1 = "http://schemas.microsoft.com/powershell/Microsoft.Exchange"
        Dim LivePath = AppSettings("ExLiveUri")

        Dim pw As New SecureString
        For Each c As Char In AppSettings("SystemPass")
            pw.AppendChar(c)
        Next

        Dim cred As New PSCredential(AppSettings("SystemUser"), pw)

        Dim wsman As New WSManConnectionInfo(New Uri(LivePath), schema1, cred)
        wsman.AuthenticationMechanism = AuthenticationMechanism.Default
        Dim RS = RunspaceFactory.CreateRunspace(wsman)
        Dim PS = PowerShell.Create()
        Dim CMD As New PSCommand

        CMD.AddCommand("Enable-Mailbox")
        CMD.AddParameter("Identity", username)
        CMD.AddParameter("Alias", aliasname)
        CMD.AddParameter("Database", "MDB1")

        PS.Commands = CMD
        Dim resp As String = ""
        Try
            RS.Open()
            Dim i = PS.Invoke()
            For Each ob As PSObject In i
                Dim nm = ob.BaseObject.ToString
                resp &= nm & "<br>"
            Next
            RS.Close()
            RS.Dispose()
            Return resp
        Catch ex As Exception
            Return ex.Message
        End Try

    End Function


0
Comment
Question by:Chrissalter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 33699611
Do you have exchange shell installed on the computer where you are running the code?

Good luck
Shaba
0
 
LVL 7

Author Comment

by:Chrissalter
ID: 33699632
no,

the code is being run on one server (our web server) and exchange is on the other (exchange server)

its as though its not loading the exchange snapin

0
 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 33699644
I feel that the computer you are running this command couldn't recognize the cmdlet. enable-mailbox is a part for exchange commandlets which comes in after installing the exchange management tools.

Good luck
Shaba
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Shabarinath Ramadasan
ID: 33699654
You need to run the setup for exchange and just select the Exchange management tools.
That will get this fixed.

Good luck
Shaba
0
 
LVL 7

Author Comment

by:Chrissalter
ID: 33699657
confirmed,

the exchange snapin is not being loaded

How do i load a snapin using wsman?

0
 
LVL 7

Author Comment

by:Chrissalter
ID: 33699662
but im not running the command on the web server im using wsman to run it on the exchange server
0
 
LVL 28

Accepted Solution

by:
sunnyc7 earned 500 total points
ID: 33699891
From your powershell window
run this

winrm quickconfig
http://scorpiotek.com/blog/?p=770

then establish a PSSession first before you start running other commands
http://technet.microsoft.com/en-us/library/dd819505.aspx
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question