Home › Studies › SC-200 › CLI & PowerShell Commands

CLI & PowerShell Commands

SC-200 tasks with the Azure CLI and PowerShell side by side for each domain, copied from the topic pages.

Every command here comes from a CLI or PowerShell table on one of the SC-200 topic pages. A - means the topic page gives no command for that tool. Placeholders such as <rg> are yours to fill in.

Manage a security operations environment (40–45%)

Defender for Endpoint Setup

TaskAzure CLIPowerShell
Verify a custom collection rule is collecting from a devicesearch in (DeviceCustomFileEvents, DeviceCustomScriptEvents, DeviceCustomNetworkEvents, DeviceCustomProcessEvents, DeviceCustomImageLoadEvents) "your_device_id" | where DeviceId == "your_device_id" | summarize EventCount = count() by RuleName, RuleLastModificationTime, $table | order by RuleLastModificationTime desc-

Data Connectors & Ingestion

TaskAzure CLIPowerShell
Create a custom table (Analytics plan)az monitor log-analytics workspace table create --resource-group "$resourceGroupName" --workspace-name "$workspaceName" --name "$tableName" --plan Analytics --columns TimeGenerated=datetime RawData=string-
Test an XPath filter for a DCR-Get-WinEvent -LogName 'Application' -FilterXPath $XPath

Detection Rules & Analytics

TaskAzure CLIPowerShell
Assess anomalies from one rule (last 24 hours)Anomalies | where RuleId contains "<RuleId>"-
Compare original and customized anomaly rulesAnomalies | where AnomalyTemplateId contains "<RuleId>"-
Custom detection query that keeps Timestamp and ReportId (NRT compatible)DeviceEvents | where ingestion_time() > ago(1d) | where ActionType == "AntivirusDetection" | summarize (Timestamp, ReportId)=arg_max(Timestamp, ReportId), count() by DeviceId | where count_ > 5-

Topic pages: Defender for Endpoint Setup, Data Connectors & Ingestion, Detection Rules & Analytics.

Respond to security incidents (35–40%)

Identity & Purview Threats

TaskAzure CLIPowerShell
Disable a user in Microsoft Entra ID-Update-MgUser -UserId $User.Id -AccountEnabled:$false
Revoke the user's Microsoft Entra refresh tokens-Revoke-MgUserSignInSession -UserId $User.Id
Disable a user in on-premises Active Directory-Disable-ADAccount -Identity johndoe

Endpoint Response & Live Response

TaskAzure CLIPowerShell
Find devices where containment blocked user activityDeviceEvents | where ActionType contains "ContainedUser"-
Find devices where containment blocked device activityDeviceEvents | where ActionType contains "ContainedDevice"-
List attack disruption actions (30 days)DisruptionAndResponseEvents | where Timestamp > ago(30d) | project Timestamp, ActionType, AttackDisruptionCategory, DeviceName, AccountUpn, RemoteIP | order by Timestamp desc-
Download a file in the background (live response)getfile "C:\windows\some_file.exe" &-
Remediate a file automatically (live response)remediate file <file path> -auto-
Check the Sense agent version (Contain user needs v10.8470)-Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status' -Name "MsSenseDllVersion"

Audit, eDiscovery & Graph Logs

TaskAzure CLIPowerShell
Check unified audit log ingestion (Exchange Online PowerShell)-Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled
Turn audit log search off (Exchange Online PowerShell)-Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $false
Find throttled Graph API callersMicrosoftGraphActivityLogs | where TimeGenerated > ago(3d) | where ResponseStatusCode == 429-

Topic pages: Identity & Purview Threats, Endpoint Response & Live Response, Audit, eDiscovery & Graph Logs.

Perform threat hunting (20–25%)

Advanced Hunting & KQL

TaskAzure CLIPowerShell
First hunting query: PowerShell download activity// Finds PowerShell execution events that could involve a download union DeviceProcessEvents, DeviceNetworkEvents | where Timestamp > ago(7d) // Pivoting on PowerShell processes | where FileName in~ ("powershell.exe", "powershell_ise.exe") // Suspicious commands | where ProcessCommandLine has_any("WebClient", "DownloadFile", "DownloadData", "DownloadString", "WebRequest", "Shellcode", "http", "https") | project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, RemoteIP, RemoteUrl, RemotePort, RemoteIPType | top 100 by Timestamp-
Chart alerts by severityAlertInfo | summarize Total = count() by Severity | render columnchart-
Inner join on a time-filtered file hashEmailAttachmentInfo | where Timestamp > ago(1h) | where Subject == "Document Attachment" and FileName == "Document.pdf" | join kind=inner (DeviceFileEvents | where Timestamp > ago(1h)) on SHA256-
Cross-workspace tableworkspace('<Workspace ID or Azure Resource ID>').<Table Name>-

Sentinel Hunting & Data Lake

TaskAzure CLIPowerShell
Delay a scheduled query for data lake ingestion latencylet lookback = 15m; let delay = 15m; let endTime = now() - delay; let startTime = endTime - lookback; CommonSecurityLog | where TimeGenerated between (startTime .. endTime)-
Summary rule query exampleGCPAuditLogs | where ServiceName == 'pubsub.googleapis.com' | summarize count() by Severity-

Topic pages: Advanced Hunting & KQL, Sentinel Hunting & Data Lake.

Pages with no command table

These topic pages have no CLI or PowerShell table, so nothing from them is repeated here: XDR Alerts & Auto Response, Sentinel Setup & Automation, Email, App & Workload Threats, Incidents & Case Management.