开发者

PowerShell: how to run script on a remote server?

开发者 https://www.devze.com 2023-04-02 11:32 出处:网络
I have a script: $StartDay = (Get-Date).AddDays(-2) Get-EventLog -LogName application -EntryType Error, Warning -After 开发者_如何学编程$StartDay

I have a script:

$StartDay = (Get-Date).AddDays(-2)
Get-EventLog -LogName application -EntryType Error, Warning -After 开发者_如何学编程$StartDay

which I would like to run from my computer (Win XP, PowerShell 1.0) on a Server1 and Server2 (Win 2008, PowerShell 2.0). How can I run this command on these servers?


You must have administrative credentials on remote computer .

$StartDay = (Get-Date).AddDays(-2)
Get-EventLog -LogName application -EntryType Error, Warning -After $StartDay -computername REMOTESERVERNAME


In order to user PowerShell remoting you need PowerShell 2.0 installed both on the server and on the client.

Check out these links. They are a good start into PowerShell remoting:

  • Remoting with PowerShell QuickStart

  • Windows PowerShell Remoting

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号