So i'm gaining a little more knowledge on Powershell an want to start using functions that can accept pipes more often.
i have achieved this but I'm, not sure how to get the results pipeable!
I want to be able to | ft and | export-csv from my functions.
this is a function i have made to get-tsload but im stuck when it comes to outputting the data in a format that will allow it to be piped into another command.
Function Get-TSLoad{
[CmdletBinding()]
param([Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[string[]]$ComputerName,
[string[]]$LoggedOn
)
PROCESS {
if ($PSBoundParameters.ContainsKey('computername'))
{
foreach($computer in $computername)
{
$computer
(Get-TSSession -ComputerName $computer).count
}
}
else
{
$ComputerName
$LoggedOn = (Get-TSSession -ComputerName $ComputerName).count
}
}
}