PowerShell Input & Output
HTML-код
- Опубликовано: 11 июл 2024
- Learn how to take in more dynamic PowerShell input and generate various types of PowerShell output. Take more control of your PowerShell Input & Output in this short video demo. See examples of how to prompt for user input, retrieve information from the web, and use PowerShell to get file content as your input. Wrap up with various demos on how to output to console and file.
Corresponding TechThoughts write-up:
www.techthoughts.info/powersh...
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
00:00 - Intro
00:27 - Dynamic input using native cmdlets
06:00 - Input using Read-Host
07:50 - Input from files using Get-Content
13:03 - Input from csv using Get-Content
14:18 - Output using Write-Host
16:52 - Output using Write-Output
18:12 - Output using Out-File
20:31 - Outro
Learn PowerShell - Episode 7 - PowerShell Input & Output
Reference PowerShell code examples from this episode:
github.com/techthoughts2/Lear...
Check out the complete Learn PowerShell RUclips Playlist:
• Learn PowerShell
~
/ jakemorrison
My recommended books for learning PowerShell:
(these affiliate links cost you nothing extra and help support this channel)
- Learn PowerShell in a Month of Lunches: amzn.to/3mlbizz
- Learn PowerShell Scripting in a Month of Lunches: amzn.to/3MtxJxe
- Windows PowerShell in Action: amzn.to/3xkjGp4
- PowerShell Cookbook: amzn.to/3tgCq6F
If you are able, and found this content valuable, please consider a secure donation in the link below. Your contribution helps offset the costs of producing this PowerShell series. Much appreciated!
www.paypal.com/cgi-bin/webscr...
Learn PowerShell online free in this operationally focused PowerShell series. These PowerShell tutorials are designed to get you ramped up and using PowerShell quickly. Each episode provides practical PowerShell examples for using PowerShell in the real world. Whether you are a PowerShell beginner or seeking advance PowerShell training, this Learn PowerShell series covers the topics you'll need to be effective with PowerShell!
These videos were recorded on a lot of my older equipment.
My newer videos use the following equipment:
- Camera: amzn.to/3MsjQPu
- Lens: amzn.to/3NrsKhJ
- Teleprompter: amzn.to/3monqQc
- Mic: Audio-Technica AT2035
- Mic Preamp: amzn.to/3tlOvY6
- Mic Arm: amzn.to/3NXJTiP
- Audio Interface: amzn.to/3xqPqJu
- Lighting: amzn.to/3O1Z2zR
- Rear color lighting: amzn.to/3H5MIMI
#learnPowerShell #PowerShell #PowerShelltraining #PowerShellTutorial Наука
This series is proof that treasure does exist on this planet 👏🏻
Learned a lot, truly great tutorial.
Honestly.. I watched Pluralsight course videos..and this playlist is 100x better than Pluralsight!
That means a lot!
Absolutely. RUclips does have some great teachers who explain way better than some $1000 paid courses.
The challenge is to find them out.
It's even tougher now that RUclips has removed the dislike counts.
Nice tutorial, thanks :)
Many thanks for giving code
Hi TechThoughts. Extremely grateful for your tutorials. How would i adjust the title length in '$posts | Select-Object Title,Score | Sort-Object Score -Descending'? Some of the reddit post lengths are way too lengthy. Thank you.
You can use Format-List instead:
$posts | Select-Object Title,Score | Sort-Object Score -Descending | Format-List
If you have to use Format-Table, it is unfortunately pretty tricky to define custom column widths for a table:
stackoverflow.com/questions/38554966/controlling-column-widths-with-format-table
How I wish the working files were at the github link to follow along.
while i was trying with this line $objData = $rawJSON | ConvertFrom-Json ... it is throwing below error ''Conversion from JSON failed with error: Unexpected character encountered while parsing value:
where can I get the Sample.log file
the font is too small
Thanks for the feedback. It looks like I didn't increase it on this lesson. I'll make sure that subsequent videos have a larger font.
@@Techthoughts2 Looks good on my 1440p monitor :)
I can retrieve only one object, I just copy-paste code from your site sill it is retrieving only one object
Please paste the code you are having issues with.
@@Techthoughts2
#retrieve dynamic content from a website
$webResults = Invoke-WebRequest -Uri 'reddit.com/r/powershell.json'
$rawJSON = $webResults.Content
$objData = $rawJSON | ConvertFrom-Json
$posts = $objData.data.children.data
$posts | Select-Object Title,Score | Sort-Object Score -Descending
I tried both Desktop and core edition but it returns only one object
I have verified that this code does indeed work as intended. Can you please indicate the error you are receiving? Can you clarify what you mean by only one object? You should only be receiving one object, the json payload. But, it can be drilled into to discover many sub properties containing content.
Font size is too small, can't see.....