The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for the ‘PowerShell’ Category

My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal – Scott Hanselman’s Blog

Posted by jpluimers on 2024/03/21

Via [Archive.is] Kevin on Twitter: “Gotta say this looks amazing and I actually didn’t know you can customize the command line on Windows this far. Read this blogpost by @shanselman , highly recommended. 👇 “

For my link archive: [Wayback] My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal – Scott Hanselman’s Blog

Read the rest of this entry »

Posted in CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows Development | Leave a Comment »

Forgot to blog: on Windows, use Certutil to Get File Hashes

Posted by jpluimers on 2023/10/19

I have had these two batch files on my system forever:

  • sha1.bat:
    :: https://superuser.com/questions/245775/is-there-a-built-in-checksum-utility-on-windows-7
    :: https://www.mcbsys.com/blog/2017/03/use-certutil-to-get-file-hash/
    :: Windows 7 has case sensitive Hash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512
    certUtil -hashfile %* SHA1
  • sha256.bat:
    :: https://superuser.com/questions/245775/is-there-a-built-in-checksum-utility-on-windows-7
    :: https://www.mcbsys.com/blog/2017/03/use-certutil-to-get-file-hash/
    :: Windows 7 has case sensitive Hash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512
    certUtil -hashfile %* SHA256

But I forgot to blog about [Wayback/Archive] Use Certutil to Get File Hash | MCB Systems mentioning:

on Windows 7, the hash algorithms are case-sensitive. Be sure to type, for example, “MD5”, not “md5”. On Windows 8.1 and 10, case doesn’t matter

I did mention the first link in “error: invalid object 100644” “git svn”, though only in a by-line. So thanks [Wayback/Archive] user64996 for asking and:

–jeroen

Posted in Batch-Files, CertUtil, Development, Power User, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Getting the Chocolatey shimgen generated shim target

Posted by jpluimers on 2023/10/10

For tomorrow’s post Ookla speedtest CLI for Windows has some undocumented arguments to accept license and GDPR I neede the full path to the speedtest.exe which I had installed using Chocolatey.

I know chocolatey uses a shim that redirects to the actual executable, so a simple where speedtest.exe would not cut it.

My guess would be that the generated shim allowed to either get the target pathname out, or have the target pathname encoded in it.

Luckily the first applies: a few of the shim command-line parameters are in [Wayback/Archive] Chocolatey Software Docs | Executable shimming (like symlinks but better):

You pass these arguments to an executable that is a shim (e.g. executables in the bin directory of your Chocolatey install, not choco.exe):

  • --shimgen-help – shows this help menu and exits without running the target
  • --shimgen-log – logging is shown on command line
  • --shimgen-waitforexit – explicitly tell the shim to wait for target to exit – useful when something is calling a gui and wanting to block – command line programs explicitly have waitforexit already set.
  • --shimgen-exit – explicitly tell the shim to exit immediately.
  • --shimgen-gui – explicitly behave as if the target is a GUI application. This is helpful in situations where the package did not have a proper .gui file.
  • --shimgen-usetargetworkingdirectory – set the working directory to the target path. Useful when programs need to be running from where they are located (usually indicates programs that have issues being run globally).
  • --shimgen-noop – Do not actually call the target. Useful to see what would happen if you ran the command.

But the below dumps show more more (using [Wayback/Archive] Strings – Windows Sysinternals | Microsoft Docs, [Wayback/Archive] clip | Microsoft Docs and post-processing in [Wayback/Archive] Notepad++).

Back to the second solution,

strings C:\ProgramData\chocolatey\bin\speedtest.exe | findstr speedtest.exe

showed

speedtest.exe
..\\lib\speedtest\tools\speedtest.exe
Cannot find file at '..\\lib\speedtest\tools\speedtest.exe' (
speedtest.exe
speedtest.exe

And towards the first,

strings C:\ProgramData\chocolatey\bin\speedtest.exe | clip

resulted in this fragment:

Read the rest of this entry »

Posted in Batch-Files, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Microsoft Store: update all apps from the command-line

Posted by jpluimers on 2023/09/12

TL;DR

I have converted the below PowerShell one-liner into this batch file (the ^| syntax is to ensure the pipe runs within PowerShell, not within the batch file):

PowerShell 'Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" ^| Invoke-CimMethod
 -MethodName UpdateScanMethod'

The why and how

Since I am a CLI person, and some Windows applications are only available on the Microsoft Store, I wanted to be able to initiate an update cycle from the command-line interface.

So I searched for [Wayback/Archive] microsoft store update all apps from the command-line – Google Search and found these to be valuable:

Read the rest of this entry »

Posted in Batch-Files, Development, Microsoft Store, Power User, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows 11 | Leave a Comment »

Seams I might in part be the cause of (#3186) Remove easter egg “You are smarter than the average bear …” by pauby · Pull Request #3276 · chocolatey/choco

Posted by jpluimers on 2023/09/11

Only having really learned to speak English starting in my late teens, I never got the “smarter than the average bear” reference, so I filed what I thought was a bug early 2019: [Wayback/Archive] “You must be smarter than the average bear…” after upgrading to 7zip.install v18.6 and notepadplusplus.install v7.6.2 · Issue #1700 · chocolatey/choco which last year got this useful comment

I had this for several packages now, since I am updating them daily.
I am assuming there is a way to remove versions, which leads to this error until there is a new update.

It was confirmed this summer from

I’m smarter than the average bear at least once or twice a month. I think it might be packages which are pulled back and you happen to have installed that version

The bug got referenced this summer from [Wayback/Archive] Remove warning message about “smarter than the average bear” · Issue #3186 · chocolatey/choco.

This in turn lead to [Wayback/Archive] (#3186) Remove easter egg “You are smarter than the average bear …” by pauby · Pull Request #3276 · chocolatey/choco

That made me realise that for large groups of English speaking people “smarter than the average bear” would actually be a well known thing.

So I searched and learned a thing or two:

Read the rest of this entry »

Posted in .NET, Chocolatey, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »