PowerShell for Windows Admins:

February, 2018


February 28, 2018  10:58 AM

PowerShell while

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell has a number of looping structures – do; while; for; foreach. This is how the PowerShell while loop works The while statement has the form: while (<condition>){<statement list>} The while loop is probably the simplest of the PowerShell loops. For example: $x =...

February 27, 2018  10:27 AM

Get-Date format

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

A common question revolves around Get-Date format. In other words how can you format the output of Get-Date. Standard output is PS> Get-Date 27 February 2018 16:02:13 You can use –DisplayHint to control what’s displayed PS> Get-Date -DisplayHint Date 27 February...


February 27, 2018  4:16 AM

Iron Scripter puzzles

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

We keep innovating around the content of the PowerShell Summit to ensure it remains fresh and relevant to our attendees. This year we’re introducing the Iron Scripter competition. As a run up to the main competition I’ve written a number of challenges. The first half of the Iron Scripter...


February 26, 2018  8:10 AM

PowerShell Scope

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell Scope has an important impact on the way your code runs. When you run a script or a function in PowerShell it runs it in its own scope. This means that all variables, functions, classes, aliases etc are removed from memory at the end of the script. Here’s an example create a...


February 23, 2018  2:30 PM

Controlled zip

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Powershell v5 introduced the Compress- and Expand-Archive cmdlets which enabled you to manage compressed archives. I had a question about how you could control adding files to archives using a CSV file. This is how you do a controlled zip. Start by creating a set of test data. 1..100...


February 23, 2018  12:01 PM

PowerShell if

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The PowerShell if statement enables you to branch your code depending in the results of one or more conditional tests. The tests can be anything you need but must produce a boolean – true/false – result. Also 0 is treated as $false and a positive non-zero is $true. A negative non-zero generates...


February 22, 2018  2:39 PM

ComputerName

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

If you want to find the name of the local computer you use $env:COMPUTERNAME. Except that doesn’t exist in Linux PowerShell v6 – you have to use $env:HOSTNAME PowerShell 1 Consistency 0 I can live with having $env:HOSTNAME because I bet that’s what Linux users would look for. It...


February 15, 2018  11:52 AM

PowerShell for loop

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell has a number of looping mechanisms – do-while; do-until; foreach; while and for loops. In this post I’ll show you how to use the PowerShell for loop. A for loop iterates a predefined number 0f times. A basic for loop looks like this:

for ($i=0; $i -lt 10; $i++)...


February 13, 2018  3:29 PM

PowerShell v6 and PowerShell Direct

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Hyper-V, Powershell

Not seen this reported anywhere so thought I post. PowerShell v6 went to GA in January 2018. PowerShell Direct is a feature of Windows 10/Windows Server 2016. By accident I found that PowerShell v6 and PowerShell Direct work together. PowerShell v6 is based on .NET core which is basically a...


February 4, 2018  8:44 AM

Putting on the style

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Philosophy, Powershell

PowerShell is all about getting things done but how you do things can be as important as what you do. I’ll explain what I mean so you be able to be putting on the style. While PowerShell is used by a number of developers its predominantly an administrators tool. Most administrators aren’t...


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: