【发布时间】:2016-07-11 21:26:22
【问题描述】:
上下文:
我已经从 azure-quickstart-template 中的 201-winrm-windows 设置了一个 ARM 部署。
- 部署运行良好
- 我可以使用 WinRM 访问虚拟机
- 我可以使用 WinRM 远程运行脚本
问题是我正在尝试在该 VM 上设置存储文件。 official documentation 要求运行此命令:
net use <drive-letter>: `
\<storage-account-name>.file.core.windows.net<share-name> `
/u:<storage-account-name> <storage-account-key>
# Result:
The command completed successfully.
问题:
- 当命令在本地运行时(VM 上的本地 powershell),我有一条成功消息并出现挂载。
- 当命令通过 WinRM 运行时,我有相同的成功消息,但是当我连接到 VM 时,我无法访问挂载。
我的代码:
$resourceGroupName = "resourcegroupname"
$username = "username"
$storageAccountName = "storageaccountname"
$zone = "westeurope"
$hostName = "$resourceGroupName.$zone.cloudapp.azure.com"
$shareFileName = "test"
$winrmPort = '5986'
$storageAccountKey = "......................"
$cred = new-object `
-typename System.Management.Automation.PSCredential `
-argumentlist $username, $password
$soptions = New-PSSessionOption -SkipCACheck
Invoke-Command `
-ComputerName $hostName `
-Credential $cred `
-Port $winrmPort `
-SessionOption $soptions `
-filepath .\provision.ps1 `
-UseSSL `
-ArgumentList `
$storageAccountName, `
$storageAccountKey, `
$shareFileName
还有配置文件.\provision.ps1:
Param (
[Parameter(Mandatory=$True,Position=0)]
[string]$accountStorageName,
[Parameter(Mandatory=$True,Position=1)]
[string]$accountStorageKey,
[Parameter(Mandatory=$True,Position=2)]
[string]$shareFileName
)
net use w: `
\\$accountStorageName.file.core.windows.net\$shareFileName `
/user:$accountStorageName $accountStorageKey
注意:
- 我的问题与this one类似,但作者没有回复。
【问题讨论】:
-
“无法访问挂载”是什么意思?有错误提示吗?
标签: powershell azure azure-storage winrm azure-storage-files