PowerShell for Windows Admins:

Powershell


September 24, 2018  6:23 AM

CSV cmdlets

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

I was reading something and when ConvertFrom-CSV was mentioned it made me pause and think about what that cmdlet actually did. This is a quick explanation of the CSV cmdlets. Export-CSV was available in PowerShell v1. You use it to create a CSV file from PowerShell objects. The code in...

September 23, 2018  5:16 AM

PowerShell copy file

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

An article I wrote for searchwindowsserver on PowerShell file copy was published recently. The article is available at 0 Comments     RSS Feed     Email a friend


September 22, 2018  5:24 AM

Determining the PowerShell host

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The PowerShell ecosystem is more diverse than it used to be which makes determining the PowerShell host a bit more difficult. The variable $host, and its Name property, is a good starting point. PS>  $host.Name ConsoleHost   You get ConSoleHost if you’re running in the...


September 21, 2018  5:32 AM

Splitting paths

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell has the Split-Path cmdlet that provides the leaf and parent of a path. But what if you’re splitting paths and need one or paths at a higher level. Consider the path

PS> $path = 'C:\Scripts\HyperV\Admin\Optimize-VMDisks.ps1'
  Its just an arbitrary path...


September 19, 2018  5:07 AM

PowerShell v6.1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell v6.1 was released last week – there’s no big ticket items like v6.0 but a lot of bug fixes and minor improvements. You can download from 0 Comments     RSS Feed     Email a friend


September 14, 2018  9:10 AM

Get-Date – DisplayHint

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

On the surface Get-Date is a simple cmdlet that’s been around since PowerShell v1. However, it has some interesting quirks. In this post I’ll show how Get-Date –DisplayHint works. By default Get-Date returns the data and time PS> Get-Date 13 September 2018 16:09:34 The...


September 13, 2018  9:43 AM

PowerShell new line

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

A PowerShell new line can be generated using `n. It’s one of a series of special characters recognised by PowerShell. The full list of Windows PowerShell v5.1 special characters is: `0 Null `a Alert `b Backspace `f Form feed `n New line `r Carriage return `t Horizontal tab `v...


September 8, 2018  6:15 AM

PowerShell check file exists

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

There are times when you need to check if a file exists – this is how you do a PowerShell check file exists. If you try to access a file that doesn’t exist you’ll get an error: PS> Get-Content -Path c:\test\z27.txt Get-Content : Cannot find path 'C:\test\z27.txt' because it does...


September 6, 2018  11:13 AM

Hyper-V book soon available

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

I’ve been working with Andy Syrewicze on a Hyper-V book that’ll be available in the next few months. https://www.apress.com/gb/book/9781484241158


August 31, 2018  6:05 AM

PowerShell string contains

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

How can you check if a PowerShell string contains a character or substring? You might be tempted to try this: PS> $s = 'abcdefghijk' PS> $s -contains 'f' False But –contains is for working with the contents of arrays. So you could do this: PS> ($s.ToCharArray()) -contains...


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: