Upload file to 100's of Azure VM using Powershell

324 Views Asked by At

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.

1

There are 1 best solutions below

1
On BEST ANSWER

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
}