Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

running netsh advfirewall set rule on multiple computers

Posted on 2016-11-17
3
Medium Priority
?
132 Views
Last Modified: 2016-12-01
Hello,
I wanted to ask you how can I run this command on multiple computers at once?
The best way would be to specify server list in servers.txt and then run this on multiple servers.

o      netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes

thank you very much!
0
Comment
Question by:creative555
[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
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Dustin Saunders earned 2000 total points
ID: 41891873
Something like this would do the trick, with one computer name per line in the text file.  If you're not on a domain with permission, we'd need a different way though.
$textFile = "C:\Path\To\File.txt"
$computers = Get-Content $textFile

foreach ($computer in $computers)
{
    $cmd = 'netsh -r ' + $computer + ' advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes'   
    Invoke-Expression $cmd 
}

Open in new window

1
 

Author Comment

by:creative555
ID: 41894383
hm. It didn't work on the remote computer. I have no problem running enter-pssession directly. Running it in elevated prompt and with the domain admin account.
Ok.


WARNING: Could not obtain host information from machine: [Server02.testtarget.local]. Some commands may not be available.
The RPC server is unavailable
0
 

Author Closing Comment

by:creative555
ID: 41909474
This worked!! Was my fault. I ran it on the other server and it worked!! thank you very much!
0

Featured Post

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
The viewer will learn how to dynamically set the form action using jQuery.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

610 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