This is post #519 https://excelfox.com/forum/showthrea...ge52#post12794
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page52#post12794
Process Manager
This is a bit late in the winter for me to be still posting stuff here, and perhaps a bit off-topic, ( actually as it went on, maybe not so off-topic.. )
By chance I stumbled on a short YouTube play list: https://www.youtube.com/watch?v=Qh_s...qYMCmHkbEIiver
Initially I saw it as a nice well explained PowerShell GUI series to help my recently acquired PowerShell GUI knowledge. But then as I got more into understanding the second video, ( Process Manager - https://www.youtube.com/watch?v=GQSQ...EIiver&index=2 ) , I suddenly realised that there might be some application to some of my Debloat script ideas.
I wont take this much further until much later in the year, but these notes are just intended to remind me of what I learnt to the workings of the script, in particular the Process Manager. I am basically working through, and doing a walkthrough explanation of, the script given : https://pastebin.com/b5VMrmz7
_.___________
Some basic script coding of relevance/ differences to VBA
Basic concepts: . and | ( “dot” and “pipe/Piping” )
I think if you know VBA then you can fairly easily pick up PowerShell.
There is a similar object orientated hierarchical idea which you get through a . , and that is pretty well the same as in VBA.
But then there is a similar concept in parallel, a piping, | , which works a bit as its name suggests in that you filter or select/modify things as you go along the pipe sections: Think of it as pipes of different dimensions and / or pipes that filter or use or present the stuff flowing in different ways. The | separates the different sections. Some of the things going on in these stream like piping concepts sections are similar to SQL stuff
For Each Looping
In VBA this idea can be shown approximately in this pseudo coding:
__For Each Thing In theCollectionOfThings
___' This section is automatically looped for as many times as we have things, and each thing is put in the variable, Thing. We sometimes refer to Thing as the steering variable, and would need to be of type Variable or Object
___ Thing.doingstuff
___ Let SomethingElse = Thing.Something
__Next Thing
In PowerShell script we can approximately say that we have two ways to do this,
_ the first is like that in VBA , but just the syntax looks slightly different.
_ the second way is a bit more weird and needs us to introduce something completely new, which is usually used in conjunction with the looping: This - $_. ( That - $_ could also be used in the first way, but so far I have not seen it used there)
PowerShell Way1:-
Same idea , different syntax
__ For Each ( $Thing In $theCollectionOfThings ) {
___# This section works similarly to the VBA case ( In PowerShell script all variable names tart with a $ )
___ $Thing.doingstuff
___ $SomethingElse = $Thing.Something
__}
PowerShellWay2 ( Way2a) and way2b) ):-
This usually comes about during the piping of stuff, and it is less obvious that a loop happens. But is does. The difficulty in grasping this possibly comes about because the piping idea suggest that lots of things simultaneously are flowing. That can’t really happen., and they are really flowing one after the other, all be it so fast that to us they all are flowing in parallel simultaneously. I think perhaps the development and background low level stuff works so efficiency that it can be considered as if they all are flowing in parallel simultaneously. But as they are in fact looping, we can take advantage of this and “sneak in” a doing something loop. I suppose another way of thinking about this is that we have the ability to customise the filtering/selecting/modifying things going on in the Pipe sections.
This way 2 is somewhat tricky to understand because, as I write this I have seen two ways to do it, so I am looking at Way2a) and way 2b). But there might be more ways I have not set yet.
I will demo the two ways I have seen so far with pseudo script/coding examples. I might come back and add here later, if I come across more ways
Way2a)
_SomeThingsInThePipe | where { $_.Name –noteegaulto “Fred” } | hgIUdh………….
In that script/code snippet we have effectively looped to remove thee things that had the name of “Fred”
In that script/code snippet we have used for the first time the strange , $_ , which is the new PowerShell thing
This is used to access the current thing or object in the looping process.
So it is approximately equal to the Thing or $Thing in the previous examples:
Approximately
____________Thing = $Thing = $_
( Note: This Way2a) may be a debatable one. It suggest to me it’s a For-Each thing. Mostly it’s not indicated as such by others. Possibly the Where thing is an old SQL thing, and not generally regarded as a thing that loops. I am not sure: The use of the $_ suggested to me that we are in a loop)
Way2b)
In the last example, the use of where, may have indicated to PowerShell that we are wanting to do something in a loop to the things “passing in the pipe”.
We can also more explicitly indicate that we want to loop the things “passing in the pipe”. This then resembles the VBA and First PowerShell examples:
_SomeThingsInThePipe | ForEach ( {
___ $_.doingstuff
___ $SomethingElse = $_.Something
__ } )
I expect there is some inter changeability in using alternative ways, which I may come back to demonstrating later.
For now, with the gained knowledge I will go back to the script walkthrough and expanded explanations.




Reply With Quote
Bookmarks