Solved

Powershell syntax help

Posted on 2013-02-01
3
377 Views
Last Modified: 2013-02-02
Hi all im creating a powershell script for installing exchange 2010 which works but i have come to a point where i need help. I would like to enter 2 parameters within one function so that it asks the server name which works folowed by the mnemonic. I have inserted the code below that i have. Any help appreciated.

thanks

function dbaseconfig {
param(
    [Parameter(Mandatory=$true)]
    $servername, $mnemonic
    )
add-pssnapin microsoft.exchange.management.powershell.e2010
Get-MailboxDatabase -server $servername  | set-mailboxdatabase -name 'Mailbox Database $mnemonic'
}
0
Comment
Question by:cwstad2
3 Comments
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 38845553
Whats wrong with the output if you could send here.
0
 
LVL 5

Accepted Solution

by:
coraxal earned 500 total points
ID: 38845784
Well, based on your description I'm guessing you're using $mnemonic as part of the database name. If that's true, I'd use it as a separate parameter in your function and use double quotes instead of single
function dbaseconfig {
	param
	(
		[Parameter(Mandatory=$true,
					Position=0)]
		[string]$servername, 
		[Parameter(Mandatory=$true,
					Position=1)]
		[string]$mnemonic
		
	)

	add-pssnapin microsoft.exchange.management.powershell.e2010
	Get-MailboxDatabase -server $servername | 
	set-mailboxdatabase -name "Mailbox Database $mnemonic"
} 

Open in new window

0
 
LVL 15

Author Closing Comment

by:cwstad2
ID: 38846278
Perfect thanks for your help
0

Featured Post

Are your AD admin tools letting you down?

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.

Question has a verified solution.

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

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.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

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