[英]How to run PS1 file on a Server 2016 from a remote computer?
i wrote a script for Exchange Management Shell.我为 Exchange Management Shell 编写了一个脚本。 i've saved the script on the server.
我已将脚本保存在服务器上。 my question is: how can i run the script from a remote windows 10 Computer?
我的问题是:如何从远程 windows 10 计算机运行脚本? *regarding to server authentiication - it's OK for me to write my server Credentials on the script
*关于服务器身份验证 - 我可以在脚本上写下我的服务器凭据
i've try this script, but it's asking for user and password every time and cannot exeute the file.我试过这个脚本,但它每次都要求输入用户名和密码,并且无法执行文件。
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://mailserver/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session
Invoke-Command -ComputerName mailserver -FilePath \\mailserver\c$\Script\MPC3.ps1
EDIT: i want to be able to open the following PS on my Windows computer:编辑:我希望能够在我的 Windows 计算机上打开以下 PS:
Thanks for helping me !谢谢你帮助我!
I do not recommend to store credentials inside a script.我不建议将凭据存储在脚本中。 But here a way of doing it:
但这里有一种方法:
$Username = 'username'
$Password = 'passwd' | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList $Username, $Password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.