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 2,975 other subscribers

Archive for September 9th, 2021

Some links to post about ESXi 6 and ESXi 7 storage and storage speed issues

Posted by jpluimers on 2021/09/09

For my link archive (most via [Wayback] sata very slow after ESXi 6.7 update – Google Search):

Two takeaways already:

–jeroen

Posted in ESXi6, ESXi6.5, ESXi6.7, ESXi7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

PowerShell: recovering from corrupt empty *.nupkg files after a disk was accidentally full during update

Posted by jpluimers on 2021/09/09

When you do a choco upgrade all --yes on a system that – during upgrade – becomes low on disk space, you can end up with a lot of empty .nupkg files.

For those package, Chocolatey will not recognise they are installed any more.

The fix is this:

  1. increase disk space so at least 5 gigabytes is free
  2. split the choco upgrade process so it checks before each upgrade that this diskspace is indeed free
  3. list all choco .nupkg files of length zero ordered from oldest to newest
  4. for each package, delete the .nupkg file if it exists, then force install it with the --force parameter before the --yes parameter like in

    choco install --force --yes chocolatey

  5. when all packages have been done, then choco upgrade --all --yes

I wrote a few PowerShell scripts assisting me in cleaning up the mess.

choco-list-installed.bat

:: https://superuser.com/questions/890251/how-to-list-chocolatey-packages-already-installed-and-newer-version-available-fr
choco list --localonly %*

choco-show-installed-package-names.bat

:: `--limit-output`  does not show Chocolatey version header and count footer.
:: `--id-oonly`      omits the version number, so you only get the package name
choco list --local-only --limit-output --id-only

choco-show-installed-package-names-and-versions.bat

:: `--limit-output`  does not show Chocolatey version header and count footer.
choco list --local-only --limit-output %*

choco-reinstall-empty-nupkg-by-names.ps1

  • [WayBack] Powershell – Finding 0-byte Files | Another computer blog
  • [WayBack] windows – Where is the Chocolatey installation path? – Stack Overflow:

    There is an environment variable set on installation, ChocolateyInstall, which is set to C:\Chocolatey by default in versions of Chocolatey less than 0.9.8.27. After that, this defaults to C:\ProgramData\Chocolatey.

    NOTE: By default, the C:\ProgramData folder on Windows is hidden. You will either need to enable hidden files and folders through Folder Options | View or you can navigate directly to the path shown above by copy/pasting directly into the Windows Explorer address bar.

    In version 0.9.9 of Chocolatey, it actively moves from the old folder location to the new one.

  • [WayBack] string – Powershell concatenate an Environment variable with path – Stack Overflow

    A convenient way to obtain the string value rather than the dictionary entry (which is technically what Get-ChildItem is accessing) is to just use the variable syntax: $Env:USERPROFILE rather than Get-ChildItem Env:USERPROFILE.

    $localpath = "$env:USERPROFILE\some\path"

    Also, the Join-Path cmdlet is a good way to combine two parts of a path.

    $localpath = Join-Path $env:USERPROFILE 'some\path'
<#
https://learningpcs.blogspot.com/2009/12/powershell-finding-0-byte-files.html

Zero length .nupkg files sorted by oldest first.

These are packages that choco will not show and likekly need a forced reinstall.

Choco does remember the version that was installed (so not all the choco config is hosed).

- https://stackoverflow.com/questions/28235388/where-is-the-chocolatey-installation-path/28239451#28239451
- https://stackoverflow.com/questions/41047123/powershell-concatenate-an-environment-variable-with-path/41047343#41047343

/#>
$LibPath = Join-Path $env:ChocolateyInstall 'lib'
$NuPkgExtension = 'nupkg'
$NupkgFilter = "*.$NuPkgExtension"

## Remove the empty .nupkg files for each argument
$args | ForEach-Object {
    $PackageName = $_ 
    Write-Output "Deleting any empty $PackageName.$NuPkgExtension under $LibPath :"

    Get-ChildItem -Path $LibPath -Recurse -Filter $NupkgFilter | Where-Object {
        ($_.Length -eq 0) -and ($_.BaseName -eq $PackageName)
    } | Sort-Object LastWriteTime | ForEach-Object { 
        $PackageFullName = $_.FullName
        Write-Output "Deleting $PackageFullName"
        Remove-Item $PackageFullName
    }
}

## Force install the chocolatey package for each argument
$args | ForEach-Object {
    $PackageName = $_ 
    Write-Output "Installing $PackageName with Chocolatey:"
    choco install --force --yes $PackageName
}

Link lists

Some more links that helped me solve this:

Some links on errors I encountered while recovering from this:

–jeroen

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

Opening shell folders from the command-prompt

Posted by jpluimers on 2021/09/09

I knew I could run shell:startup and similar shortcuts from the Explorer address bar or the Windows-R “run” prompt.

First I learned that via [WayBack] tablet РHow to set Google Chrome to automatically open up and in full screen РSuper User.

Then via [WayBack] “shell:startup” – Google Search, I¬†found [WayBack] Location of the Startup folder in Windows 10.

It took a while before I realised you can also run them from the command-prompt, batch-files or PowerShell scripts prepending them with start:

start shell:startup

That one will open a new explorer window in the user startup folder from either the command-prompt, a batch file or PowerShell script..

The shell: shortcuts can contain spaces. So for instance there is shell:common startup that opens the common startup folder.

Starting it from the command prompt, batch file or PowerShell script is different: because of the spaces you will get the error on the right unless you add double quotes:

start "shell:common statartup"

All shell: commands that you can run in the same way: double quotes work for both the ones requiring spaces and the simple ones nor requiring spaces.

Virtually each new Windows version (even most Windows 10 major builds) gets new shell: commands.

A good source with an up-to-date and historically accurate of shell: commands list is at [WayBack] Shell Commands to Access the Special Folders in Windows 10/8/7/Vista/XP ¬Ľ Winhelponline,

You can get the current list by recursively enumerating the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions registry key, which consists of a list of Explorer folder GUIDs having Name, ParentFolder and RelativePath value names.

–jeroen

Read the rest of this entry »

Posted in Batch-Files, Console (command prompt window), Development, Power User, Scripting, Software Development, Windows | Leave a Comment »

 
%d bloggers like this: