How to Get File Modified Date in PowerShell?

Get File Modified Date in PowerShell

If you want to know how to get file modified date in PowerShell, check out this tutorial completely. In this blog post, we will explore various methods to retrieve file modification dates using PowerShell. To get the file modified date in PowerShell, you can use the Get-Item cmdlet followed by the LastWriteTime property. For example, … Read more

How to Encrypt a File with a Password in PowerShell?

Do you want to know how to encrypt a file in PowerShell using password? In this tutorial, we’ll explore different methods to encrypt a file with a password in PowerShell. This way, you can secure your files with password protection using PowerShell. To encrypt a file with a password in PowerShell, you can utilize the … Read more

How to Rename Files with Date in PowerShell?

Rename Files with Date in PowerShell

Recently, I got a requirement to rename a file by appending the current date in PowerShell. I tried different methods, and in this PowerShell tutorial, I will explain to you how to rename files with date in PowerShell using various methods. To rename a file in PowerShell and append the current date, you can use … Read more

How to Count Files in a Folder Using PowerShell?

Count Files in a Folder Using PowerShell

You might encounter situations where you need to count the number of files present in a folder using PowerShell. In this tutorial, I will explain how to count files in a folder using PowerShell. To count files in a folder using PowerShell, you can use the Get-ChildItem cmdlet combined with the Measure-Object cmdlet. For example, … Read more

How to Get File Details and File Version in PowerShell

Get details of a file in PowerShell

To get the details of a file in PowerShell, use Get-Item with the file path. It returns the name, size, dates and attributes, and Format-List shows them one per line: Output: Length is the size in bytes. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1, and they returned the same results. Read … Read more

How to Get File Creation Date in PowerShell?

Get File Creation Date in PowerShell

When managing files on a Windows system, you might often need to know when a file was created. In this PowerShell tutorial, we’ll explore various methods to get the file creation date using PowerShell with various examples. To get the file creation date in PowerShell, you can use the Get-Item cmdlet followed by accessing the CreationTime property of the … Read more

How to Check If a File or Folder Is Empty in PowerShell

Check if a file or folder is empty in PowerShell

To check if a file is empty in PowerShell, get the file with Get-Item and test whether its Length is 0. Length is the file’s size in bytes: Output: Folders need a different test, which I cover further down. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1 against the same sample folder, … Read more

How to Split Large Text Files with PowerShell?

Split Large Text Files with PowerShell

When working with large text files, it can be necessary to split them into smaller files. This is a common requirement while working with log files. PowerShell provides different commands and methods to divide these types of large files. In this tutorial, we’ll explore different methods to split large text files using PowerShell. To split … Read more

How to Create a Password-Protected Zip File Using PowerShell?

Create a Password-Protected Zip File Using PowerShell

Recently, one of my clients asked me to create an encrypted zip file. I tried PowerShell. In this PowerShell tutorial, I will show you how to create a password-protected zip file using PowerShell. To create a password-protected zip file in PowerShell, you can use the Compress-Archive cmdlet combined with a third-party tool like 7-Zip. Here’s an example … Read more

How to Convert Files to Base64 in PowerShell

Convert files to Base64 in PowerShell

To convert a file to Base64 in PowerShell, read its bytes with [System.IO.File]::ReadAllBytes and pass them to [System.Convert]::ToBase64String: It works the same in PowerShell 7 and 5.1. Below I encode and decode a sample file, fix the -Encoding Byte error, stream large files and compare certutil. Encode a file to Base64 Here I encode a … Read more