Monthly Archives: September 2018

Copy-Item Container parameter

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 … Continue reading

Posted in Powershell | Leave a comment

-like oddity

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 … Continue reading

Posted in Powershell | Leave a comment

Comparing strings and integers

Saw an interesting problem involving the comparison of 2 numbers. In reality its 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 … Continue reading

Posted in Powershell | Leave a comment

CSV cmdlets

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 … Continue reading

Posted in Powershell | Leave a comment

PowerShell copy file

An article I wrote for searchwindowsserver on PowerShell file copy was published recently. The article is available at https://searchwindowsserver.techtarget.com/tip/PowerShell-commands-to-copy-files-Basic-to-advanced-methods

Posted in Powershell | 1 Comment

Determining the PowerShell host

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 … Continue reading

Posted in Powershell | Leave a comment

Splitting paths

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 … Continue reading

Posted in File system, Powershell | Leave a comment