Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Problem with the follow code: get-wmiobject win32_service ... foreach ($Service in $incl_Service)

$
0
0

 # I think you down understand my question ... 

#

# I need more arguments in variable "-incl_Service"  and "-excl_Service"

#             =========             ===============      ============== 

#

# .\service-query.ps1 localhost -startmode * -state running -incl_Service D*, Fax, *Update* -excl_Service Design*, DHCP*"

#                                                                         ==============================================

#

# This query is ok, but i missing more than on incl_Servic e.g: DNS*, DHCP, *Update*,  ... , ... , ... on both variables

#

param

        [string] $Computername,

        [string] $StartMode,

        [string] $State,

        [string[]]$incl_Service,

        [string[]]$excl_Service

    )

echo"Command         :  .\service-query.ps1 localhost -startmode * -state running -incl_Service D*"

echo"-----------"

echo"Computername    :$Computername"

echo"StartMode       :$StartMode"

echo"State           :$State"

echo"include Service :$incl_Service"

echo"exclude Service :$excl_Service"

$i= 0

foreach ($Servicein$incl_Service)

 $Service=get-wmiobjectwin32_service-Computer $Computername|`

         Select-ObjectDisplayName,State|`

        where { ($_.DisplayName-replace$excl_Service-like$incl_Service )-and ($_.StartMode-like$StartMode)-and ($_.State-like$State)}`

        }

 $Service; $i++

 



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>