Category Archives: Powershell Basics

PowerShell pause

PowerShell pause – how can you pause a PowerShell script? Two ways come to mind. First if you just want the script to pause for a specified time period then you can use Start-Sleep 1..10 | foreach {   $PSItem   if … Continue reading

Posted in Powershell Basics | 3 Comments

PowerShell for loop

Loops are a construction seen in most scripting and programming languages. A loop is used to repeat a set of statements a set number of times or until a specific criterion is met or while a specific criterion is true. … Continue reading

Posted in Powershell Basics | Leave a comment

Create a directory

PowerShell enables you to work with the file system on your machine – one question that often comes up is how to create a directory. When working interactively you can use md PS> md c:\testf1      Directory: C:\ Mode                LastWriteTime         … Continue reading

Posted in Powershell Basics | Leave a comment

PowerShell foreach

PowerShell has a number of ways to perform a loop – I recently counted seven distinct methods. If you can’t list them all don’t worry one is very esoteric and unexpected. I’ll enumerate them in a future post. For now … Continue reading

Posted in Powershell Basics | 2 Comments

Passing parameters to a script block

Passing parameters to a scriptblock seems to be an issue at the moment. Consider a simple scriptblock Invoke-Command -ScriptBlock {Get-Process} How can you modify that to parameterise the processes that are returned. Its a two step process. Add a parameter … Continue reading

Posted in Powershell Basics | 1 Comment

Modifying AD users in bulk

Modifying AD users in bulk involves either setting one or more properties to the same value for a set of users or reading in the values you need from a data source of some kind. We prepared some test data … Continue reading

Posted in PowerShell and Active Directory, Powershell Basics | Leave a comment

Test data for bulk AD changes

I’ve had a number of questions about changing AD user data in bulk. If you need to do that you need some test data. The specific questions were around setting the Division property and the EmployeeNumber at the same time … Continue reading

Posted in PowerShell and Active Directory, Powershell Basics | Leave a comment