Link to home
Start Free TrialLog in
Avatar of jfgray
jfgray

asked on

Modify Service settings

Hello,

I have the following script


$Computers = gc "c:\Active_Computers.txt"

$colItems = get-wmiobject -class "Win32_Service" -namespace "root\CIMV2" `
-computername $Computers

foreach ($objItem in $colItems) {

Write-Host  $Computers
write-host "Desktop Interact: " $objItem.DesktopInteract
Write-Host "Service Name :" $objItem.DisplayName

write-host
}


I would like to only tell me where the service named "Intel Local Scheduler Service" is set to   DesktopInteract = true and if it is change it to false

Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


Filter the results first:
Get-WmiObject Win32_Service -Filter "DisplayName='Intel Local Scheduler Service' AND DesktopInteract=$True"

Open in new window

Make sure that returns what you need first please :)

Then, if it does:
$Service = Get-WmiObject Win32_Service -Filter "DisplayName='Intel Local Scheduler Service' AND DesktopInteract=$True"
$Service.DesktopInteract = $False
$Service.Put()

Open in new window

And if all that works, reinstate the loop:
Get-Content C:\Active_Computers.txt | ForEach-Object {
  $Service = Get-WmiObject Win32_Service -ComputerName $_ `
    -Filter "DisplayName='Intel Local Scheduler Service' AND DesktopInteract=$True"
  If ($Service) {
    $Service.DesktopInteract = $False
    $Service.Put()
  }
}

Open in new window

HTH

Chris

We might find that that option doesn't actually work. If you find that to be the case, pop back and we can call the Change method to modify it. It might just take a little experimentation to get there :)

Chris
Avatar of jfgray
jfgray

ASKER

I can now filter for only that service and where objItem.DesktopInteract = True but it does not take the check mark out of "Allow service to interact with desktop"
Avatar of jfgray

ASKER

This is what I have so far

=====================================
$Computers = gc "c:\Active_Computers.txt"

$colItems = get-wmiobject -class "Win32_Service" -namespace "root\CIMV2" `
-computername $Computers -Filter "DisplayName='Intel Local Scheduler Service' AND DesktopInteract=$True"

foreach ($objItem in $colItems ) {

Write-Host  $objItem.SystemName
}
=====================================

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jfgray

ASKER

You the MAN !