Solved

Powershell syntax help

Posted on 2013-02-01
3
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
The viewer will learn how to count occurrences of each item in an array.
how to add IIS SMTP to handle application/Scanner relays into office 365.

751 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