?
Solved

How to script Exchange powershell commands?

Posted on 2008-10-23
7
Medium Priority
?
687 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
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.

 

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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this video we show how to create an Address List 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 Organization >> Ad…
In this video we show how to create an email address policy 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…
Suggested Courses

762 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