Powershell copy-item not working with azure automation

给你一囗甜甜゛ 提交于 2020-06-17 09:43:30

问题


Trying to execute ps script on azure vm's using azure automation using the approach defined at https://stackoverflow.com/a/62258063/1014275. Script below does copy files between azure vm's. Both Vm's are in same subnet and if we run the copy-item command from VM powershell it copies the files to target VM folder. The same script executes successfully with azure automation runbooks, but without copying files.

Script used:

Copy-Item -Path C:\folder\sample.txt -Destination \\\VmHostname\C$\folder -Force 

Updated 1: The script throws exception as below.

Failed
VERBOSE: Performing the operation "Copy File" on target "Item: C:\folder\file.txt Destination: 
\\vmhostname\C$\folder". Copy-Item : You can't connect to the file share because it's not secure. This share requires the obsolete SMB1 
protocol, which is unsafe and could expose your system to attack.
Your system requires SMB2 or higher.

Update 2:

run the below ps command (Solved update 1 issue)

Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

after this we are getting below error

Failed
 Copy-Item : Access is denied
At C:\Packages\Plugins\Microsoft.CPlat.Core.RunCommandWindows\1.1.5\Downloads\script17.ps1:1 char:1
+ Copy-Item -Path C:\folder\file.txt -Destination \\vmhostname ...

Any suggestion would be helpful!

来源:https://stackoverflow.com/questions/62260399/powershell-copy-item-not-working-with-azure-automation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!