During my session on scriptblocks at Summit 2018 I showed how to split a string into pairs of values Start with this string PS> $str = ‘Jack,Jill,Bill,Ben,Eric,Ernie,Cagney,Lacey’ You want the string split in the commas – but every other comma so you get pairs if values separated by a comma. You need to set […]
Archive for May, 2018
Splitting into pairs
Posted by: richardsiddaway | May 31, 2018 Comments Off on Splitting into pairs |Summit 2018 sessions
Posted by: richardsiddaway | May 31, 2018 Comments Off on Summit 2018 sessions |The code and slides from my Summit 2018 sessions can be found at https://github.com/RichardSiddaway/Summit2018TroubleShootingRemoting and https://github.com/RichardSiddaway/Summit2018ScriptBlocksDecoded
PowerShell functionality
Posted by: richardsiddaway | May 31, 2018 Comments Off on PowerShell functionality |PowerShell functionality – in the form of modules – comes from a number of different sources. These are: Powershell itself including the Microsoft.PowerShell.* modules and CIM cmdlets Windows Team – this includes the modules such as NetAdapter, NetTCPIP, Storage that were first introduced with Windows 8 and have been part of all subsequent Windows client […]
The Month of Lunches Hyper-V book I was working on was cancelled by the publisher. The good news is that it’s most likely going to be resurrected with another publisher and will hopefully be available later this year. More to follow when the details are finalised
WMI and CIM accelerators
Posted by: richardsiddaway | May 26, 2018 Comments Off on WMI and CIM accelerators |In PowerShell an accelerator is a shortcut to a .NET type. The WMI accelerators have been around since PowerShell v1. The WMI accelerators were heavily used in v1 fill some of the gaps in cmdlet coverage. The CIM accelerators appeared in PowerShell v3 (I think – only discovered them recently!). This is how you use […]
PowerShell parameter sets
Posted by: richardsiddaway | May 22, 2018 Comments Off on PowerShell parameter sets |PowerShell parameter sets allow you to control which parameters can be used together. If a parameter isn’t in the parameter set you’re trying to use you’ll get an error message. PS> Get-VM -Name XYZ -id (New-Guid) Get-VM : Parameter set cannot be resolved using the specified named parameters. At line:1 char:1 + Get-VM -Name XYZ […]
Discovering the PowerShell version you’re using can be an interesting task. The automatic variable $PSVersionTable was introduced in PowerShell v2. On my Windows 10 version 1803 machine for Windows PowerShell I get PS> $PSVersionTable Name Value —- —– PSVersion 5.1.17134.48 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} BuildVersion 10.0.17134.48 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 […]
PowerShell will format the output of objects that it knows about. For instance Get-Process shows different sets of properties depending on whether you choose a table or list view. The format data is stored in files named *.format.ps1xml. In Windows PowerShell the format files are found in C:\Windows\System32\WindowsPowerShell\v1.0. In PowerShell v6 the format files are […]
PowerShell v6.1 preview 2 has added the where –not option. The option adds another parameter to the syntax where-object <property name> <operator like parameter> <value> Couple of examples of using the syntax Get-Process | where CPU -gt 12 Get-Service | where Status -like ‘Stop*’ Use –Not when you’re looking for properties that aren’t […]
Calculating standard deviation
Posted by: richardsiddaway | May 11, 2018 Comments Off on Calculating standard deviation |Calculating a standard deviation isn’t a difficult exercise but PowerShell v6.1 offers an easier method. In Windows PowerShell v5.1 and PowerShell v6.0 the Measure-Object cmdlet has this syntax PS> Get-Command Measure-Object -Syntax Measure-Object [[-Property] <string[]>] [-InputObject <psobject>] [-Sum] [-Average] [-Maximum] [-Minimum] [<CommonParameters>] Measure-Object [[-Property] <string[]>] [-InputObject <psobject>] [-Line] [-Word] [-Character] [-IgnoreWhiteSpace] [<CommonParameters>] In […]
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