Solved

How to script Exchange powershell commands?

Posted on 2008-10-23
7
680 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…
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…

860 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