News, tips, advice, support for Windows, Office, PCs & more
Home icon Home icon Home icon Email icon RSS icon

We're community supported and proud of it!

  • Updated: CMsLocalPCInfoW10.ps1

    Home Forums Developers, developers, developers DevOps Lounge Updated: CMsLocalPCInfoW10.ps1

    Tagged: 

    Viewing 17 reply threads
    • Author
      Posts
      • #2254001
        RetiredGeek
        AskWoody MVP

        Hey Y’all,

        Well I’ve been bashing code again, can’t do much else these days, and I’ve got a new version of my PC Information program.

        Thanks to Rick Corbett for testing and many fine suggestions!

        What’s new:

        • Works on both PS 5 & 7 w/o throwing errors, at least in my testing.
        • Second level tab interface to make information easier to access.
        • Additional information reported. Including the MS-DefCon level! (Except on PS7 where a documented bug (Invoke-WebRequest) keeps it from returning the necessary information)
        • Run time is reported on the title bar and in the printout. Timed from start of program until menu display.

        Enjoy!

        CMsLocalPCInfoW10-V5-11
        .zip MD5 Hash: 5AF24441616843871A4B7FCF577D9638
        .ps1 MD5 Hash: 44DA33790D0DC71656BD7C675C1FFEE3

        😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        2 users thanked author for this post.
      • #2254176
        joep517
        AskWoody MVP

        Just tried this script on my Surface Pro 3 running Insider build 19608. Running in PS Admin window – Go the message about investigating the PC. Then PS window closed. Nothing else hapened.

        --Joe

      • #2254336
        RetiredGeek
        AskWoody MVP

        Joe,

        Did you run the install routine?Β  [d:\path\]CMsLocalPCInfoW10.ps1 -Setup

        Were you running from the ISE or CMD PS Window?

        If not the ISE try running from there as it will keep the error messages if any.

        Thanks for testing!

        RG 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2254389
        RetiredGeek
        AskWoody MVP

        Joe,

        I dug out my Insider laptop and gave it a go and the program runs!
        PCInfov5-11-Insider
        However, there are problems.
        You’ll note from the title bar that I was running as an Admin. However, if you look down at the Last Boot & Up Time entries it says it requires Administrative Access?

        Here’s the culprit:

          $GWEArgs =
               @{ProviderName = 'Microsoft-Windows-Kernel-Boot'
                 MaxEvents    = 100
                 ErrorAction  = 'Stop'}
          $FilterID = "27"
        
            $Events = Get-WinEvent @GWEArgs
            $Events = $Events |
               Where-Object {$_.id -like "$FilterID"} |
               Select-Object -First 1
        
        #If next stmt errors increase MaxEvents above!
            $LastBootupTime = $Events.TimeCreated
        
        ------------------------------------------------------
        
        Get-WinEvent : The system cannot find the file specified
        At line:7 char:15
        +     $Events = Get-WinEvent @GWEArgs
        +               ~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : NotSpecified: (:) [Get-WinEvent], EventLogNotFou 
           ndException
            + FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogNotFo 
           undException,Microsoft.PowerShell.Commands.GetWinEventCommand
         
        The variable '$Events' cannot be retrieved because it has not been set.
        At line:8 char:15
        +     $Events = $Events |
        +               ~~~~~~~
            + CategoryInfo          : InvalidOperation: (Events:String) [], RuntimeExc 
           eption
            + FullyQualifiedErrorId : VariableIsUndefined
         
        The variable '$Events' cannot be retrieved because it has not been set.
        At line:13 char:23
        +     $LastBootupTime = $Events.TimeCreated
        +                       ~~~~~~~
            + CategoryInfo          : InvalidOperation: (Events:String) [], RuntimeExc 
           eption
            + FullyQualifiedErrorId : VariableIsUndefined
         
        
        

        Seems like the Insider Edition is having a problem with the Get-WinEvent cmdlet.
        This cmdlet runs just fine on all my regular Win 10 machines
        ————————————
        Edition: Windows 10 Pro 64-bit
        Version: 1909
        Build: 18363.720
        ————————————
        Edition: Windows 10 Pro 64-bit (1 Desktop Win Pro & 1 Laptop Win Pro 1 Laptop Win Home)
        Version: 1909
        Build: 18363.778
        ————————————

        I guess that’s why it’s an insider edition! 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2254413
        joep517
        AskWoody MVP

        Got it to run in ISE but got this error:

        Cannot index into a null array.
        At C:\Users\Joe\Utilities\CMsPowerShell\CMsLocalPCInfoW10.ps1:4162 char:7
        + If ($Events[0].ID -eq 27) {
        + ~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArray

        Guess that is why it crashes in PS

        --Joe

      • #2254415
        joep517
        AskWoody MVP

        Which Insider build? I’m running 19608. Going to 19613 as I write this.

        --Joe

        • #2254510
          RetiredGeek
          AskWoody MVP

          Joe,

          19608…it shows on the screen shot in post #2254389

          May the Forces of good computing be with you!

          RG

          PowerShell & VBA Rule!
          Computer Specs

      • #2254526
        joep517
        AskWoody MVP

        Here’s what I see with build 19613

        Oops. Wrong tab. Ignore this. Run with ISE. Still won’t run with PS.

        --Joe

        • This reply was modified 1 year, 1 month ago by joep517.
        • This reply was modified 1 year, 1 month ago by joep517.
        • #2254556
          Rick Corbett
          AskWoody_MVP

          Joe, the error on line 4162 is related to boot time and boot method (i.e. cold boot, hybrid boot or resume from hibernation) which should display on the Windows 10 > General tab.

          So, for example, my test laptop shows (when run from an *elevated* PowerShell commandline prompt):

          rg-cmsinfo-v5-1

          Perhaps try a clean shutdown/restart?

          • This reply was modified 1 year, 1 month ago by Rick Corbett.
          • This reply was modified 1 year, 1 month ago by Rick Corbett.
          • This reply was modified 1 year, 1 month ago by Rick Corbett.
      • #2254743
        joep517
        AskWoody MVP

        With the latest Insider build 19613 I don’t get the error in ISE. It runs fine in ISE running as Admin. I can’t get it to run just using PS.

        --Joe

      • #2254888
        RetiredGeek
        AskWoody MVP

        Ok Y’all,

        Here’s the next iteration.

        Change Log:

        • I found a couple of problems running as User and fixed that.
        • Split the Registry/Services tab into two sub tabs.
        • Fixed the Install-Program function to use a variable for the program name vs hard coded, it didn’t pick up the change when I added the W10 to the end of the name. I also changed the code so that if you setup it up from PS7 (Core) it will call PS7, previously always called Ps5 (Windows). Each Task & shortcut name indicates which version of PS it calls so you can have both!TaskSch-CMsLocalPCInfoW10
          Icons-CMsLocalPCinfoW10
        • Squashed some of the blank lines in the output. However PS5 & PS7 act differently thus you’ll see more blank lines in the PS5 version than the PS7 version.

        CMsLocalPCInfoW10-V5-12.zip:Β  CMsLocalPCInfoW10-v5-12
        .zip MD5 Hash: 72119A72DD1F77E5FB137657640C7DD3
        .ps1 MD5 Hash: 35BF77741EBCE86F41AA6FFA1690614D

        Currently downloading the latest Insider version and will test as soon as it is installed.

        Thanks for all your testing efforts!

        HTH 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2254960
        RetiredGeek
        AskWoody MVP

        Joe,

        I just tested on Windows Insider version 2004 Build 19613.1000.

        The program ran successfully on both PowerShell V5 & V7. I ran the install (-setup) procedure from both PS5 & 7 and used the Icons created to run the program. I then also opened the both PS5 & 7 cmd windows as admin and manually typed in the program path and again both ran as expected.

        😎

         

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2257019
        joep517
        AskWoody MVP

        Bruce,

        I just installed PS7. The script ran in PS7 but still fails in PS 5.1. Used Run As Admin for both. It runs ok in 5.1 PS ISE. Tried again in X86 PS 5.1 and still fails.

        --Joe

      • #2257142
        joep517
        AskWoody MVP

        I do not see any error. From the reliability history I see:

        Source
        Console Window Host

        Summary
        Stopped working

        Date
        β€Ž4/β€Ž28/β€Ž2020 1:17 PM

        Status
        Report sent

        Description
        Faulting Application Path: C:\Windows\System32\conhost.exe

        Problem signature
        Problem Event Name: APPCRASH
        Application Name: conhost.exe
        Application Version: 10.0.19613.1000
        Application Timestamp: 0e08a624
        Fault Module Name: ntdll.dll
        Fault Module Version: 10.0.19613.1000
        Fault Module Timestamp: 5d81f9fc
        Exception Code: c0000005
        Exception Offset: 000000000005fd95
        OS Version: 10.0.19613.2.0.0.256.48
        Locale ID: 1033
        Additional Information 1: a97f
        Additional Information 2: a97f4522445799741ac773c11129c13f
        Additional Information 3: db38
        Additional Information 4: db38741ef13e5e58bedac3e2b3c4ea9c

        Extra information about the problem
        Bucket ID: d955732109c98cf27ae0b8d4ed91710a (1936751064427622666)

        --Joe

      • #2257214
        RetiredGeek
        AskWoody MVP

        Joe,

        Since you’re running an Insider version and you’re not getting any PowerShell errors in the command window I’d say you have an OS problem.

        I run it on my laptop with windows insider version 2004 Build 19613.1000 and PowerShellΒ  5.1.19613.000 w/o problems. I’ve attached my sanitized output file so you can see fully what I am running.

        CMsLocalPCInfo output: CMsLocalPCInfoW10-v5.12-Using-PS-v5-as-of-20200428-for-BRUCESLT1564

        HTH 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2257248
        RetiredGeek
        AskWoody MVP

        Hey Y’all,

        New wrinkle with Insider Editions. The Invoke-WebRequest cmdlet now not only doesn’t work in PS7 but also PS5! This must be internal to Windows vs PowerShell.

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2258148
        RetiredGeek
        AskWoody MVP

        Hey Y’all,

        Here’s version 5.13 with a progress bar and a couple minor tweaks.

        2258149: CMsLocalPCInfoW10V5-13
        .zip MD5 Hash: F60692A7D6231351308AF7752EC418BF
        .ps1 MD5 Hash: CD2ECAD0631CE24582C7F77840CF98C9

        HTH 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2258225
        joep517
        AskWoody MVP

        Bruce,

        I am now running 19619. Still the same results. Now, with PS 5.1 the progress bar gets to 1% but crashes without error before the next update. The next update goes to 7% running PS7 or PS 5.1 ISE. Must be some permission on my PC. I sure don’t have a clue though.

        --Joe

      • #2258248
        Rick Corbett
        AskWoody_MVP

        RG, surely trying to keep up with Insider issues is just a waste of your time compared to coding for stable versions?

      • #2258280
        joep517
        AskWoody MVP

        Rick,

        In general I agree about not coding for Insider builds nut this has been going on for quite a long time. Bruce does not seem to have a problem with the same builds that fail for me. I suppose some setting or permission is mis-configured.I don’t have any problem with daily use and this is my primary PC.

        --Joe

    Viewing 17 reply threads

    Please follow the -Lounge Rules- no personal attacks, no swearing, no politics or religion.

    Reply To: Updated: CMsLocalPCInfoW10.ps1

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.