Link to home
Create AccountLog in
Avatar of cwstad2
cwstad2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell multiple queries

Hi all, is it possible to query multiple objects and have the all returned for example im looking to get a report on
SAMAccountName,name.IPv4Address,Created,Modified,OperatingSystemVersion,OperatingSystem,OperatingSystemServicePack,LastLogonTimeStamp

thanks
ASKER CERTIFIED SOLUTION
Avatar of becraig
becraig
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
As an example you can use this :
function get-objvalues
{
$computer=hostname
$totalprocesses = (Get-Process).count

return $computer, $totalprocesses
}
$pc,$tprc = get-objvalues
Write-Host "PC - $pc      Processes Count - $tprc"

Open in new window

Or

$results = get-objvalues
Write-Host "PC - $($results.item(0))      Processes Count - $($results[1])"

Open in new window

SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
What becraig meant was, translated to the example by RMA:
function get-objectvalues
{
   New-Object PsObject -Property @{
       ComputerName = $env:ComputerName
       TotalProcesses   = (Get-Process).Count
  }
}

$results = get-objectvalues
$results | format-table -auto
Write-Host "$($results.ComputerName) has $($results.TotalProcesses) processes running"

Open in new window

Avatar of cwstad2

ASKER

sorry for the delay guys. Appreciate the help