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
Solved

Powershell

Posted on 2016-08-30
6
73 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
  • 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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