Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

I want to run a script on multiple servers(nearly 40-50 servers) parallely

$
0
0

I'm trying to execute an existing script on a remote server and capture the output in a local file


$Username = "user"

$Password = "Password"

$servers = get-content "c:\temp\servers.txt"

$sb = {c:\temp\PsExec.exe -h \\$server -u $Username -p $password cmd.exe /c "echo . 
| Powershell.exe -executionpolicy bypass -file c:\script.ps1" > "$env:userprofile\Desktop\output.txt"} foreach($server in $servers) { start-job -ScriptBlock $sb }

this code works fine if i remove start-job, but executes one after the other, which takes lot of time.

I cannot use PSsession or invoke-command, since it is restricted in our environment.

This code never exits. It stops at this position:

 + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

Viewing all articles
Browse latest Browse all 8583

Trending Articles