Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinRM and Invoke-Command Help

Status
Not open for further replies.

ededdy

Programmer
Sep 6, 2010
1
ZA
Hi,

Previously we used to use psexec and execute reg and bat files on remote servers. Since we've upgrade all our servers to 2008 we the company would like us to use ps-remoting/Win-RM etc...

The ip's of the machines i would like to interact with are in a text file.

This is my current ps1 script:

do {
cls
Get-Content C:\IPS.txt | Foreach-Object {Invoke-Command $_ -Credential {Set-Location "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";Set-ItemProperty . -name DefaultUserName -value "A-TEST"}}

write-host "Running Test Done"

$response = Read-Host "Did the script error? Press y to run it again or press n to continue"
}
while ($response -match 'y')


If I run this from my machine it works. It successfully updates the registry on the machines, but I get no feedback on screen, meaning I don't see what it's actually doing in the console window.

How can I get powershell do display on screen?

Thanks :)





 
I am fairly new to remoting with PowerShell, so I am not 100% certain on this but I believe the issue is you are executing the command on a remote system and any error messages would therefore be on the remote console.

Try using PSSession instead.

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top