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 to D1 PS> Copy-Item -Path c:\test -Destination C:\D1 copies the […]
Archive for September, 2018
Copy-Item Container parameter
Posted by: richardsiddaway | September 28, 2018 Comments Off on Copy-Item Container parameter |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 expect. Remove $b and try the comparison again. […]
Comparing strings and integers
Posted by: richardsiddaway | September 25, 2018 Comments Off on 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 = @’ >> “Count”;”Value” >> “3”;”Year1″ >> “1”;”Year1″ >> “5”;”Year3″ >> “8”;”Year4″ >> “10”;”Year15″ >> […]
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 PowerShell v6.1 is PS> Get-Process […]
PowerShell copy file
Posted by: richardsiddaway | September 23, 2018 Comments Off on 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
Determining the PowerShell host
Posted by: richardsiddaway | September 22, 2018 Comments Off on 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 you’re running in the console. For ISE you get – Windows PowerShell ISE Host […]
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 from my test machine. Using Split-Path you can get the parent (by default) […]
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 https://github.com/PowerShell/PowerShell/releases and find the release notes at https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-core-61?view=powershell-6
Get-Date –DisplayHint
Posted by: richardsiddaway | September 13, 2018 Comments Off on Get-Date –DisplayHint |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 DisplayHint parameter ( available in PowerShell v5.1, 6.0 and 6.1) modifies […]
PowerShell new line
Posted by: richardsiddaway | September 9, 2018 Comments Off on PowerShell new line |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 Vertical tab –% Stop parsing […]
Categories
- .NET
- Active Directory
- Architecture
- Azure
- Bash
- BITS
- Books
- CDXML
- CIM
- Cloud
- COM
- Containers
- Deep Dive
- Desired State Configuration
- DevOps
- DHCP
- DNS
- DSC
- European Summit
- Events
- Exchange
- File System
- Firewall
- General
- General IT Matters
- Hyper-V
- IIS
- Infrastructure
- IT Community
- IT Security
- Learning PowerShell
- Linux
- Math
- Microsoft
- Modules
- Nano Server
- Networking
- Office 2010
- Office 2013
- Open Source
- Opinion
- Outlook
- Philosophy
- PowerShell
- PowerShell 7
- PowerShell and .NET
- PowerShell and Active Directory
- PowerShell and CIM
- PowerShell and Exchange 2007
- PowerShell and IIS
- PowerShell and SQL Server
- PowerShell and WMI
- PowerShell Basics
- PowerShell original
- PowerShell Summit
- PowerShell User Group
- PowerShell User Group 2
- PowerShell v2
- PowerShell V3
- PowerShell v4
- PowerShell v5
- PowerShell v6
- PowerShell.org
- PowerShellGet
- PowerShellV2
- PSAM
- Rant
- Registry
- Scripting
- Scripting Games
- Scripting Games 2104
- Security
- SQL Server
- Storage
- Strings
- Summit
- Technology
- Uncategorized
- Virtualization
- Windows 10
- Windows 2012 R2
- Windows 7
- Windows 8
- Windows 8 Server
- Windows 8.1
- Windows Server
- Windows server 1709
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- WMFv5
- WPF
- WSUS