Solved

Powershell

Posted on 2016-08-30
6
84 Views
Last Modified: 2016-09-09
I will like to run a exe located in a particular directory.  After exe is performed I will like then to a restart a service.  

I will like to run this exe on all Domain Controllers in my environment.  Does anyone know how to performed this in Powershell.

The cmdlets I will like to use for the DC's are "Get-ADDomainControllers"

The user the foreach statement.

Example of directory: Path of the exe;  Filename of exe (watchdog.exe)


Can someone please provide the syntax for this
D:\Program files\Monitor\
0
Comment
Question by:JCJohnson76
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:FOX
ID: 41776663
Is the .exe sitting on each domain controller?
0
 

Author Comment

by:JCJohnson76
ID: 41776683
yes; same path
0
 
LVL 16

Assisted Solution

by:FOX
FOX earned 50 total points
ID: 41776700
Try the below

$DC=Get-ADDomainController | ft samaccountname | foreach{start-process -filepath 'D:\Program files\Monitor\watchdog.exe' | Restart-Service theservicename
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:JCJohnson76
ID: 41776940
does not work;

Lets use another example

Lets say Systernal "pskill" is locate under the c:\tools\    This path is located on all DC's

And I have notepad running on all DC"s and I want to use pskill to kill this process.  How would I be able to do it using Get-ADDomaincontrollers
0
 
LVL 40

Accepted Solution

by:
Subsun earned 450 total points
ID: 41779934
pskill can be used to remotely kill the processes.

See the example below..
Import-Module Activedirectory
Get-ADDomainController -Filter * | %{
	& 'C:\Tools\pskill.exe' "\\$($_.name)" notepad
}

Open in new window

Pskill.exe should be there in the specified path where you run the script.
0
 

Author Closing Comment

by:JCJohnson76
ID: 41791296
Subsun,

Thanks, it worked a like a charm
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

623 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