【问题标题】:Cannot Mount AzureFileShare using Powershell on Windows Server无法在 Windows Server 上使用 Powershell 挂载 AzureFileShare
【发布时间】:2021-09-18 11:15:42
【问题描述】:

我的目标是将新驱动器附加到 Windows VM 映射到 Azure 文件共享 这需要通过 Terraform 完成

$UserName = $StorageAccount
$SecurePassword = ConvertTo-SecureString $StorageAccountKey -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword

# Mount the drive
    If (!(Test-Path O:)) {
        New-PSDrive -Name "O" -PSProvider "FileSystem" -Root "\\$StorageAccount.file.core.windows.net\$FileShareName" -Persist -Scope "Global" -Credential $Credentials
    }
    else { Write-Host "The O: drive is already in use." }

我得到的错误是

New-PSDrive : 指定的网络密码不正确

请帮忙

【问题讨论】:

  • 这几乎是不言自明的。
  • 我检查了密码,它是正确的

标签: windows azure powershell terraform


【解决方案1】:

不确定-ArgumentList 是否是对象的有效属性。尝试这个: $Credentials = New-Object System.Management.Automation.PSCredential ($UserName, $SecurePassword)

【讨论】:

  • 使用-ArgumentList与在(...)中包含相同,与[System.Management.Automation.PSCredential]::new(...)相同
  • 所以下一个问题是$StorageAccountKey 声明在哪里。
猜你喜欢
  • 2021-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多