this origin code:
#Requires -Version 5.1 -Modules @{ModuleName="PSFalcon";ModuleVersion='2.1'}
param(
[Parameter(Mandatory = $true, Position = 1)]
[ValidatePattern('\.txt$')]
[ValidateScript({
if (Test-Path -Path $_ -PathType Leaf) {
$true
} else {
throw "Cannot find path '$_' because it does not exist or is a directory."
}
})]
[string] $Path,
Start-Sleep
-Milliseconds 30000
[Parameter(Mandatory = $true, Position = 2)]
[string] $Name,
Start-Sleep
-Milliseconds 15000
[Parameter(Position = 3)]
[string] $Description
)
process {
try {
# Import hostnames and create host group
$Hostnames = (Get-Content -Path $PSBoundParameters.Path).Normalize()
$Param = @{
GroupType = 'static'
Name = $PSBoundParameters.Name
}
if ($PSBoundParameters.Description) {
$Param['Description'] = $PSBoundParameters.Description
}
$Group = New-FalconHostGroup @Param
[array] $HostIds = for ($i = 0; $i -lt $Hostnames.count; $i += 20) {
# Retrieve the device_id for hostnames in groups of 20
$Filter = ($Hostnames[$i..($i + 19)] | ForEach-Object {
if ($_ -ne '') {
"hostname:['$_']"
}
}) -join ','
,(Get-FalconHost -Filter $Filter)
}
# Add hosts to group
Invoke-FalconHostGroupAction -Name add-hosts -Id $Group.id -HostIds $HostIds
} catch {
throw $_
}
}
I glad for any hel[p
nate