Tags » 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

Calculating Standard Deviation - the function

Last time I showed how to calculate the standard deviation of a set of numbers and said the code could easily be turned into a function… 81 more words

Powershell Basics

Calculating Standard Deviations–the calculation

A while ago I saw something asking about calculating standard deviations for a set of numbers in PowerShell. You can calculate the the mean (average) of a set of numbers using Measure-Object… 169 more words

Powershell Basics

using help proactively

I was reading a thread on the forum about using a particular cmdlet and it occurred to me that the person posing the question hadn’t actually looked at the help file for the cmdlet. 139 more words

Powershell Basics