简体   繁体   中英

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. Example, from C:\\Users\\\\Desktop\\copyme.txt (local path) to C drive (or E drive) on Azure windows VM. I want to script this using Powershell.

I know that we can do it individually via RDP. Is there any way that we can automate this using Powershell?

Thanks in advance.

Well, just copy file to session using 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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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