Tags » Powershell-basics

Playing with the range operator

The range operator allows you to reference a range of numbers

1..10

is equivalent to

1,2,3,4,5,6,7,8,9,10

If you want anything other than numbers you’re stuck as the range operator only works with integers… 53 more words

Powershell Basics

Typing variables

I was recently asked a question about typing variables after thinking about it came up with this demonstration.

Create a variable with an integer value… 263 more words

Powershell Basics

Modifying text

I needed to modify some text somewhere in a file. The file looks like this

## start file
This is some text.

I want to change something. 180 more words

Powershell Basics

Variable select

I was working on some code that accesses a SQL database this afternoon. I only needed to pull back a single column from a single row but which column to pull back is variable depending on other data. 164 more words

Powershell Basics

Awkward file and folder names

Spent some time today dealing with a situation where there were special characters – namely [ ] in folder a file names

£> Get-ChildItem -Path C:\Test… 348 more words

Powershell Basics

Event log dates

You can use Get-EventLog to query the event logs on you system

Get-EventLog -LogName System

One frequent task is to check if events occurred during a specific timespan. 96 more words

Powershell Basics

Get your current powershell version: $PSVersionTable

The first command I run on any system that I have never touched before is: $PSVersionTable

This command will pull up the version of Powershell. On windows 7, if it’s anything below version 4, I first run an upgrade. 152 more words

Powershell Basics