ShortCut Keys in VSCode:
Auto-adjust indent
Shift+Alt+F (Win)
Shift+Option+F (Mac)
Annotating
Ctrl+/ (Win)
HashCode
Description:
To get the specific file’s SHA256 automaticallySyntax
Get-FileHash <Path> | fl Get-FileHash <Path> -Algorithm <SHA256/MD5/…>
More info: Microsoft-Get-FileHash
TryCatch
Description:
Make sure the script can output log.Syntax
$ErrorMessage = $_.Exception.Message $FailIedItem = $_.Exception.ItemName $StackTrace = $_.Exception.StackTrace Write-Host "Error: $ErrorMessage "
- Example[Output]
Error Message : Cannot find path ‘C:\Program Files’ because it does not exist.
Failed Item : C:\Program FilesMore info: Microsoft-about_Try_Catch_Finally
Split-Path
Description:
To get the file name in the file’s path.Syntax
Split-Path -Path <Path> -Leaf
- Example[Output]
Pass1.log
Pass2.logMore info: Microsoft-Split-Path
Start-process(Msiexec.exe)
Description:
To start one or more processes on the local computer.Example[Command]
Start-Process -PassThru -Wait MsiExec.exe -ArgumentList "/i $mPar /qn REBOOT=Suppress"
- Example[Output]
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 0 2 432 1852 0.00 45952 1 msiexec
- Syntax
Start-Process MsiExec.exe -ArgumentList <Arg> -Wait -PassThru
-PassThru is a parameter that returns an object that contains information about the new process
-Wait is a parameter that waits for the new process to finish before continuing execution.
- <arg>Normal Parameters
- /i is an option that installs a Windows Installer package.
- /X is an option that unintalls a Windows Installer package.
- /qn is an option that display no user interface during the installation process.
- REBOOT=Suppress is a property that prevents the computer from restarting after the installation completes.
More info: Microsoft-MsiExec
More info: Microsoft-Start-Process