Solved

Powershell syntax help

Posted on 2013-02-01
3
372 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
Comment Utility
Whats wrong with the output if you could send here.
0
 
LVL 5

Accepted Solution

by:
coraxal earned 500 total points
Comment Utility
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
Comment Utility
Perfect thanks for your help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
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 generate a certificate request 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 Servers >> Certificates…
The viewer will learn how to dynamically set the form action using jQuery.

772 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