> For the complete documentation index, see [llms.txt](https://manuals.blusapphire.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manuals.blusapphire.io/blugenie/full-function-list/invoke-blugenieyara.md).

# Invoke-BluGenieYara

﻿

### Invoke-BluGenieYara <a href="#invoke-blugenieyara" id="invoke-blugenieyara"></a>

### SYNOPSIS <a href="#synopsis" id="synopsis"></a>

Yara Scanner

### SYNTAX <a href="#syntax" id="syntax"></a>

```
Invoke-BluGenieYara [[-ItemToScan] <String[]>] [-Rules <String>] [-RulesSource <String[]>] [-CompiledRules] [-ToolPath <String>] [-Count] [-Tag <String>] [-Identifier <String>] [-Negate] [-PrintTags] [-PrintMeta] 
[-MaxStringsPerRule <Int32>] [-PrintStrings] [-PrintStats] [-PrintNamespace] [-Threads <Int32>] [-PrintStringLength <Int32>] [-MaxRules <Int32>] [-Timeout <Int32>] [-Recurse] [-FastScan] [-StasckSize <Int32>] 
[-FailOnWarnings] [-NoWarnings] [-Version] [-CommandHelp] [-ClearGarbageCollecting] [-UseCache] [-CachePath <String>] [-RemoveCache] [-DBName <String>] [-DBPath <String>] [-UpdateDB] [-ForceDBUpdate] 
[-NewDBTable] [-Walkthrough] [-ReturnObject] [-OutUnEscapedJSON] [-OutYaml] [-FormatView <String>] [<CommonParameters>]
```

### DESCRIPTION <a href="#description" id="description"></a>

Invoke-BluGenieYara is a wrapper around the YARA tool. The Yara tools is designed to help malware researchers identify and classify malware samples. It’s been called the pattern-matching Swiss Army knife for security researchers (and everyone else).

### EXAMPLES <a href="#examples" id="examples"></a>

#### EXAMPLE 1 <a href="#example-1" id="example-1"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP
```

```
Description: Scan all files under $env:temp directory with any .Yar rules found
Notes:
```

#### EXAMPLE 2 <a href="#example-2" id="example-2"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -Recurse
```

```
Description: Recursive Directory Scan
Notes:
```

#### EXAMPLE 3 <a href="#example-3" id="example-3"></a>

```
Command: Invoke-BGYara -ItemToScan $env:TEMP -Recurse
```

```
Description: Use the (BG) Alias to run Yara
Notes:
```

#### EXAMPLE 4 <a href="#example-4" id="example-4"></a>

```
Command: Yara -ItemToScan $env:TEMP -Recurse
```

```
Description: Use the Short Name Alias to run Yara scan
Notes:
```

#### EXAMPLE 5 <a href="#example-5" id="example-5"></a>

```
Command: Invoke-BluGenieYara -ItemToScan "$env:TEMP\AttachmentArchive.msg" -Rules 'Attachment'
```

```
Description: Run all Rules with Attachment in the name against the .MSG file in the temp direcotry
Notes:
```

#### EXAMPLE 6 <a href="#example-6" id="example-6"></a>

```
Command: Invoke-BluGenieYara -ItemToScan "$env:TEMP\AttachmentArchive.msg" -Rules 'Attachment' -RulesSource Z:\YaraRules\Email
```

```
Description: Run all Rules with Attachment in the name from a specific source, against the .MSG file in the temp direcotry
Notes:
```

#### EXAMPLE 7 <a href="#example-7" id="example-7"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $(Get-Process -Name notepad++ | Select-Object -ExpandProperty ID)
```

```
Description: Scan a PID
Notes:
```

#### EXAMPLE 8 <a href="#example-8" id="example-8"></a>

```
Command: Invoke-BluGenieYara -ItemToScan 'AllPids'
```

```
Description: Scan all PID using all found .Yar rules
Notes:
```

#### EXAMPLE 9 <a href="#example-9" id="example-9"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -UseCache
```

```
Description: Cache found objects to disk to not over tax Memory resources
Notes: By default the Cache location is %SystemDrive%\Windows\Temp
```

#### EXAMPLE 10 <a href="#example-10" id="example-10"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -UseCache -RemoveCache
```

```
Description: Remove Cache data
Notes: By default the Cache information is removed right before the data is returned to the caller
```

#### EXAMPLE 11 <a href="#example-11" id="example-11"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -UseCache -CachePath $Env:Temp
```

```
Description: Change the Cache path to the current users Temp directory
Notes: By default the Cache location is %SystemDrive%\Windows\Temp
```

#### EXAMPLE 12 <a href="#example-12" id="example-12"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -UseCache -ClearGarbageCollecting
```

```
Description: Scan large directories and limit the memory used to track data
Notes:
```

#### EXAMPLE 13 <a href="#example-13" id="example-13"></a>

```
Command: Invoke-BluGenieYara -Help
```

```
Description: Call Help Information
Notes: If Help / WalkThrough is setup as a parameter, this script will be called to setup the Dynamic Help Menu if not the normal
Get-Help will be called with the -Full parameter
```

#### EXAMPLE 14 <a href="#example-14" id="example-14"></a>

```
Command: Invoke-BluGenieYara -WalkThrough
```

```
Description: Call Help Information [2]
Notes: If Help / WalkThrough is setup as a parameter, this script will be called to setup the Dynamic Help Menu if not the normal
Get-Help will be called with the -Full parameter
```

#### EXAMPLE 15 <a href="#example-15" id="example-15"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -OutUnEscapedJSON
```

```
Description: Return a detailed function report in an UnEscaped JSON format
Notes:  The OutUnEscapedJSON is used to Beautify the JSON return and not Escape any Characters.  Normal return data is a Hash Table.
```

#### EXAMPLE 16 <a href="#example-16" id="example-16"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -OutYaml
```

```
Description: Return a detailed function report in YAML format
Notes:  The OutUnEscapedJSON is used to Beautify the JSON return and not Escape any Characters.  Normal return data is a Hash Table.
```

#### EXAMPLE 17 <a href="#example-17" id="example-17"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -ReturnObject
```

```
Description: Return Output as a Object
Notes:  The ReturnObject is used to return a PowerShell Object.  Normal return data is a Hash Table.
       This parameter is also used with the FormatView
```

#### EXAMPLE 18 <a href="#example-18" id="example-18"></a>

```
Command: Invoke-BluGenieYara -ItemToScan $env:TEMP -ReturnObject -FormatView Yaml
```

```
Description: Output PSObject information in Yaml format
Notes:  Current formats supported by default are ('Table','Custom','CustomModified','None','JSON','OutUnEscapedJSON','CSV', 'Yaml')
       Default is set to (None) and normal PSObject.
```

### PARAMETERS <a href="#parameters" id="parameters"></a>

#### ItemToScan <a href="#itemtoscan" id="itemtoscan"></a>

```
-ItemToScan <String[]>
   Description: File(s), Directory, PID, or AllPids Scan
   Notes:  If ItemToScan = "AllPids", every PID on the System will be scanned
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    1
   Default value                
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Rules <a href="#rules" id="rules"></a>

```
-Rules <String>
   Description: .Yar Rule Names (Filtered with RegEx)
   Notes:  Default is set to '.*'
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                .*
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### RulesSource <a href="#rulessource" id="rulessource"></a>

```
-RulesSource <String[]>
   Description: Source path to for your .Yar Rule files
   Notes:  Default Search Paths
   			* $Env:SystemDrive\Windows\Temp
   			* %Current Script Directory%
   			* $Env:Temp
   			This scan is not recursive.
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### CompiledRules <a href="#compiledrules" id="compiledrules"></a>

```
-CompiledRules [<SwitchParameter>]
   Description: Load compiled rules
   Notes:
   Alias: 'CR'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### ToolPath <a href="#toolpath" id="toolpath"></a>

```
-ToolPath <String>
   Description:
   Notes: Default is set to  $('{0}\Windows\Temp' -f $env:SystemDrive)
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                $(Join-Path -Path $ToolsDirectory -ChildPath 'Yara')
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Count <a href="#count" id="count"></a>

```
-Count [<SwitchParameter>]
   Description: Print only number of matches
   Notes:
   Alias: 'C'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Tag <a href="#tag" id="tag"></a>

```
-Tag <String>
   Description: Print only rules tagged as TAG
   Notes: tag=TAG
   Alias: 'T'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Identifier <a href="#identifier" id="identifier"></a>

```
-Identifier <String>
   Description: Print only rules named IDENTIFIER
   Notes: identifier=IDENTIFIER
   Alias: 'I'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Negate <a href="#negate" id="negate"></a>

```
-Negate [<SwitchParameter>]
   Description: Print only not satisfied rules (negate)
   Notes:
   Alias: 'N'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintTags <a href="#printtags" id="printtags"></a>

```
-PrintTags [<SwitchParameter>]
   Description: Print tags
   Notes:
   Alias: 'PT'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintMeta <a href="#printmeta" id="printmeta"></a>

```
-PrintMeta [<SwitchParameter>]
   Description: Print metadata
   Notes:
   Alias: 'PM'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### MaxStringsPerRule <a href="#maxstringsperrule" id="maxstringsperrule"></a>

```
-MaxStringsPerRule <Int32>
   Description: Set maximum number of strings per rule (default=10000)
   Notes:
   Alias: 'MS'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintStrings <a href="#printstrings" id="printstrings"></a>

```
-PrintStrings [<SwitchParameter>]
   Description: Print matching strings
   Notes:
   Alias: 'PS'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintStats <a href="#printstats" id="printstats"></a>

```
-PrintStats [<SwitchParameter>]
   Description: Print rules' statistics
   Notes:
   Alias: 'PA'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintNamespace <a href="#printnamespace" id="printnamespace"></a>

```
-PrintNamespace [<SwitchParameter>]
   Description: Print rules' namespace
   Notes:
   Alias: 'PN'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Threads <a href="#threads" id="threads"></a>

```
-Threads <Int32>
   Description: Use the specified NUMBER of threads to scan a directory
   Notes:
   Alias: 'TR'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### PrintStringLength <a href="#printstringlength" id="printstringlength"></a>

```
-PrintStringLength <Int32>
   Description: Print length of matched strings
   Notes:
   Alias: 'PL'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### MaxRules <a href="#maxrules" id="maxrules"></a>

```
-MaxRules <Int32>
   Description: Abort scanning after matching a NUMBER of rules
   Notes:
   Alias: 'M'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Timeout <a href="#timeout" id="timeout"></a>

```
-Timeout <Int32>
   Description: Abort scanning after the given number of SECONDS
   Notes:
   Alias: 'TO'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Recurse <a href="#recurse" id="recurse"></a>

```
-Recurse [<SwitchParameter>]
   Description: Recursively search directories (follows symlinks)
   Notes:
   Alias: 'R'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### FastScan <a href="#fastscan" id="fastscan"></a>

```
-FastScan [<SwitchParameter>]
   Description: Fast matching mode
   Notes:
   Alias: 'F'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### StasckSize <a href="#stascksize" id="stascksize"></a>

```
-StasckSize <Int32>
   Description: Set maximum stack size (default=16384)
   Notes:
   Alias: 'SS'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                0
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### FailOnWarnings <a href="#failonwarnings" id="failonwarnings"></a>

```
-FailOnWarnings [<SwitchParameter>]
   Description: Fail on warnings
   Notes:
   Alias: 'FW'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### NoWarnings <a href="#nowarnings" id="nowarnings"></a>

```
-NoWarnings [<SwitchParameter>]
   Description: Disable warnings
   Notes:
   Alias: 'NW'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Version <a href="#version" id="version"></a>

```
-Version [<SwitchParameter>]
   Description: Show version information
   Notes:
   Alias: 'V'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### CommandHelp <a href="#commandhelp" id="commandhelp"></a>

```
-CommandHelp [<SwitchParameter>]
   Description: Show the Yara command help
   Notes:
   Alias: 'CH'
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### ClearGarbageCollecting <a href="#cleargarbagecollecting" id="cleargarbagecollecting"></a>

```
-ClearGarbageCollecting [<SwitchParameter>]
   Description: Garbage Collection in Powershell to Speed up Scripts and help lower memory consumption
   Notes: This is enabled by default.  To disable use -ClearGarbageCollecting:$False
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### UseCache <a href="#usecache" id="usecache"></a>

```
-UseCache [<SwitchParameter>]
   Description: Cache found objects to disk.  This is to not over tax Memory resources with found artifacts
   Notes: By default the Cache location is %SystemDrive%\Windows\Temp
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### CachePath <a href="#cachepath" id="cachepath"></a>

```
-CachePath <String>
   Description: Path to store the Cache information
   Notes: By default the Cache location is %SystemDrive%\Windows\Temp
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                $('{0}\Windows\Temp\{1}.log' -f $env:SystemDrive, $(New-BluGenieUID))
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### RemoveCache <a href="#removecache" id="removecache"></a>

```
-RemoveCache [<SwitchParameter>]
   Description: Remove Cache data on completion
   Notes: Cache information is removed right before the data is returned to the calling process
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### DBName <a href="#dbname" id="dbname"></a>

```
-DBName <String>
   Description: Database Name (Without extention)
   Notes: The default name is set to 'BluGenie'
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                BluGenie
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### DBPath <a href="#dbpath" id="dbpath"></a>

```
-DBPath <String>
   Description: Path to either Save or Update the Database
   Notes: The default path is $('{0}\BluGenie' -f $env:ProgramFiles)  Example: C:\Program Files\BluGenie
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                $('{0}\BluGenie' -f $env:ProgramFiles)
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### UpdateDB <a href="#updatedb" id="updatedb"></a>

```
-UpdateDB [<SwitchParameter>]
   Description: Save return data to the Sqlite Database
   Notes:
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### ForceDBUpdate <a href="#forcedbupdate" id="forcedbupdate"></a>

```
-ForceDBUpdate [<SwitchParameter>]
   Description: Force an update of the return data to the Sqlite Database
   Notes: By default only new items are saved.  The primary key is ( FullName )
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### NewDBTable <a href="#newdbtable" id="newdbtable"></a>

```
-NewDBTable [<SwitchParameter>]
   Description: Delete and Recreate the Database Table
   Notes:
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Walkthrough <a href="#walkthrough" id="walkthrough"></a>

```
-Walkthrough [<SwitchParameter>]
   Description:  Start the dynamic help menu system to help walk through the current command and all of the parameters
   Notes:
   Alias: Help
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### ReturnObject <a href="#returnobject" id="returnobject"></a>

```
-ReturnObject [<SwitchParameter>]
   Description: Return information as an Object
   Notes: By default the data is returned as a Hash Table
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### OutUnEscapedJSON <a href="#outunescapedjson" id="outunescapedjson"></a>

```
-OutUnEscapedJSON [<SwitchParameter>]
   Description: Remove UnEsacped Char from the JSON information.
   Notes: This will beautify json and clean up the formatting.
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### OutYaml <a href="#outyaml" id="outyaml"></a>

```
-OutYaml [<SwitchParameter>]
   Description: Return detailed information in Yaml Format
   Notes: Only supported in Posh 3.0 and above
   Alias:
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### FormatView <a href="#formatview" id="formatview"></a>

```
-FormatView <String>
   Description: Automatically format the Return Object
   Notes: Yaml is only supported in Posh 3.0 and above
   Alias:
   ValidateSet: 'Table','Custom','CustomModified','None','JSON','OutUnEscapedJSON','CSV', 'Yaml'
   
   Required?                    false
   Position?                    named
   Default value                None
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### CommonParameters <a href="#commonparameters" id="commonparameters"></a>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
