CrowdStrike / psfalcon

PowerShell for CrowdStrike's OAuth2 APIs
The Unlicense
370 stars 71 forks source link

Create output-selected-host-info-and-replace-ids-with-names.ps1 #408

Closed David-M-Berry closed 5 months ago

David-M-Berry commented 5 months ago

Added the Hostname param.

The script still runs normally, but if you add the -Hostname "SPECIFICHOSTNAME" you can just get the output for a single host.

Update output-selected-host-info-and-replace-ids-with-names.ps1 to allow specific hostnames

Added features and functionality

Explanation of Changes

  1. Hostname Parameter:

This allows the script to accept a hostname as an optional parameter.

   Param (
       [string]$Hostname
   )
  1. Filtering Host Information:

This filters the retrieved host information to include only the specified hostname if provided.

# Retrieve all host information and filter to selected fields
$HostInfo = if ($Hostname) {
  Get-FalconHost -Filter "hostname:'$Hostname'" -Detailed | Select-Object $Field
} else {
  Get-FalconHost -Detailed -All | Select-Object $Field
}

Usage

This update ensures that the script can be used to retrieve information for all hosts or for a specific host, based on user input.

David-M-Berry commented 5 months ago

Thank you for the optimization suggestion @bk-cs !