Monthly Archives: February 2018

PowerShell while

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. … Continue reading

Posted in Powershell | Leave a comment

Get-Date format

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 … Continue reading

Posted in Powershell | Leave a comment

Iron Scripter puzzles

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 … Continue reading

Posted in Powershell | Leave a comment

PowerShell Scope

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 … Continue reading

Posted in Powershell | Leave a comment

Controlled zip

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. … Continue reading

Posted in PowerShell v5 | Leave a comment

PowerShell if

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 … Continue reading

Posted in Powershell | Leave a comment

ComputerName

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 … Continue reading

Posted in PowerShell v6 | Leave a comment

PowerShell for loop

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 … Continue reading

Posted in Powershell Basics | Leave a comment

PowerShell v6 and PowerShell Direct

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 … Continue reading

Posted in Hyper-V, PowerShell v6 | 2 Comments

Putting on the style

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 … Continue reading

Posted in Philosophy, Powershell | Leave a comment