In WSL2 Console, create /etc/wsl.conf with this contents: 1[user] 2default=username Then in powershell (administrator): 1wsl --shutdown Reopen terminal and make sure default user is now changed. Reference: https://superuser.com/questions/1566022/how-to-set-default-user-for-manually-installed-wsl-distro
Read MoreSometimes, you need to check the uptime of a Windows machine. Here's the Powershell command for that: 1PS C:\> systeminfo|find "System Boot Time" This was tested working under Windows 10 Pro and worth noting that it also works in the old cmd. For other methods, see this article.
Read MoreLinux systemcmd or init way of rebooting will not work in a Windows Subsystem for Linux or wsl-run Linux. You need to use the Powershell command below: 1wsl --shutdown For other methods, see this article.
Read MoreUsing the example in variable assignment And you want to do something to each variable, you may do the following: 1foreach ($i in $container_ids) { 2$i 3} So for instance, you want to delete all the containers: 1foreach ($i in $container_ids) { 2docker rm $i 3}
Read MoreFrom powershell CLI; 1$container_ids=docker ps -qa 2$container_ids In the command above, 1st line does the assignment. 2nd line prints the values. You will then have an output such as the following: 16fc00bc6a 2ba3c76ca3 3a9b4e46eb
Read More1PS C:\> [Environment]::Is64BitProcess 2PS C:\> [Environment]::Is64BitOperatingSystem both will return "True" if you're on a 64 bit Windows. See https://stackoverflow.com/questions/31977657/determining-32-64-bit-in-powershell
Read More1PS C:\> $env:COMPUTERNAME See https://blogs.technet.microsoft.com/heyscriptingguy/2015/06/20/powertip-use-powershell-to-get-computer-name/
Read More1PS C:\> Get-FileHash -Path $file -Algorithm MD5 See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash?view=powershell-6
Read More1PS /Users/example> $PSVersionTable 23Name Value 4---- ----- 5PSVersion 7.0.2 6PSEdition Core 7GitCommitId 7.0.2 8OS Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 9Platform Unix 10PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} 11PSRemotingProtocolVersion …
Read More1PS C:\> $env:PATH See https://blogs.technet.microsoft.com/heyscriptingguy/2011/07/23/use-powershell-to-modify-your-environmental-path/
Read More