Skip to content

Instantly share code, notes, and snippets.

@vScripter
Created April 13, 2015 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vScripter/d8ca05ec6c19bebdabea to your computer and use it in GitHub Desktop.
Save vScripter/d8ca05ec6c19bebdabea to your computer and use it in GitHub Desktop.
Creating new object
$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