Solved

what does this mean? {$_.S   -q  } Help with the script

Posted on 2013-12-18
5
336 Views
Last Modified: 2013-12-23
what does this mean? {$_.S   -q  } I see it all the time in the scripts. For example
-ResultSize unlimited | Where {$_.Subject -eq "System Alert: Sales Database Reaching Capacity"} | Remove-Message -WithNDr $False



 I would like to be able to write simple scripts in powershell for Exchange 2010 &2013. Could you please advice on the good resource or videos that I can use.

Thank you very much!
0
Comment
Question by:claudiamcse
[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
5 Comments
 
LVL 1

Assisted Solution

by:Rapska1ion
Rapska1ion earned 167 total points
ID: 39728366
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 167 total points
ID: 39728468
Hi,

-ResultSize unlimited | Where {$_.Subject -eq "System Alert: Sales Database Reaching Capacity"} | Remove-Message -WithNDr $False

Open in new window


The "|" means that it is piping / pipelining objects from left to the right - but instead of generating a bunch of variables it is directly passing the objects down.

So the above means to get "all" results, then setting a filter on the resultset where the subject of each element equals "System ..." and these filtered resultset is going to be deleted (item by item). WithNDR parameter specifies whether a non-delivery report (NDR) is returned to the sender of a message. The default value is $true, therefore it is set here to false.

A good starting point for Exchange PSHell is here:
http://exchangeserverpro.com/powershell/
(of course the above training is very important as you should already know the basics of PS before digging into a specific server management and administration)

HTH
Rainer
0
 
LVL 57

Assisted Solution

by:Mike Kline
Mike Kline earned 166 total points
ID: 39728905
I was going to try and explain it but my friend Mark Minasi recently wrote a column and he did a great job

http://windowsitpro.com/powershell-amp-scripting/where-object-and-pipeline

I like Mark's idea think of $_ as $pipeline. Let me know if you questions after reading Mark's article

For training definitely start the free Microsoft Virtual Academy courses on powershell

http://www.microsoftvirtualacademy.com/Studies/SearchResult.aspx?q=powershell#?fbid=zc-AfodZCsj

They are taught by the inventor of powershell.  There are a lot of other great resources but start there and look at Mark's old columns too.  You will also get better the more you practice.

Thanks

Mike
0
 
LVL 16

Expert Comment

by:ThinkPaper
ID: 39732027
Quick answer - Think of anything starting with "$_." being an input variable. So if you are pulling in a CSV file to do stuff in powershell, and your CSV looks like:

Name, JobTitle
smithj, manager
williamsa, IT supervisor
johnsonk, engineer

So then to grab the values, you would use "$_.Name" and "$_.JobTitle"

"-eq" stands for equal.
0
 

Author Closing Comment

by:claudiamcse
ID: 39737007
Thanks a lot!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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