TROUBLESHOOTING: Test PowerShell - Windows
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is the latest version.

1TROUBLESHOOTING: Test PowerShell - Windows4/8/2015 1:34:26 PM
2TROUBLESHOOTING: Test PowerShell - Windows4/8/2015 1:43:30 PM

Description

This task will test the execution of a powershell command through BigFix on the target system. The powershell version will be reported as the exit code of the action.

See a related analysis here:  http://bigfix.me/analysis/details/2994540

 


Property Details

ID5020
StatusBeta - Preliminary testing ready for more
TitleTROUBLESHOOTING: Test PowerShell - Windows
DomainBESC
SourceInternal
Source Release Date4/8/2015 12:00:00 AM
Added by on 4/8/2015 1:43:30 PM
Last Modified by on 4/8/2015 1:43:30 PM
Counters 9607 Views / 68 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

isWindows (Relevance 1172)
Used in 1129 fixlets and 533 analyses   * Results in a true/false
Show indented relevance
windows of operating system

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
delete C:\windows\temp\bigfix_test_powershell.txt

waithidden powershell -ExecutionPolicy Bypass -command "Get-Host | out-file C:\windows\temp\bigfix_test_powershell.txt"

continue if{ exists (it) whose(it as lowercase starts with "name") of (concatenation of characters whose (it != "%00") of it) whose(it as trimmed string != "") of lines of files "C:\windows\temp\bigfix_test_powershell.txt" }

// The exit code is the major version of powershell or -1 if it cannot find the version #
exit { (unique value of (it as integer) of preceding texts of firsts "." of (it as string) of pads of (it as trimmed string as version) of following texts of firsts ":" of (it) whose(it as lowercase starts with "version") of (concatenation of characters whose (it != "%00") of it) whose(it as trimmed string != "") of lines of files "C:\windows\temp\bigfix_test_powershell.txt") | -1 }
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!
jgstew -
please post on forum.bigfix.com to get help. CC me in the forum post with @jgstew and I'll see it.
fnketterman -
I have added our powershell script in the are indicated but it never completes creating the file. It is a complex powershell script. Below is the script. Any help would be appriciated. $Extensions = ".adn", ".accdb", ".accdr", ".accdt", ".accda", ".mdw", ".accde", ".mam", ".maq", ".mar", ".mat", ".maf", ".laccdb", ".ade", ".adp", ".mdb", ".cdb", ".mda", ".mdn", ".mdt", ".mdf", ".mde", ".ldb" $drives = Get-Volume | Where {$_.DriveLetter -and $_.FileSystem -eq "NTFS"} $Location = "C:\Program Files (x86)\BigFix Enterprise\BES Client" ForEach-Object{ Foreach($drive in $drives.DriveLetter){ Foreach($extension in $Extensions){ Get-ChildItem -path "$($drive):\" -Recurse -Filter "*$($extension)" -ErrorAction SilentlyContinue -Verbose | Where {$_.FullName -notlike "*\windows\*"} | Foreach-object { [pscustomobject]@{ Server = $env:COMPUTERNAME FileName = $_.name Path = $_.directoryname LastWriteTime = $_.lastwritetime } } } } } | select Server, FileName, Path, LastWriteTime | Format-Table -AutoSize | Out-File "$Location\founddb.txt" -Append #Remove blank lines from beginning of text file (gc "$Location\founddb.txt") | ? {$_.trim() -ne "" } | set-content "$Location\founddb.txt" -Force I should note that there is a __Createfile created as a text file, but only the first line is written in it. Thanks.
jgstew -
$psversiontable.psversion might be the better option anyway actually https://forum.bigfix.com/t/january-intel-meltdown-patches/24077/29
kjmccann1 -
To return the version directly as an exit code and without needing to write and read a text files: waithidden powershell -ExecutionPolicy Bypass -command "exit $psversiontable.psversion.Major.ToString()" parameter "psversion"="{if exist exit code of action then exit code of action as string else "-1"}" exit {parameter "psversion"}