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

x
?
Solved

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

Posted on 2013-12-18
5
Medium Priority
?
339 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 668 total points
ID: 39728366
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 668 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 664 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Suggested Courses

704 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