How to Get File Name from Path in PowerShell?

Get File Name from Path in PowerShell

When working with file system operations in PowerShell, a common task that arises is extracting the file name from a given path. This can be particularly useful in scripting, where you need to manipulate files based on their names or extensions. PowerShell offers several ways to accomplish this, and in this blog post, we’ll explore … Read more

How to Move a File to a Folder in PowerShell?

Move a File to a Folder in PowerShell

There are multiple ways you can move a file to a folder in PowerShell. You can use Move-Item Cmdlet, Robocopy, etc., to move files in PowerShell to a folder. Let me show you quickly, how to move a file to a folder in PowerShell using the Move-Item cmdlet. To move a file to a folder … Read more

How to Get the Path of a File in PowerShell?

Get the Path of a File in PowerShell

Recently, while working with an automation script in PowerShell, I got a requirement to get the path of a file in PowerShell. There are various methods to get the path of a file in PowerShell. To get the path of a file in PowerShell, you can use the Get-Item cmdlet followed by the FullName property … Read more

How to Write Variables to a File in PowerShell? [6 Methods]

Write Variables to a File in PowerShell

Do you want to write variables to a PowerShell file? I will show you different methods to write variables to a file in PowerShell. To write a variable to a file in PowerShell, you can use the Out-File cmdlet, which is straightforward and effective for basic output needs. For example, $variable | Out-File -FilePath “C:\MyFolder\file.txt” … Read more

How to Remove Array Element by Index in PowerShell?

Remove Array Element by Index in PowerShell

Recently, I got a requirement to remove an array element by index in PowerShell. In this PowerShell tutorial, I will explain different ways to remove array elements by index in PowerShell. To remove an element by index in PowerShell, you can use the array slicing method to create a new array without the element. For … Read more

How to Copy Files from One Folder to Another in PowerShell?

Copy Files from One Folder to Another in PowerShell

Do you need to copy files from one folder to another folder? In PowerShell, it is easily possible. In this tutorial, I will show you how to copy files from one folder to another folder in PowerShell using various methods. To copy a file from one folder to another in PowerShell, you can use the … Read more

How to Write String to File in PowerShell: Tips and Tricks

Write String to File in PowerShell

Writing strings to files in PowerShell is a task you might perform regularly as a system administrator or a developer. In this PowerShell tutorial, we’ll explore how to write string to file using PowerShell using various methods and scenarios, including appending and overwriting content, avoiding newlines, and ensuring UTF-8 encoding. To write a string to … Read more

How to Find Strings in Files in PowerShell?

If you are working with strings in PowerShell, this tutorial will help you. In this PowerShell tutorial, we’ll explore various methods to find strings in files using PowerShell. To find a string in a file using PowerShell, you can use the Select-String cmdlet, which is similar to grep in Unix/Linux. For instance, Select-String -Path “C:\MyFolder\file.txt” … Read more

Connect-SPOService : Current site is not a tenant administration site

connect-sposervice current site is not a tenant administration site. error

I will show you a very simple solution to fix the error “connect-sposervice current site is not a tenant administration site“. I got this error while trying to connect to SharePoint Online using PowerShell. Current site is not a tenant administration site When I was trying the below PowerShell cmdlet to connect to SharePoint Online … Read more

PowerShell foreach where-object example

PowerShell foreach where-object

Do you want to iterate over collections and filter items based on certain conditions in PowerShell? In this PowerShell tutorial, I will explain how to use where-object in foreach in PowerShell. Finally, I will show you some examples related to “PowerShell foreach where-object“. To iterate over a collection and filter items in PowerShell, you can … Read more

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.