Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Modify Service settings

Posted on 2011-02-15
6
Medium Priority
?
935 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:jfgray
  • 3
  • 3
6 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 34899664

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
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 34899802

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
0
 

Author Comment

by:jfgray
ID: 34900026
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"
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:jfgray
ID: 34900036
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
}
=====================================

0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 34900187
In that case we'll have to use the Change method.

Can we try...
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.Change($Null, $Null, $Null, $Null, $Null, $False, $Null, $Null, $Null, $Null, $Null)
  }
}

Open in new window

We may have to feed it the other values instead of Null, please use this on something we can safely test against, I'd hate to break something important.

Chris
0
 

Author Comment

by:jfgray
ID: 34900390
You the MAN !
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question