如何使用 Get-AzureRmStorageAccountKey PowerShell 命令显示完全可见的密钥?
How To Display Fully Visible Keys With Get-AzureRmStorageAccountKey PowerShell Command?
当我运行以下命令时:
Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname"
我会得到以下结果:
如何让键完全可见,以便我可以将其用作变量?
我通过调试命令找到了解决方法,所以这是完全显示密钥的命令:
$DebugPreference = “Continue”
write-debug (Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname")
编辑:
我这里明显有问题,write-debug
有效,但最后也报错,说:
写入调试:无法转换 'Microsoft.Azure.Management.Storage.Models.StorageAccountKey
这不是问题,只要它输出完整的密钥,但我可能使用 write-debug
命令的方式不对,因为当我想使用以下命令将输出保存到文件时:
$DebugPreference = “Continue”
write-debug (Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname") | Out-File output.txt
没有创建文件。
谁能帮我完成这个任务?这样我就有了一个完整的解决方案,可以将密钥输出到文件中,然后从该文件中找到密钥字符串,并将其用作下一个命令中的变量。
输出结果如下:
我只需要捕获key1,就是"value"之后开始的长字符串:“
您可以使用 Format-List cmdlet 来扩展属性:
Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname" | Format-List * -force
当我运行以下命令时:
Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname"
我会得到以下结果:
如何让键完全可见,以便我可以将其用作变量?
我通过调试命令找到了解决方法,所以这是完全显示密钥的命令:
$DebugPreference = “Continue”
write-debug (Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname")
编辑:
我这里明显有问题,write-debug
有效,但最后也报错,说:
写入调试:无法转换 'Microsoft.Azure.Management.Storage.Models.StorageAccountKey
这不是问题,只要它输出完整的密钥,但我可能使用 write-debug
命令的方式不对,因为当我想使用以下命令将输出保存到文件时:
$DebugPreference = “Continue”
write-debug (Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname") | Out-File output.txt
没有创建文件。
谁能帮我完成这个任务?这样我就有了一个完整的解决方案,可以将密钥输出到文件中,然后从该文件中找到密钥字符串,并将其用作下一个命令中的变量。
输出结果如下:
您可以使用 Format-List cmdlet 来扩展属性:
Get-AzureRmStorageAccountKey -ResourceGroupName "USWest" -AccountName "mystorageaccountname" | Format-List * -force