Solved

Powershell syntax help

Posted on 2013-02-01
3
373 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 18

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
To show how to create a transport rule 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 >> Rules tab.:  To cr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 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

17 Experts available now in Live!

Get 1:1 Help Now