PowerShell for Windows Admins:

September, 2018


September 28, 2018  8:55 AM

Copy-Item Container parameter

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

The Copy-Item Container parameter controls whether the folder structure is also copied. Lets start with the source material – a folder C:\test with a bunch of files. A destination folder C:\D1 also exists PS>  Copy-Item -Path c:\test\* -Destination C:\D1 copies the files from test...

September 28, 2018  5:42 AM

-like oddity

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Recently saw a question asking why this code worked PS>  $a = 'aa' PS>  $b = 'a' PS>  $a -like "*$b*" True PS>  Remove-Variable -Name b PS>  $a -like "*$b*" True Set 2 variables and compare using wildcards. The comparison comes back as  True as you’d...


September 25, 2018  7:39 AM

Comparing strings and integers

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Saw an interesting problem involving the comparison of 2 numbers. In reality it's was comparing strings and integers. The starting point was a CSV file but as I showed last time you can create a CSV in memory PS> $file = @' >> "Count";"Value" >> "3";"Year1" >>...


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


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: