Solved

Powershell

Posted on 2016-08-30
6
54 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now