Want to automate simple tasks & discovered PowerShell. Your intro video is EXCELLENT...really a great overview, well-organized, and gave me a LOT of information in a short time. Thank you!
Great videos! I love the simplicity in explaining concepts! I've watched other videos on Databricks from you, Bryan and they are all wonderful in explaining concepts really well! Thank you!
Hi Bryan, thank you for sharing your knowledge! Could you elaborate on the efficiency gains part with ForEach vs ForEach-Object? I am still having a difficult time understanding when one is better than the other, and what the actual differences are behind the scenes.
Hi Tucker, My main point is that the alias foreach which translates to foreach-object only gets invoked when you pipe into the command. When you write the code as a loop over a collection, it does not translate using the alias which is very odd. Example code is: Get-ChildItem | foreach { "Value is $_" } Get-ChildItem | foreach-object { "Value is $_" } $myarray = Dir foreach ($val in $myarray) { "Value is $val " } foreach-Object ($val in $myarray) { "Value is $val " } Notice the the last statement fails but the prior one does not. In the first statement, foreach is translated to foreach-object due to the alias but the second to last statement is not translated. Why? I don't know. Kind of looks like a bug. So word of caution. As for performance, piping data through a command should perform better and require less memory because you don't need to store and hold the data, i.e. you are streaming it. When you loop over a collection the collection is all in memory. If you wanted to process a large file for example, the piping approach should scale better.
Beautifully efficient. Thanks! One note about line 28 in your script: Perhaps this is regional, but I've always understood the tilde to be this: ~ while this ` is a backtick. Am I mistaken?
Want to automate simple tasks & discovered PowerShell. Your intro video is EXCELLENT...really a great overview, well-organized, and gave me a LOT of information in a short time. Thank you!
YW. Glad it helped.
Bryan is very easy to understand. I think this is best place to start learning about PowerShell.
Bryan, thanks so much for these videos. You're my virtual mentor. - Al
Glad they help.
Thanks Bryan. Great introductory videos. More please.
Great videos! I love the simplicity in explaining concepts! I've watched other videos on Databricks from you, Bryan and they are all wonderful in explaining concepts really well! Thank you!
Thanks!
Thank you from Trinidad and Tobago!
powershell newbie here: this is by far the most helpful video i have seen so far (i have used my entire week off watching PS vids lol) thank you!
Great way to spend the week. :-) Glad you found this useful.
Your videos are really awesome, and I learned a lot form it. Thank you very much.
Thanks.
Great video Bryan, keep it up! I liked the foreach explanation, I never realised this.
Thanks David. I just did another that covers all the looping structures in detail.
Hi Bryan, thank you for sharing your knowledge! Could you elaborate on the efficiency gains part with ForEach vs ForEach-Object? I am still having a difficult time understanding when one is better than the other, and what the actual differences are behind the scenes.
Hi Tucker, My main point is that the alias foreach which translates to foreach-object only gets invoked when you pipe into the command. When you write the code as a loop over a collection, it does not translate using the alias which is very odd. Example code is:
Get-ChildItem | foreach { "Value is $_" }
Get-ChildItem | foreach-object { "Value is $_" }
$myarray = Dir
foreach ($val in $myarray)
{ "Value is $val " }
foreach-Object ($val in $myarray)
{ "Value is $val " }
Notice the the last statement fails but the prior one does not. In the first statement, foreach is translated to foreach-object due to the alias but the second to last statement is not translated. Why? I don't know. Kind of looks like a bug. So word of caution.
As for performance, piping data through a command should perform better and require less memory because you don't need to store and hold the data, i.e. you are streaming it. When you loop over a collection the collection is all in memory. If you wanted to process a large file for example, the piping approach should scale better.
Beautifully efficient. Thanks! One note about line 28 in your script: Perhaps this is regional, but I've always understood the tilde to be this: ~ while this ` is a backtick. Am I mistaken?
Good point! Yes. You are correct. Did not realize I missed that. Thanks!
Wonderful!! Thanks! Great Job!!