prompt for powershell for user inputbox

Greetings I am trying to construct a prompt for an inputbox that will prompt me for the input and then run this script and have it to go into the csv file. I am trying to Microsoft.visual basic parameters and they are not working. I am using powershell 3.0. The $prompto variable after organizationalname is the piece I am trying to get an inputbox to prompt for thanks. Any help would be appreciated.


$Total_results=@()
$mailbox=Get-mailbox –organizationalname $prompto
$mailbox| foreach-object{
$DisplayName=$_.DisplayName
$SmtpAddress=$_.PrimarySmtpAddress
$TotalItemSize=(get-mailboxstatistics –identity $DisplayName ).TotalITemSize
$ItemCount=(get-mailboxstatistics -identity $DisplayName ).ItemCount


$obj=new-object System.Object

$obj|add-member -membertype NoteProperty -name "PrimarySmtpAddress" -value $SmtpAddress

$obj|add-member -membertype NoteProperty -name "TotalItemSize" -value $TotalItemSize

$obj|add-member -membertype NoteProperty -name "ItemCount" -value $ItemCount

$Total_results+=$obj

}

$Total_results|export-csv c:\report.csv -notype
techdriveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmitIT ArchitectCommented:
Though PS is easy to use, however when it comes to GUI, it is a complex task. Check below MS URL
http://technet.microsoft.com/en-us/library/ff730941.aspx

See if this fits to your requirement.
0
footechCommented:
If you're fine with just a prompt at the console, then you can use Read-Host.
$prompto = Read-Host "Enter something"
If you really need a popup box then you're left with the more complicated route of creating GUI elements.
0
Murali ReddyExchange ExpertCommented:
$prompto = read-host                           ####and then
$mailbox=Get-mailbox –organizationalname $prompto -resultsize "unlimited"

or

$mailbox=Get-mailbox –organizationalname (read-host) -resultsize "unlimited"


May I have your requirement? Howmany exchange organizations you have in your setup?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
For a non-GUI, simple prompt you can use $promptTo = read-host 'Please provide the organizational unit to display members of'.

The code you showed isn't the way you should write PowerShell scripts. Make extensive use of the pipeline, as this improves both performance and memory consumption. Where you should use intermediate vars is if you need to use data more than once; you called get-mailboxstatistics twice, which should be avoided.
$promptTo = read-host 'Please provide the organizational unit to display mailboxes of'
Get-mailbox –organizationalname $prompto | foreach-object {
  $mbstats       = get-mailboxstatistics –identity $_.DisplayName

  new-object PsObject -Property @{
     PrimarySmtpAddress = $_.PrimarySmtpAddress
     TotalItemSize      = $mbstats.TotalITemSize
     ItemCount          = $mbstats.ItemCount
  }
} | export-csv c:\report.csv -notype

Open in new window

This can be written more smart even, by using the mailbox statistics object and filter/add properties as needed:
$promptTo = read-host 'Please provide the organizational unit to display mailboxes of'
Get-mailbox –organizationalname $prompto | foreach-object {
  $SmtpAddress = $_.PrimarySmtpAddress
  get-mailboxstatistics –identity $_.DisplayName |
    select TotalItemSize, ItemCount, @{n='PrimarySmtpAddress'; e={$SmtpAddress}}
} | export-csv c:\report.csv -notype

Open in new window

We have still to use foreach-object here since PrimarySmtpAddress isn't contained in the mb stats (the display name is for example).
0
oBdACommented:
For what it's worth, it's actually not that difficult to access the VB Inputbox in PS:
Add-Type -AssemblyName Microsoft.VisualBasic
$prompto = [Microsoft.VisualBasic.Interaction]::InputBox("Prompt", "Title", "Default Response")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
techdriveAuthor Commented:
outstanding thanks exactly what I was looking for OBDA
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.