Tags » Powershell-basics

Boolean in Where-Object filter

I was testing some code yesterday and realised there was a quirk in the way the original where syntax (with {}) worked and the way the newer syntax worked. 196 more words

Powershell Basics


It would be nice to be able to do this:

PS> Get-Date -Day 25 -Month December -Year 2016
Get-Date : Cannot bind parameter ‘Month’. Cannot convert value “December” to type “System.Int32”. 237 more words

Powershell Basics

WMI Filters

A common mistake with WMI/CIM filters is:

PS> Get-WmiObject -Class Win32_LogicalDisk -Filter “DeviceId=C:”
Get-WmiObject : Invalid query “select * from Win32_LogicalDisk where DeviceId=C:”
At line:1 char:1… 264 more words

PowerShell And WMI

Converting strings to dates

You’ll see many examples of this:

PS> ’12/25/2016′

25 December 2016 00:00:00

This works great if the date is in US format – MM/DD/YYYY

For those of us who use different date formats – such as England DD/MM/YYYY – this approach won’t work… 98 more words

Powershell Basics

32 or 64 and/or Administrator

When you run the PowerShell console (or ISE) the default icon runs a 32 or 64 bit version that matches your OS. On a 64 bit machine you have the option of running in 32bit (icons have a (x86) suffix on the title. 116 more words

Powershell Basics

Dates in file and folder names

If you want to incorporate the date in a file or folder name you can’t use Get-Date directly

PS> Get-Date

01 June 2016 20:52:03

The simplest answer is to use the –Format or –Uformat parameters: 15 more words

Powershell Basics

Counting members

If you have a collection of objects

$proc = get-process

you can get the number of members using the Length property

PS> $proc.Length

$proc is of type System.Array… 246 more words

Powershell Basics