Powershell command processed only with few paramaters

Hello,

i have made an fixlet, which creates a log file with Windows Services and its Name, DisplayName, State & StartMode. The problem is that if I try to run this action directly on the server via FixletManager its working fine, but when I run this fixlet from BigFix console, the output is generated, but State & StartMode columns are missing.

Any idea, what I did wrong?

action uses wow64 redirection {not x64 of operating system}
waithidden powershell -ExecutionPolicy Bypass -command "Get-WmiObject win32_service | Select Name, DisplayName, State, StartMode | Sort State, Name | Out-File "C:\temp\${{env:COMPUTERNAME}_Services_$(Get-Date -f yyyyMMdd-HHmm).txt"

Thank you

why dont you do this natively -

Q: (services, start type of it) of services

Thank you, I was not aware about this possibility. Anyway I need to log this output to some file, to have a record from concrete time, when it was executed.
How can I forward this output to some log file please?

I know its probably some easy task, but I’m not good in scripting and BF relevancies.

Thank you

delete "{pathname of parent folder of regapp “besclient.exe”}\Services.txt"
appendfile {concatenation “%0d%0a” of ((display name of it & " - ") & (state of it & " - ") & (start type of it)) of services}
move __appendfile “{pathname of parent folder of regapp “besclient.exe”}\Services.txt”

Hello,

thank you for help, but this action has failed:
Completed delete "C:\temp\Services.txt"
Failed appendfile {concatenation “%0d%0a” of ((display name of it & " - ") & (state of it & " - ") & (start type of it)) of services}
move __appendfile “C:\Itemp\Services.txt”

btw is there also any option to add time stamp to output log name (in this case Services.txt)?
I know that in such case It would be a problem to use delete function, but I wouldn’t need that.

Thank you

I still think this is better solved using an analysis then exporting the data from Web Reports, but if you need these individual text files on your endpoints you can try this slight variation of nick’s commands:

delete "{pathname of parent folder of regapp "besclient.exe"}\Services.txt"
appendfile {"Time Generated: " & now as string}
appendfile {(service name of it, display name of it, state of it, start type of it) of services}
move __appendfile "{pathname of parent folder of regapp "besclient.exe"}\Services.txt"

Note that when pasting code from here sometimes it uses the wrong quotation marks, so you might need to manually modify them.

1 Like

thank you josh, but it is not what I need

  1. I need timestamp in file name of the output log, not in its content (like COMPUTERNAME_Services_yyyyMMdd-HHmm).txt)
  2. with this command all the services and its state are in one line, so its bit mess

My original command with powershell is working well, I just don’t understand, why I cannot push it via BigFix with the same results…

I just ran your exact command four different ways (below) and all four achieved the same result, with all the data. I’m not sure what you’re doing that modifies the results.

  • PowerShell command prompt (64-bit)
  • PowerShell ISE (64-bit)
  • Fixlet Debugger - Action tab
  • BigFix Custom Action deployed from Console
1 Like

Try:

delete __appendfile
appendfile {concatenation "%0d%0a" of (it as string) of  (service name of it, display name of it, state of it, start type of it) of services}
move __appendfile "c:\temp\{computer name|"missingName"}_Services_{(((year of it as string&month of it as two digits&day_of_month of it as two digits) of current date) & "_" & ((last 2 of ("0" & hour_of_day of it as string) & last 2 of ("0" & Minute_of_hour of it as string)) of current time_of_day))}.txt"

Thanks a lot @brolly33, this is exactly what i was looking for :slight_smile:

PS: i was testing again my original fixlet with PS commands and it has really strange behavior - on some servers its working fine and on some servers State & StartMode columns are missing in the output file. Moreover these servers have the same OS and same version of PS.

I do wish that we had a simple format ability in relevance, similar to the powershell.
I was able to tighten up the Date/Time format portion a bit with Two Digit Hour and Two Digit Minute, but I think that is as tight as it gets.

delete __appendfile
appendfile {concatenation "%0d%0a" of (it as string) of  (service name of it, display name of it, state of it, start type of it) of services}
move __appendfile "c:\temp\{computer name|"missingName"}_Services_{(year of it as string & month of it as two digits & day_of_month of it as two digits) of current date & "_" & (two digit hour of it & two digit minute of it) of current time_of_day}.txt"
1 Like