Ramon TAN

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 138 total)
  • Author
    Posts
  • in reply to: Powershell 7 is missing Get-Wmiobject #211881
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    My sincere thanks Olaf …

    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    My sincerest thanks to all for their very educational and informative advice.  As a beginner to PS I have found this forum to be an extremely valuable source of useful knowledge.  The answers I have been getting such as the ones from this recent post remind me of some advice I read somewhere in the past — let Powershell do the work.  Indeed, my (foreach / if ) approach says I am still in need of help from experts like you  … thanks again !

    in reply to: How do I “merge” these 3 hash tables? #206886
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you Mr Boutros.  I have studied your answer carefully.  It opens up a lot of new PS knowledge to me, personally, in fundamentals and more advanced techniques that I’m still learning.  Luckily (in desperation), I also found a blog that seems to have solved my problem.  It used an alternative to GetEnumerator():

    foreach ($mk in $ht1.Keys) {
    
    $ht1.Item($mk) + $delim + $ht2.Item($mk) + $delim + $ht3.Item($mk) } 

    seems to work.  My sincerest gratitude for your insightful solution.  Best.

     

    in reply to: Update-help error message #178428
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you Joel.  I tried it and it worked perfectly, much appreciated.

    in reply to: Can Regex return the starting position of a match? #153705
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you everyone for your very creative, informative and educational insights.

    Yes, I am guilty of taking short cuts in describing/stating my problem.  My sincere apologies.

    When I listed the array $test = @(Book1 …) I was trying to be sufficiently brief to give the reader a good idea of what the data looks like, with the 3 dots to mean “and so on”.  Yes, next time I will be more precise.

    I am very thankful you have all taken the efforts to share your PowerShell knowledge;  for a beginner like me, these replies have been the best source of learning PowerShell.

    in reply to: Update-help in VS Code/pwsh.exe doesn't seem to work #152849
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks, Postanote … much appreciated.

    in reply to: How do I include this field into Out-gridview #151700
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Yes, Mr KVPrasoon … I’m glad you sensitized me to this aspect of the impact of Out-gridview during processing.  Indeed, it can become disruptive.  What I typically do is insert Out-gridview at “key points” when I am still developing the script, and then comment it out when “final”.

    My sincerest thanks for your continuing advice and assistance, and generous sharing of technical knowledge.

    in reply to: Does OleDB work under Powershell Core? #151497
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks, much appreciated.

    in reply to: Does OleDB work under Powershell Core? #151461
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks Mr KVprasoon … I am wondering how one discovers these facts about whether or not a particular product or software component is already certified to work — or even if it is in the works.  It took me a while to get ACE/OleDb (and the MADE2010 Redistributable of Microsoft) to work for Powershell 5.1/ISE … now we have to move again to PS Core.  Is it safe to assume that .Net Core will be the “preferred” or “recommended” .NET when using PS Core?  In any case, my sincerest gratitude to you for this tip.  Best,

    in reply to: How do I display a Grand-Total of Grouped-totals? #147030
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thanks again.  There’s actually a typo in my last post, the last line should read

    $Grouped += [pscustomobject]@{Name="Grand total";SumTotal=$GTotal.sum}

    and not “Dept”.

    in reply to: How do I display a Grand-Total of Grouped-totals? #146841
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor
    $Grouped = $data | Group-object -property Dept |
            ForEach-object {
                $Sum = $_.group |
                Measure-object -Sum -Property Amount
                [pscustomobject]@{ Dept = $_.Name; SumTotal = $Sum.Sum }
            }
    $GTotal = $Grouped | Select-object -Expandproperty SumTotal | Measure-object -Sum
    $Grouped | Add-member -Membertype NoteProperty -Name "Grand total" -Value $GTotal.sum

    will produce:

    Dept SumTotal Grand total
    ---- -------- -----------
    ABC  20       110
    DEF  40       110
    XYZ  50       110

    Instead of Add-member, I utilized Mr Boutros’ solution and replaced the last line with:

    $Grouped += [pscustomobject]@{Dept="Grand total";SumTotal=$GTotal.sum}

    which produces:

    Dept SumTotal
    ---- --------
    ABC  20
    DEF  40
    XYZ  50
    Grand total 110
    

    I struggled but could not get Add-member to output the last line the way it should.
    Thanks to you both, Messrs Sam Boutros and KVprasson, this was an eye-opener and very educational.

    in reply to: How do I display a Grand-Total of Grouped-totals? #146561
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thanks Mr kvprasoon, when I do the Add-Member, what -Membertype will I use?  I am guessing this would have to be a ScriptProperty.  Thanks,

    in reply to: How do I display a Grand-Total of Grouped-totals? #146540
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thanks a lot Mr Sam Boutros, much appreciated!

    in reply to: Getting all the EXCEL enums #146337
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Much thanks, Mr KVprasoon … for a very enlightening reply. Yes, I was not aware of .Name or .Fullname. In my early efforts to figure this out, I piped to Get-Member (GM) the result of

    $x1.GetType().Assembly.GetExportedTypes()

    and just stopped there. Please let me share my “trial and error” efforts before my post. In order to “figure out” my dilemma I first did the ff:

    # -- this yields Selected.System.RuntimeType
    $x1.GetType().Assembly.GetExportedTypes() | GM

    to see what’s “available”. In hindsight maybe the correct “line of thinking” should have been:

    # -- this yields Microsoft.PowerShell.Commands.MemberDefinition
    $x1.GetType().Assembly.GetExportedTypes() | GM | GM

    In both cases there is a Name property, but which one is the logically correct? Is my “logic” (or lack of it) consistent within PowerShell’s way of operation?
    Thanking you in advance.

    in reply to: Am getting blanks for this line of code, why? #146237
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Much thanks, Olaf, JS and Joel — I made that mistake before!

    I cannot thank you enough for all of your comments and tips.

    They provide many insights to the fundamentals of using Powershell and reinforce my learning progress.

    More power to you all.

Viewing 15 posts - 16 through 30 (of 138 total)