Scenario: You have collected information into a variable, and you want to run different formatting commands against that variable to performs tasks such as Sorting, Grouping, Selecting, Ect.
Don’t forget the Pipe! $final | Sort name
Example of the command you ran:
$final = get-mailboximportrequest -batchname ‘502’
#To display all properties:
$final | FL #List Style
$final | Select * #Table or List Style
$final | FT # Table Style
#Sorting based on a property:
$final | Sort Identity #Ascending Order
$final | Sort Identity -Descending #Descending Order
$final | Sort -unique # Sorts Unique Values
#Grouping based on a property
$final | Group RequestQueue #Provides a Count of number of objects in array based on the value of the RequestQueue.
$final | Group Request Queue | Sort Count #Same as command above by sorts by the count of the value of the Request Queue
# Where statements: Filter your variable based on a Property Value with
$final | Where Status -ne Completed
$final | Where {$_.Status -ne "Completed"}
$final | Where Status -like "*Failed*"
$final | Where WhenCreated -gt "5/3/2016 2:00:00 PM"
#common conditions:
-eq equals
-ne not equals
-gt greater than
-ge greater than or equal
-lt less than
-le less than or equal
-like Contains
-notlike Does not contain
#Rename a Property
$final | Select Identity, @{Name="Database";Expression={$_.RequestQueue} #this will display the request queue as the headername of Database.