The best case scenario in my opinion of using variables is to leverage objects. I know some of the users prefer text only, but objects carry much more information, that can be logged or leveraged. Here is an example:
Having computer’s name vs and object with multiple properties.
The 3 last lines are are magic…
Having the same data in the variable and then manipulating them to give you what you want so that the data is applicable and even passed to more commands.
So lets say there is another propery or point of interest that needs to be associated with the computer and user….
Can you do that with text and then create a fancy excel sheet? maybe if you want to have panic attacks about deadlines. It is all about the objects of desire lol.
Lets add a serial number:
Lets get Dynamic like a duo (no Microsoft pun) with dynamic Data
This object is now dynamic and can be used to extrapolate data inside of a remote script, report, or function.
Brain Check… share your real world applications of create dynamic and static objects.
If you cannot think of any then use the code to inventory your home PCs. Don’t forget to add the serial number:
Don’t Forget to select the properties you need or expand them to just get the inside of the object.
Want to learn what is selectable with any object? Indicate the object and pipe it to get-member.
Get-CimInstance Win32_bios | get-member