Tags » Powershell-basics

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. 402 more words

PowerShell And Active Directory

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 – but some accounts didn’t have an employee number. 223 more words

PowerShell And Active Directory

Get-Content and Numbers

A common technique is to put a list of information into a text file and read that using Get-Content. The information is often server names. This works great when the data is strings but breaks down if you’re dealing with numbers. 268 more words

Powershell Basics

Filtering of Objects and Properties

Saw a post on the forum today that suggests people are still confused about how to perform filtering of objects and properties in PowerShell.

As with so much in PowerShell explanations are always better with examples. 352 more words

Powershell Basics

Append data to a file

A question on the forums – the user wanted to append data to a file. This is a common scenario when you’re creating a log file. 191 more words

Powershell Basics

Preserving property order

This is a very common pattern:

$os = Get-CimInstance -ClassName Win32_OperatingSystem 
$comp = Get-CimInstance -ClassName Win32_ComputerSystem

$props = @{
  OS = $os.Caption
  InstallDate = $os.InstallDate
  LastBoot = $os.LastBootUpTime
  Make = $comp.Manufacturer
  Model = $comp.Model

New-Object -TypeName PSObject -Property $props… 130 more words
Powershell Basics

Calculating Standard Deviation – the class

You’ve seen how to calculate standard deviation and how to turn that calculation into a PowerShell function. This time we’ll use the calculation to create a class:

class stats {
  static  StandardDeviation (]$numbers) {

    $mean = $numbers | Measure-Object -Average | select -ExpandProperty Average
    $sqdiffs = $numbers | foreach {::Pow(($psitem - $mean), 2)}

    $sigma = ::Sqrt( ($sqdiffs | Measure-Object -Average | select -ExpandProperty Average) )
    return ::Round($sigma, 3)
} 91 more words
Powershell Basics