PowerShell for Windows Admins:

Powershell


March 15, 2018  6:37 AM

Set active hours

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Last time time you saw how to get the current active hours. This is how you set the active hours. $sb = { Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name ActiveHoursStart -Value 10 -PassThru Set-ItemProperty -Path...

March 14, 2018  1:42 PM

Get Active Hours

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Windows 10 and Server 2016 (and later) have the concept of active hours. These are the hours you define as working hours in effect. This is how you get active hours for a system $sb = { param([string]$computerName) $ahs = Get-Item -Path...


March 5, 2018  7:00 AM

Cmdlet parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

I discovered another way to investigate cmdlet parameters. If you dig into the output of Get-Command you’ll see it has a parameters property

PS> Get-Command Clear-RecycleBin | select parameters

Parameters
----------
{[DriveLetter, System.Management.Automation.ParameterMetadata],...


March 4, 2018  10:41 AM

Finding special folders

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Windows has a number of special folders. These can be accessed either directly through the file system – for example the Documents special folder is C:\<user>\Richard\Documents or through code. But how do you go about finding special folders. The easiest way is to use this...


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...


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: