Forum Discussion

Biswajit21's avatar
Biswajit21
Copper Contributor
Jul 18, 2020

Permissions to query Azure Log Analytics from PowerShell

Team,

 

I am able to query with the following Code from one Work-space but same code is not working for another Work-space but I am able to query directly after login both the workspace . I have read access where Powershell code does not returns any output. Do I need any additional permission to run the below Code ?

 

$query = "Heartbeat | where TimeGenerated > ago(1d) | summarize LastHeartbeat = max(TimeGenerated) by Computer | where isnotempty(Computer) | where LastHeartbeat < ago(1h)" 
$selectSub = Set-AzContext -SubscriptionId "f8878fbq-4ch3-4ce0-8b08-9729ab66fa42"
if ($selectSub) {    
    $Workspace = Get-AzOperationalInsightsWorkspace -Name "insight-lt-workspace" -ResourceGroupName "azure-insight-lt"
 
    try {
        $Result = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId.Guid -Query $query -Verbose -ErrorAction SilentlyContinue
    }
    catch {
        Write-host 'Failure'
    }
}
 
$Result.Results

 

 

Thanks

Biswajit  

No RepliesBe the first to reply

Resources