• 27 November

    Print Environment Variables in PowerShell

    💡TL;DR To print environment variables in PowerShell, use Get-ChildItem cmdlet as below: [crayon-662ddaf9b3b03226357809/] Environment variables store values used by the operating system and installed programs. For instance, the environment variable PATH contains a list of directories to search for executable files. Some other environment variables in the Windows operating system are OS, APPDATA, COMPUTERNAME, USERNAME, […]

  • 23 November

    Get File Size in KB, MB, GB in PowerShell

    💡 TL;DR To Get File Size in KB, MB, GB in PowerShell, use Get-Item cmdlet to get the file at specified location and use length property on the file to get the file size. Divide file size by 1 KB, 1 MB and 1 GB to get the file size in KB, MB, GB respectively. […]

  • 18 November

    Replace String in Multiple Files in PowerShell

    💡 TL;DR To replace String in multiple files, use Get-ChildItem to get all the required files and iterate over the files using ForEach-Object. In each iteration, read the file content using Get-Content cmdlet, use replace() method to replace text and Set-Content to save the content in the files. Here is simple example: Let’s say, you […]

  • 18 November

    Replace Space with Comma in PowerShell

    💡 TL;DR To replace space with comma in PowerShell, you can use String’s replace() method or PowerShell’s replace operator. Here is simple example: [crayon-662ddaf9bcb8f692990458/] There are multiple ways to replace Space with Underscore in PowerShell. Let’s go through them. Using String’s replace() method Use string’s replace() method to replace space with comma in PowerShell. Replace […]

  • 18 November

    Replace Space with Underscore in PowerShell

    💡 TL;DR To replace space with underscore in PowerShell, use String’s replace() method or PowerShell’s replace operator. Here is simple example: [crayon-662ddaf9bd51d726386937/] There are multiple ways to replace Space with Underscore in PowerShell. Let’s go through them. Using String’s replace() method You can use string’s replace() method to replace space with underscore in PowerShell. Replace […]

  • 06 November

    Get Filename without Extension in PowerShell

    💡 Quick Answer You can get filename without extension in PowerShell using BaseName property with Get-Item cmdlet. [crayon-662ddaf9c19e1559639119/] Output: [crayon-662ddaf9c19ed060894787/] While working on a Windows operating system, you may often encounter the requirement of getting filename without extension. For example: FileName : C:\temp\sample.txt FileName without extension: sample In this post, we will see various ways […]