Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell syntax help

Posted on 2013-02-01
3
Medium Priority
?
398 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

715 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