Working With PowerShell Variables

  Рет қаралды 38,364

TechThoughts

TechThoughts

Күн бұрын

Learn how to use and work with PowerShell variables. See different PowerShell variable types, and how to identify them. Learn how to get a list of PowerShell constant and environment variables. I'll demo how to strongly type variables, and how different types of quotes can impact PowerShell variable use. Finish this lesson off with an easy how to example that demos PowerShell use in the real world!
Corresponding TechThoughts write-up:
www.techthoughts.info/working...
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
00:00 - Intro
00:22 - Basic variable use
03:33 - Typed variables in PowerShell
05:41 - PowerShell DataType example
07:16 - Strongly typing variables
08:14 - Converting data types
09:45 - Using quotes in PowerShell
12:38 - Reserved PowerShell variables
15:15 - Final Example
18:42 - Outro
Learn PowerShell - Episode 5 - Working With PowerShell Variables
Reference PowerShell code examples from this episode:
github.com/techthoughts2/Lear...
Check out the complete Learn PowerShell KZfaq 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

Пікірлер: 31
@BeccaTheBoring
@BeccaTheBoring Жыл бұрын
Thanks! I started watching to refresh my 15 year old training. Wasn’t expecting to find a new editor I actually like! ISE really wasn’t cutting it and I absolutely hate PyCharm! Thank you!
@sanghvian
@sanghvian 3 жыл бұрын
This series is literally the best thing I've binged. Thanks so so SO much for such amazing videos and powerful documentation !!
@user-zj1go7wn9i
@user-zj1go7wn9i 4 ай бұрын
Thank you that was awesome...
@amritarongpipi2617
@amritarongpipi2617 3 жыл бұрын
This tutorial is best ever with the combinations of video and blog.
@Chris-tu8qd
@Chris-tu8qd 4 жыл бұрын
These videos are fantastic! Great job. You're a very skilled instructor.
@kd_john8200
@kd_john8200 4 жыл бұрын
This is one of the best explanation of PowerShell variables videos I have ever seen. Keep up the good work!
@budcarr8673
@budcarr8673 8 ай бұрын
Gr8 video !
@DrWho2008t101
@DrWho2008t101 3 жыл бұрын
thanks for the video.
@pseudounknow5559
@pseudounknow5559 2 жыл бұрын
Thats a very good video
@BijouBakson
@BijouBakson 2 жыл бұрын
Thank you.
@muhammadsajid2676
@muhammadsajid2676 3 жыл бұрын
Thanks for the video. :-)
@Techthoughts2
@Techthoughts2 3 жыл бұрын
Welcome!
@sawyerclendening8430
@sawyerclendening8430 4 жыл бұрын
Awesome videos! I am trying to learn PowerShell to further my new IT career but I have 0 coding experience, so I do get little lost in the terminology of things like whats a string and how can I tell it apart in. But that's nothing little google can't help me with!
@aloisodipo8459
@aloisodipo8459 Жыл бұрын
The topics are good so far,but need to increase the fonts of the video for more visibility when using a phone.
@TotalWarriorLegends
@TotalWarriorLegends 4 жыл бұрын
Are you also make an video how to begin with scripting and what are the basics and what is importent?
@Techthoughts2
@Techthoughts2 4 жыл бұрын
Yes. This series has many episodes, and one is dedicated to scripting. Check out the whole playlist: kzfaq.info/sun/PL2j0_s2VJe2hzQuQyn6yfMS2olhhs4UnQ
@mbahr6322
@mbahr6322 Жыл бұрын
Hi, can you please tell me the answer for the below question Which variable cannot be modified by the administrator? A)user created B)automatic C) preference D)pre-defined
@chris8534
@chris8534 3 жыл бұрын
Hmmm.....if you put get-process into the variable so it only had to be loaded into memory once - true that is more efficient but won't that data in that variable go more and more out of date over time as the data is a snapshot of that command?
@betenu1
@betenu1 4 жыл бұрын
Wouldn't be easier to pipe all the commands into one variable? I'm referring to the filedata example
@ashisharya65
@ashisharya65 Жыл бұрын
What's the VS code extension you are using ?
@dalefirmin5118
@dalefirmin5118 Жыл бұрын
It should be repeated that, unlike other programming languages, cmdlets and variables are NOT case sensitive. So $rawfiledata and $rawFileData are the same. And although other special characters can be used, "best practices" is to only use the underscore.
@Johannes00
@Johannes00 3 жыл бұрын
$foo = 1..5 $foo 1, 2, 3, 4, 5 $bar = $foo -ge 2 $bar 2, 3, 4, 5 $bar = $bar -le 4 $bar 2, 3, 4 I'm very new to powershell and I don't know how to improve this with the pipeline but I'd like to use compound comparisons / conditionals? Tried doing $bar = ($foo -ge 2) -and ($foo -le 4), but this obviously returned a boolean which is not what I want. Goal is to check a list of ordered numbers and clamp the output, in this case, only greater than 1 and less than 5.
@Techthoughts2
@Techthoughts2 3 жыл бұрын
Let me know if this makes sense. There are many, many ways to do this. $foo = 1..5 $bar = @() $foo | ForEach-Object { if ($_ -gt 1 -and $_ -lt 5) { $bar += $_ } }
@Johannes00
@Johannes00 3 жыл бұрын
@@Techthoughts2 That's a Here-String function, I think? You're piping $foo into the ForEach-Object, and the $_ is an automatic variable? So, ForEach variable passed into this, check if it's gt 1 AND lt 5, and if it is add it to $bar? Learnt a lot from that example, thanks! -Edit, I found out @() is an empty array, whoops! Makes more sense to me. I don't quite understand the difference between lists and arrays yet, especially when it comes to using the pipeline. If I want to learn more ways of doing this, what else should I look up?
@isaacmaag1294
@isaacmaag1294 2 жыл бұрын
A little confused with the beginning... Around 3:34 you said that It was so much more conveinent to use $processes when that is just as long as get-process... You still had to run two commands and type out the pipe plus the commands and so each example the time didn't change? Your first two commands were the same amount of time as the second two? Seems a little confusing.
@Techthoughts2
@Techthoughts2 2 жыл бұрын
Its more convenient when your doing a lot of stuff with the data capture. When you run a command like the following: Get-Process ^ This is just a moment in time and you get the raw object return. If you want to sort the data a different way, you have to run Get-Process again if you only wanted info on one particular process, you have to run Get-Process again if you just wanted memory information, you have to run Get-Process again This is very expensive (Get-Process has to be run EACH TIME). Alternatively, you can run Get-Process once and then work with the data as much as you want: $processes = Get-Process $processes | Where-object {$_.Name -eq "notepad.exe"} $processes | Where-object {$_.CPU -gt 1000} $processes | Sort-Object WorkingSet64 -Descending $processes | Sort-Object -Descending CPU
@DElionel1995
@DElionel1995 4 жыл бұрын
Where do you explain arrey's?
@Techthoughts2
@Techthoughts2 4 жыл бұрын
Hi Lionel, I haven't gone in depth with Arrays in the series yet. In the meantime here is a great post that covers everything you would want to know: powershellexplained.com/2018-10-15-Powershell-arrays-Everything-you-wanted-to-know/
@marialainapreciado5677
@marialainapreciado5677 2 жыл бұрын
Honestly this video lost me at the very beginning. What is Get-Process? Why are you using it? Do you have to type Get-Process before using a variable?
@TheM0n
@TheM0n Жыл бұрын
Taking Control with PowerShell Logic
27:57
TechThoughts
Рет қаралды 27 М.
PowerShell Functions
36:06
TechThoughts
Рет қаралды 42 М.
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 52 МЛН
🌊Насколько Глубокий Океан ? #shorts
00:42
Learn and use PowerShell with just three commands
16:08
TechThoughts
Рет қаралды 54 М.
Windows PowerShell [04] Variables, Types & PSDrives
19:36
John Hammond
Рет қаралды 39 М.
PowerShell Variables Explained
14:38
Shane Young
Рет қаралды 31 М.
PowerShell Input & Output
20:53
TechThoughts
Рет қаралды 24 М.
Working with the PowerShell Pipeline
15:17
TechThoughts
Рет қаралды 88 М.
5 Tips to Help You Learn Windows PowerShell
18:34
Gary Explains
Рет қаралды 40 М.
PowerShell Modules
25:01
TechThoughts
Рет қаралды 12 М.
PowerShell Errors and Exceptions Handling
27:49
TechThoughts
Рет қаралды 29 М.
Understanding the $PSItem ($_)  Variable in PowerShell
5:18
PowerShell Engineer
Рет қаралды 988
GamePad İle Bisiklet Yönetmek #shorts
0:26
Osman Kabadayı
Рет қаралды 107 М.
Asus  VivoBook Винда за 8 часов!
1:00
Sergey Delaisy
Рет қаралды 1,2 МЛН