#$cred = Get-Credential # または #(事前に Get-Credential | Export-Clixml $HOME\vm01-cred.xml でXMLを作成) #$cred = Import-Clixml $HOME\vm01-cred.xml # または $username = ".\Administrator" $password = "P@ssw0rd!" $securePassword = ConvertTo-SecureString $password -AsPlainText -Force $cred = [PSCredential]::new($username, $securePassword) $vmName = "vm01" Invoke-Command -VMName $vmName -Credential $cred -ScriptBlock { $before = (Get-Item "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe").VersionInfo.ProductVersion #https://learn.microsoft.com/ja-jp/deployedge/deploy-edge-with-windows-10-updates Start-Process -FilePath "${env:ProgramFiles(x86)}\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -ArgumentList "/silent /install appguid={56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}&appname=Microsoft%20Edge&needsadmin=True" -Wait $after = (Get-Item "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe").VersionInfo.ProductVersion "Edge: $before -> $after" }