- 1 year ago
Use native tar PowerShell cmdlet on Windows Sever 2016
The tar
command is not available as a native PowerShell cmdlet in Windows Server 2016. However, you can use the tar
command-line utility provided by various third-party software packages like 7-Zip or GnuWin32.
Here are the steps to use the tar
command from 7-Zip in PowerShell:
Install 7-Zip: Download and install 7-Zip from the official website (https://www.7-zip.org/) if you haven't already done so.
Add 7-Zip to the system's PATH: Ensure that the directory where 7-Zip is installed (e.g., "C:\Program Files\7-Zip") is added to the system's PATH environment variable. This will allow PowerShell to locate the
7z.exe
executable.Run the
tar
command: In PowerShell, you can use the&
operator to invoke the7z.exe
executable and pass the appropriate arguments to perform the desired tar operation. Here's an example to extract a tar archive:powershell& 'C:\Program Files\7-Zip\7z.exe' x -o"C:\ExtractedFiles" "C:\Path\to\archive.tar"
In the above example, replace
"C:\Program Files\7-Zip\7z.exe"
with the correct path to the7z.exe
executable on your system,"C:\ExtractedFiles"
with the desired output directory for the extracted files, and"C:\Path\to\archive.tar"
with the path to the tar archive you want to extract.
With these steps, you can utilize the tar
functionality provided by 7-Zip or similar third-party tools within PowerShell on Windows Server 2016.