![]() ![]() ![]() In the second case you can write: (GPS AcroRd32).countīecause a collection has a count property. One thing you need to know is that in PowerShell generally, and particulary in CmdLets you manipulate objects or collection of objects.Įxample: if only one 'AcroRd32' is running Get-Process will return a, if more than one are running it will return a collection of. To put it another way, I want to avoid turning into a Cargo Cult Programmer/ Code Monkey. If I'm supposed to use Dot Notation, then I will, but I'd like to take this opportunity to learn more about how and *why PowerShell works this way, rather than just building a perfunctory understanding of PowerShell's syntax. So, why does Dot Notation ( $a.count) work, but not an explicitly written statement ( GPS | Measure -Property Count)? The following provides me the information I need, except it doesn't provide me with an integer to perform operations on, as you'll see: PS C:\Users\Me> $a = GPS AcroRd32 | Measure If Count is the default, then shouldn't an explicit pass of Count work? GPS AcroRd32 | Measure -Property Count # Fails The default is the Count (Length) property of the object. ![]() The second example returns this: Measure-Object : Property "Count" cannot be found in any object(s) input. The first example returns a value of 2, which is what I want, an integer. Work, when GPS AcroRd32 | Measure -Property Count ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |