|
Thanks for the ideas. I'm phone posting so forgive me. What I need is an "on the fly" ad-hoc way of saying "I want to log to a custom CSV the command/script I'm about to execute". I don't have a need to log other stuff I run. Maybe I can figure out a way to retroactively parse history for the info?
|
# ? Apr 15, 2024 17:53 |
|
|
# ? Jun 9, 2024 06:15 |
|
Are you capturing the output of that script, or just that you ran the script? If the script outputs something, just set a variable to be the called script like so (the script just does get-date) code:
code:
Happiness Commando fucked around with this message at 21:07 on Apr 15, 2024 |
# ? Apr 15, 2024 20:58 |
|
Thanks for the idea! I learned something new with that Start-Transcript. It's a weird short-term thing that isn't totally necessary, just something that can save me a bit of manual data entry. I'm mainly poking at it to see if I can automate it. At this point I'm thinking I can add a comment (e.g. ##LogThis!) at the end of each relevant command execution, then write a simple script that parses History and finds those comments, writing those commands to a CSV along with their execution time.
|
# ? Apr 15, 2024 23:54 |
|
I'm still not seeing what exactly you're trying to accomplish. Do you need to submit some kind of report of when you do a specific task? In that case, I'd honestly just auto-start a transcript as part of your profile.ps1, then grab the relevant data whenever you need to submit the report. Combine that with a Posh theme that auto-timestamps your prompt and you're probably golden. If you're trying to capture specific output from a command/script, adding | export-csv -NoClobber (or -Append) -NoTypeInformation -Path '$path\command-{$get-date}.csv' or similar code directly into your script is probably the right way to go. Wizard of the Deep fucked around with this message at 09:24 on Apr 16, 2024 |
# ? Apr 16, 2024 00:20 |
|
Hughmoris posted:Thanks for the idea! I learned something new with that Start-Transcript. Is this potentially related to fulfilling some security thing (e.g. ACSC Essential Eight)? If so look at transcription/script block logging/module logging settings in Group Policy (Note you can enable these on a single machine via local Group Policy, aka gpedit.msc): https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_group_policy_settings?view=powershell-5.1 If you're looking to have a kind of running-log of your PowerShell session's execution history you could add a PSConsoleHostReadLine function to your Profile.ps1. There are various automatic variables that should allow you to pull out the relevant parts of what's about to be executed and write it to a file. Note that you can break your console with this if you do something like: code:
|
# ? Apr 23, 2024 14:27 |
|
Wizard of the Deep posted:I'm still not seeing what exactly you're trying to accomplish. Do you need to submit some kind of report of when you do a specific task? In that case, I'd honestly just auto-start a transcript as part of your profile.ps1, then grab the relevant data whenever you need to submit the report. Combine that with a Posh theme that auto-timestamps your prompt and you're probably golden. Pile Of Garbage posted:Is this potentially related to fulfilling some security thing (e.g. ACSC Essential Eight)? If so look at transcription/script block logging/module logging settings in Group Policy (Note you can enable these on a single machine via local Group Policy, aka gpedit.msc): https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_group_policy_settings?view=powershell-5.1 Thanks for the ideas. I was attending an informal training session where certain actions needed to be logged for review. I ended up just keying in ,or copy/pasting, what was needed. I have learned more about the transcripts and profiles after reading up on your suggestions.
|
# ? Apr 23, 2024 17:57 |
|
I've been tasked to get some daily orders from a web site. Because they won't send the orders to an email address without clicking a link (logging in) and downloading the file (good security), I am attempting to use PS and its New-WebServiceProxy to connect and request the previous days' sales and then combine it with a report with order details (concatenating/merging) as a csv file. I'm not worried about that, I'm doing that quite a bit already (thanks to you here that helped me a couple years ago). The site has ColdFusion / SOAP and I can get "in" with credentials, within PS, but I don't know how to use the Web service proxy object and build commands that return results. Do I need to pass a big <Body>...</Body> blob, envelope. Other (older) method is Invoke-WebRequest but trying to stick to NWS-Proxy. I can get-members and methods, but I it's my lack of knowledge of building a SOAP request that I think is tripping me up. I have only found a couple web sites that show simplistic namespace class (which apparently isn't necessary), examples - like calculator. Thanks MS -> https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-webserviceproxy?view=powershell-5.1 Also, I'm not having luck trying things out in the SoapUI that I am using on a 14 day trial. I will admit, I haven't done much with xml/json API / GET / POST stuff in the past, and that's hindering me now. The URI for the Orders is: https://webservices.vin65.com/V301/OrderService.cfc?wsdl If anybody could point me to a site (or a book) that shows SOAP w/ Powershell wrapping or something similar - thank you. I'm surprised there's not more on this just searching Google for the last 30 minutes. Or if anyone could rough out a simple example on how I would construct a request to return all of the previous days orders from the complexType name="Order" namespace or SearchOrders schema...(check the url above) - that would be super helpful. Thanks Goons, in advance.
|
# ? May 18, 2024 00:48 |
|
I wouldn't use powershell for this, there are purpose built libraries in Python or C#
|
# ? May 18, 2024 01:05 |
|
That could also be a job for PHP but everyone hates PHP nowadays
|
# ? May 18, 2024 01:31 |
|
PHP is actually fine these days, but it took a hard reputation hit and never really recovered
|
# ? May 18, 2024 01:41 |
|
|
# ? Jun 9, 2024 06:15 |
|
The Fool posted:I wouldn't use powershell for this, there are purpose built libraries in Python or C# I can do it in Python I suppose. Probably the most versatile solution. Djimi fucked around with this message at 07:46 on May 19, 2024 |
# ? May 19, 2024 07:44 |