Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enable-Mailbox Not Recognised

Posted on 2010-09-17
7
Medium Priority
?
4,469 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
  • 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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
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 2000 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

Ready for your healthcare security check-up?

In the past few years, healthcare organizations have become a prime target for advanced attacks. Does your organization have what it needs to defend itself? Schedule your healthcare security check-up today and download our free Healthcare Security Resource Kit today!

Question has a verified solution.

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

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

926 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