Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Function against multiple computers from list?

$
0
0

Howdy - I found this great function that i need to use but against multiple servers that I have in a list.

how can I modify this to use against several servers in a file?

function RemoteCMD {        param(      [Parameter(Mandatory=$true,valuefrompipeline=$true)]      [string]$compname)      begin {          $command = [char]34+"powermt display dev=all"+[char]34+" > c:\temp\log.txt"          [string]$cmd = "CMD.EXE /C " +$command                          }      process {          $newproc = Invoke-WmiMethod -class Win32_process -name Create -ArgumentList ($cmd-ComputerName $compname | out-null         Start-sleep -s 5         $mt=Get-Content \\$compname\C$\temp\log.txt | Out-String         Write-Output $mt         }      End{Write-Output "Script ...END"}                   } 



Viewing all articles
Browse latest Browse all 15028

Trending Articles



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