July 2017
Intermediate to advanced
648 pages
31h 9m
English
There is another useful technique for creating custom objects which utilizes the Select-Object cmdlet. Take a look at the following code:
$mailboxes | %{
$obj = "" | Select-Object Name,Database,Title,Dept
$obj.Name = $_.Name
$obj.Database = $_.Database
$obj.Title = (Get-User $_.Name).Title
$obj.Dept = (Get-User $_.Name).Department
Write-Output $obj
}
You can create a custom object by piping an empty string variable to the Select-Object cmdlet, specifying the property names that should be included. The next step is to simply assign values to the properties of the object using the property names that you've defined. This code loops through the items in our $mailboxes object and returns a custom object for each one. The output ...
Read now
Unlock full access