简体   繁体   English

使用Powershell将文件上传到100个Azure VM

[英]Upload file to 100's of Azure VM using Powershell

I wanted to know about how to copy a file from a local system to 100's of Azure Virtual Machine. 我想知道如何将文件从本地系统复制到100个Azure虚拟机。 Example, from C:\\Users\\\\Desktop\\copyme.txt (local path) to C drive (or E drive) on Azure windows VM. 例如,从C:\\ Users \\\\ Desktop \\ copyme.txt(本地路径)到Azure Windows VM上的C驱动器(或E驱动器)。 I want to script this using Powershell. 我想使用Powershell编写脚本。

I know that we can do it individually via RDP. 我知道我们可以通过RDP单独进行操作。 Is there any way that we can automate this using Powershell? 有什么办法可以使用Powershell自动执行此操作?

Thanks in advance. 提前致谢。

Well, just copy file to session using powershell 5? 好吧,仅使用Powershell 5将文件复制到会话中? Like so: (assuming 1 single account is good for logging into all vm's) 像这样:(假设有一个单一帐户适合登录所有虚拟机)

$cred = Get-Credentials
$servers = Get-Content servers.txt
for ($server in $servers) {
    $session = New-PSSession $server -Credentials $cred
    Copy-Item -Path C:\copyme.txt -Destination C:\copyme.txt -ToSession $session
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM