Solved

How to script Exchange powershell commands?

Posted on 2008-10-23
7
671 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

 

Author Comment

by:TaraC
Comment Utility
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
Comment Utility
0
 
LVL 18

Expert Comment

by:BSonPosh
Comment Utility
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
Comment Utility
This case ID can be closed.  This was not the solution we were looking for.
Thank you,
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
In this video we show how to create a Distribution Group 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 >>…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now