Reputation: 1055
I have the below code....
Get-Service -CN . |
ForEach-Object {
write-host -ForegroundColor 9 "Service name $($_.name)"
if($_.DependentServices)
{ write-host -ForegroundColor 3 "`tServices that depend on $($_.name)"
foreach($s in $_.DependentServices)
{ "`t`t" + $s.name }
} #end if DependentServices
if($_.RequiredServices)
{ Write-host -ForegroundColor 10 "`tServices required by $($_.name)"
foreach($r in $_.RequiredServices)
{ "`t`t" + $r.name }
} #end if DependentServices
} #end foreach-object $o
This code gives me a list of all services being run on my machine and the various dependencies.
It also highlights the Service Name in RED and the Services Required and Services Dependent in GREEN. as shown below ...
what I want to do is separate the data output with blank lines after each service so that it looks like the below....
Can anyone advise me on the best way to do this? Can it be coded in?
I am trying to create a document to show what services we have and what dependencies etc.
All help appreciated.
Upvotes: 0
Views: 69
Reputation: 2066
May be just an extra write-host will be enough?
Get-Service -CN . |
ForEach-Object {
write-host -ForegroundColor 9 "Service name $($_.name)"
if($_.DependentServices)
{ write-host -ForegroundColor 3 "`tServices that depend on $($_.name)"
foreach($s in $_.DependentServices)
{ "`t`t" + $s.name }
} #end if DependentServices
if($_.RequiredServices)
{ Write-host -ForegroundColor 10 "`tServices required by $($_.name)"
foreach($r in $_.RequiredServices)
{ "`t`t" + $r.name }
} #end if DependentServices
write-host #new line
} #end foreach-object $o
Upvotes: 1