Advertisement
upz

Get-ReqServices

upz
Nov 17th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Get-ReqServices
  2. {
  3.     param
  4.     (
  5.        # Service you want recursive required services from
  6.        [string]$service
  7.     )
  8.        
  9.     $final_list = @()
  10.     $final_list += (get-service $service).RequiredServices
  11.    
  12.     do
  13.     {
  14.         $check = $final_list.count
  15.         foreach ($item in $final_list)
  16.         {            
  17.             if(($item.RequiredServices).count -ne 0)
  18.             {
  19.                 $final_list += (Compare-Object $final_list $item.RequiredServices | where {$_.sideindicator -eq "=>"}) | select inputobject -ExpandProperty inputobject                
  20.             }
  21.         }
  22.     }
  23.     until ($check -eq $final_list.count)
  24.    
  25.     $final_list | select status,name,Displayname,RequiredServices | Sort-Object -Property Name
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement