PowerShell for Windows Admins:

Powershell


August 20, 2017  2:10 PM

PowerShell for loop

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Loops are a construction seen in most scripting and programming languages. A loop is used to repeat a set of statements a set number of times or until a specific criterion is met or while a specific criterion is true. In this post I’ll describe the PowerShell for loop. For loops are found in...

August 19, 2017  7:52 AM

Create a directory

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell enables you to work with the file system on your machine – one question that often comes up is how to create a directory. When working interactively you can use md

PS> md c:\testf1


 Directory: C:\


 Mode LastWriteTime Length Name
 ---- ------------- ------ ----
 d-----...


August 18, 2017  3:00 AM

PowerShell foreach

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell has a number of ways to perform a loop – I recently counted seven distinct methods. If you can’t list them all don’t worry one is very esoteric and unexpected. I’ll enumerate them in a future post. For now I want to concentrate on a source of confusion – especially to newcomers...


August 9, 2017  4:59 AM

Get-ADUser filtering

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, Powershell

Saw a question on the forums that revolved around Get-ADUser filtering. Initial code was like this Import-Csv .\users.txt | foreach { Get-ADUser -Filter {Name -like $_.Name} } which on the face of it seems reasonable. However, you get errors like this Get-ADUser : Property: 'Name' not found in...


August 1, 2017  4:00 AM

PowerShell Summit 2018: Call for topics

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The call for topics for the PowerShell and DevOps Summit 2018 is now open - https://powershell.org/2017/08/01/76318/ We’re looking for sessions (45 or 105 minute) that span the whole range of PowerShell usage and knowledge PLUS sessions on DevOps practices. This is your opportunity to speak...


July 31, 2017  2:20 PM

PowerShell documentation

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The home of Microsoft’s PowerShell documentation is changing from MSDN to https://docs.microsoft.com The PowerShell documentation is currently opened sourced at https://github.com/powershell/powershell-docs This change makes accessing the documentation easier


July 20, 2017  4:11 AM

Unblock and rename files

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

I have a bunch of files that I’ve downloaded to a specific folder. I need to unblock and rename files in that folder. The rename involves replacing a plus sign with a space.

$path = 'C:\Users\Richard\Downloads\Walks'

$files = Get-ChildItem -Path $path -File

foreach ($file in $files) {...


July 16, 2017  3:56 AM

Change a computer’s description

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell

The Win32_OperatingSystem class exposes the machines Description. This is how you can easily change a computer’s description.

PS> Get-CimInstance -ClassName Win32_OperatingSystem | select Description

Description
-----------

PS> Get-CimInstance -ClassName Win32_OperatingSystem |...


July 15, 2017  4:46 AM

Control split output

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

In this post I’ll show you show to control split output – that is control the number of strings that are returned. If you use –split with just a delimiter you’ll get a split occurring at every occurrence of the delimiter:

PS> 'SundayJanuary 01 Jan 1 New Years Day First Monday if...


July 12, 2017  10:13 AM

More diskinfo

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Disk storage, Powershell

Yesterday I showed how to get the disk, partition and logical disk information using CIM. Today I want to show more diskinfo techniques. This time we’ll use the Storage module which was introduced with Windows 8. Underneath the covers it uses CIM – just different classes. The storage module...


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: