按照此处的示例https://learn.microsoft.com/en-us/cli/azure/vm/run-command?view=azure-cli-latest
我在运行命令时遇到错误
az vm run-command invoke --command-id RunPowerShellScript --name win-vm -g my-resource-group --scripts @script.ps1
Run Code Online (Sandbox Code Playgroud)
错误:
展开运算符“@”不能用于引用表达式中的变量。“@script”只能用作命令的参数。要引用表达式中的变量,请使用“$script”。
将其放在引号中只会传入引号中的内容,而不是脚本的内容。
如何通过Graph API返回单个指定用户?
我能够返回所有用户,但需要通过 CLI 参数获取单个用户。
我熟悉在 Az CLI 中请求令牌——az account get-access-token --resource-type ms-graph | ConvertFrom-Json但我需要从 Azure PowerShell 获取令牌。我知道您可以通过以下方式请求 REST API 令牌
$currentAzureContext = Get-AzContext
$profileClient = New-Object Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient([Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile);
$UserToken = $profileClient.AcquireAccessToken($currentAzureContext.Subscription.TenantId).AccessToken;
Run Code Online (Sandbox Code Playgroud)
但同样,我需要一个 Graph 访问令牌。有没有办法做到这一点?