Solved

How to script Exchange powershell commands?

Posted on 2008-10-23
7
684 Views
Last Modified: 2012-05-05
I would like to run a Exchange cmdlet from a PowerShell command line inside an ASP web page using wscript object.  

The code look like this:

set wshell=CreateObject("Wscript.Shell")
wshell.run "%COMSPEC% /C C:\Windows\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile 'C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1' -command "". 'set-mailbox [username] -ApplyMandatoryProperties'"", 0, TRUE
set wshell=nothing



Essentially I just want to run the above set-mailbox command inside of an ASP page WITHOUT putting set-mailbox command in a ps1 file and execute it.  Could you tell me what is the best way to do it?

Thanks.
0
Comment
Question by:TaraC
[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
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:exx1976
ID: 22787889
I apologize for my lack of knowledge of powershell (I haven't hopped on the bandwagon just yet)..  What is it, exactly, you are trying to do?  If you can't get the PS to execute properly from within the ASP page, why not just use the corresponding VBS code?  If you tell me what you're trying to modify I can most likely provide the VBS...
0
 

Author Comment

by:TaraC
ID: 22788037
I want to create a Exchange 2007 mailbox properly with using an ASP page.  I'm able to create mailbox on Exchange 2007 and able view the mailbox using Outlook but unable to open within OWA.  By running the command above (straight from Powershell) Exchange 2007 will set all the properties correctly and allow me to open the mailbox with/from OWA.
We're just doing something wrong with the syntax of the line.  
Does that help?
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22788110
So if I'm understanding correctly, you're trying to modify the "Outlook Web Access" setting under "Protocols" on the "Exchange Features" tab of the user.  Is that correct?

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:TaraC
ID: 22789486
bottom line is, I want to create an Exchange 2007 mailbox properly with using an ASP page and I don't have the syntax right.  I need to put this,
New-Mailbox -Name 'Qtest Q. testme' -Alias 'testmqq1' -OrganizationalUnit 'do.test.edu/User Accounts/Accounts-New' -UserPrincipalName 'testmqq1@do.test.edu' -SamAccountName 'testmqq1' -FirstName 'Qtest' -Initials 'Q' -LastName 'testme' -Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $true -Database '<db1>'
inside of an ASP page and how it create the account and mailbox in the right database.   When we try, the syntax isn't correct.
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 22791332
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 22791343
oh... btw 'System.Security.SecureString'  is a .NET type. It cannot be passed as a string.

-password will require the test password be converted to secure string
0
 

Accepted Solution

by:
TaraC earned 0 total points
ID: 22870893
This case ID can be closed.  This was not the solution we were looking for.
Thank you,
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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…
This video discusses moving either the default database or any database to a new volume.

705 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