Manjunath Rao
Manjunath Rao

Reputation: 1511

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.

Upvotes: 1

Views: 344

Answers (1)

4c74356b41
4c74356b41

Reputation: 72161

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
}

Upvotes: 3

Related Questions