Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Psexec in Powershell Question

$
0
0

 Hello All,

If I wanted to run two netsh commands in the context below, what would the syntax for that be, if possible? I've tried a few different things, but I can't seem to get it to work. I'd rather not launch a 2nd process to enable another firewall rule, if I don't have to. Here is the line I'd like to to concatenate:

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


     #Computer name for PsExec
     $PsExecCname="\\$computer"       
     #Psexec the computer by running it through a local process and enable WMI on the firewall
     Write-Host "Enabling WMI firewall rules on $($computer.ToUpper())..." -ForegroundColor Cyan
     $command ='netsh advfirewall firewall set rule group="Windows Management Instrumentation (WMI)" new  enable=yes'
     Start-Process -FilePath 'C:\windows\System32\sysinternals\psexec.exe' -ArgumentList @($PsExecCname,$command)     -Wait -WindowStyle Hidden


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>