Created
April 13, 2015 03:44
-
-
Save vScripter/d8ca05ec6c19bebdabea to your computer and use it in GitHub Desktop.
Creating new object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$queryItems = Get-Service | Select ServiceName,Status | |
foreach ($service in $queryItems) { | |
# clear on each iteration | |
$objSvc = @() | |
# create properties and assign values; in this example I am using strong types to define the type of value | |
# the property will return | |
$objSvc = [PSCustomObject] @{ | |
Service = [System.String]$service.ServiceName | |
ServiceStatus = [System.String]$service.Status | |
} | |
# call the object on each iteraton and return the results | |
$objSvc | |
} # end foreach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment