PowerShell for Windows Admins:

Powershell


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


February 2, 2018  8:30 AM

Dynamic parameters

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell has always been an extensible language meaning that you can add things on, change things and even remove things if required. One way that this extensibility surfaces is dynamic parameters. A dynamic parameter is a parameter that is available when certain conditions are met. Many of...


February 1, 2018  10:49 AM

CIM_ or Win32_

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

If you dig into the classes available on a Windows machine you’ll see a mixture of prefixes – namely CIM_ and Win32_ used for the classes. So which should you use CIM_ or Win32_ Lets start by seeing whats available:

PS> Get-CimClass -ClassName *Volume*


    NameSpace:...


January 31, 2018  8:51 AM

Clear-RecycleBin

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Every so often I find a new cmdlet in PowerShell. This was the case with Clear-RecycleBin that I’ve just found. It appears to have been introduced with PowerShell 5.0 BUT isn’t available in PowerShell 6.0 With pretty simple syntax PS> Get-Command Clear-RecycleBin...


January 31, 2018  5:01 AM

Documentation can be wrong!

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

We rely on vendor documentation to help us solve problems. Documentation is produced by people and people make mistakes so Documentation can be wrong! As an example: The CIM class Win32_OperatingSystem has a Description property. According to the documentation the Description property...


January 30, 2018  12:50 PM

PowerShell sleep

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell use tends to be very interactive. You run a command at the console and get some results. You run a script and get some results. How do you make PowerShell sleep? There’s a few ways you can make PowerShell code sleep. First there’s Start-Sleep

PS> for ($i=0; $i -le 10;...


January 28, 2018  8:26 AM

PowerShell –f string

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

A PowerShell –f string is used to format the data inside a string. –f is usually referred to as the format operator. The operation of the format operator is best explained by examples. At its simplest you create fields in the string using {} and the arguments to the right of the –f...


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: