Solved

How to script Exchange powershell commands?

Posted on 2008-10-23
7
675 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
In this video we show how to create a Shared Mailbox 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 >> Sha…
To show how to generate a certificate request 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 Servers >> Certificates…

776 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