I need some help with the output of the following script so the output doesn't show with the ellipses (...). I tried to insert | Format-Table -Wrap -AutoSize
but I just can't seem to get it right.
clear-host Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue $services = new-object system.collections.sortedlist $servers = (get-spfarm).servers foreach ($server in $servers) { foreach($service in $server.serviceinstances) { if ($service.status = "Online") { $s = $service.typename if ($services.contains($s)) { $serverlist = $services[$s] $servername = $server.name $services[$s] = "$serverlist - $servername" } else { $services[$s] = $server.name } } } } $services
output:
Name Value ---- ----- Access Database Service SE5APP - SE5FE - SE7FE - FAQ3 Application Discovery **and L...** SE5APP - SE5FE - SE7FE - FAQ3 Application Registry Service SE5APP - SE5FE - SE7FE - FAQ3
Here, the fix is to change the $FormatEnumerationLimit value. If you type it on its own into PowerShell the current value – probably 3 – will be returned. If you set a new value of -1, it'll output ALL entries in your collection.
The Format-Table cmdlet formats the output of a command as a table with the selected properties of the object in each column. The object type determines the default layout and properties that are displayed in each column. You can use the Property parameter to select the properties that you want to display.
The “$_” is said to be the pipeline variable in PowerShell. The “$_” variable is an alias to PowerShell's automatic variable named “$PSItem“. It has multiple use cases such as filtering an item or referring to any specific object.
$_ in the PowerShell is the 'THIS' toke. It refers to the current item in the pipeline. It can be considered as the alias for the automatic variable $PSItem.
Either Format-List
(fl
) or Format-Table -auto
(ft -auto
) should help here.
$services | fl
OR
$services | ft -auto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With