PowerShell Archive

PowerShell Comparison Operators

PowerShell comparison operators allow you to find out if the value of a variable contains a string, is it larger, smaller, or equal to some value, etc. Most programming languages use symbols as comparison operators, like <, >, !=, =, however, in PowerShell, pseudo-commands are used instead of these

PowerShell: Script for Loop through Files and Folders

In this article, we will look at examples of using constructions to loop over all files and folders on a disk or in a specific directory that you can widely use in your PowerShell scripts. Usually, the task of iterating over all file system objects in a directory arises

PowerShell: Function Return

Most PowerShell newbies believe that PowerShell functions can return a value only through the Return statement. The return statement usually terminates the function and returns control to the calling function. But in Windows PowerShell, this is not entirely true… In this article, we will look at how to return

PowerShell Function Parameters: How to Add?

When developing your PowerShell functions, sometimes you need to put some input values to your functions, such as a file name, string, or any other value. In PowerShell, there are two ways to pass parameters to functions: through the $Args variable and by setting formal parameters. Passing Parameters to

Using GPUpdate to Update Group Policy Settings

After changing any Group Policy setting using the local GPO editor (gpedit.msc) or domain policy editor (gpmc.msc), the new policy setting is not immediately applied to the user/computer. You can wait for automatic updating of GPO (up to 90 minutes), or you can update and apply policies manually using

Using WhatIf Parameter in PowerShell

The -WhatIf parameter in PowerShell scripts is typically used to avoid accidental changes to managed objects. Adding the -WhatIf parameter to the PowerShell command will display the objects to be changed by this command and the changes made. At the same time, no changes are actually made. For example,

PowerShell: Switch Statement Usage

Usually, an if-else construct is used to test conditions in PowerShell scripts. If you need to immediately check several conditions instead of doing complex constructions with if-else, it is much easier to use the switch statement. The syntax of the construction with the Switch operator is looks like follow:

How to Run PowerShell Script on Remote Computer?

The functionality of remote command execution in PowerShell is called PowerShell Remoting (appeared in PowerShell 2.0) and is based on the capabilities of the Web Services for Management protocol (WS-Management). With PowerShell Remoting, you can run commands on one or several remote computers. You can use the interactive session

Viewing Office 365 User Account Details Using Get-MsolUser

In this article we’ll show you how to get a various information about Office 365 user accounts using the Get-MsolUser PowerShell cmdlet. The Get-MsolUser cmdlet allows you to view the properties of one or several Office 365 accounts, this is an analogue of the Get-ADUser cmdlet for on-premises Active

Changing Local and Active Directory User Password Using PowerShell

The administrator can change the password of the local users on the computer using the Local Users and Groups (lusrmgr.msc) graphic snap-in. To change the password of an AD domain user, the Active Directory Users and Computer (ADUC) GUI console is mainly used. However, in some cases, the administrator