header image

Archive for April, 2018

PowerShell v6.1 Range Operator

Posted by: | April 30, 2018 Comments Off on PowerShell v6.1 Range Operator |

The PowerShell v6.1 Rang Operator has been enhanced to deal with letters as well as numbers. The range operator has always been available in PowerShell. It can be used to generate a range of integers for example: PS>  (1..10) -join ‘,’ 1,2,3,4,5,6,7,8,9,10 PS>  (10..1) -join ‘,’ 10,9,8,7,6,5,4,3,2,1 PS>  (-10..10) -join ‘,’ -10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10 PS>  (10..-10) -join […]

under: PowerShell v6

-Contains or -In

Posted by: | April 30, 2018 Comments Off on -Contains or -In |

PowerShell has two operators that do very similar jobs –contains and –in. So which should you use –contains or –in. From the help file. -Contains: Tells whether a collection of reference values includes a single test value. -In: Tells whether a test value appears in a collection of reference values OK – they’re subtly different. […]

under: PowerShell

Installing PowerShell v6.1 preview 2

Posted by: | April 28, 2018 Comments Off on Installing PowerShell v6.1 preview 2 |

The MSI for installing PowerShell v6.1 preview 2 has a screen for optional actions: Add PowerShell to Path environment variable Register Windows Event Logging Manifest Enable PowerShell remoting Add ‘open here’ context menus to Explorer   The 6.1 preview installs side by side with PowerShell v6.0.x   Test-Connection in v6.1 PS> Get-Command Test-Connection -Syntax Test-Connection […]

under: PowerShell v6

Access module and functions

Posted by: | April 28, 2018 Comments Off on Access module and functions |

A long time ago I wrote a module for working with Access databases. I also added a couple of independent functions. The  Access module and functions are now available on github. People have asked about getting the module and while its had a number of temporary homes its permanent home is now the github repsoitory […]

under: PowerShell

PowerShell v6.1 preview 2

Posted by: | April 28, 2018 Comments Off on PowerShell v6.1 preview 2 |

PowerShell v6.1 preview 2 is now available for download from https://github.com/PowerShell/PowerShell/releases   The breaking changes shouldn’t affect your code as they’re for telemetry and installation   Test-Connection is now available in v6 Export-FormatData will pretty print the XML rather than just giving you a single string There’s now a Test-Json cmdlet and a –Not parameter has […]

under: PowerShell v6

ScriptBlocks Decoded

Posted by: | April 28, 2018 Comments Off on ScriptBlocks Decoded |

My second talk at the PowerShell Summit 2018 was ScriptBlocks Decoded.   Starting from the basic explanation of what is a scriptblock and why they’re important it progressed through to proxy functions at the end.   The slides and code are available at https://github.com/RichardSiddaway/Summit2018ScriptBlocksDecoded   The recording of the session should be on the powershell.org […]

under: PowerShell, Summit

Troubleshooting #2

Posted by: | April 27, 2018 Comments Off on Troubleshooting #2 |

Last time I covered the PowerShell Troubleshooting pack. This time in Troubleshooting #2 I want to show you how to use Pester when troubleshooting.   When you’re troubleshooting you ideally want to follow a repeatable process so that you can do it again if necessary and teach others to do the same task. By wrapping […]

under: PowerShell

Troubleshooting #1

Posted by: | April 26, 2018 Comments Off on Troubleshooting #1 |

How do you go about troubleshooting a problem?   There are two ends to the spectrum of solutions to troubleshooting a problem. At one end you have the click and pray brigade who will manically click round all the menus on all the tools they can think of using to try and find something that […]

under: PowerShell

CIM references and associations

Posted by: | April 24, 2018 Comments Off on CIM references and associations |

Way back in 2011, when I were just a young lad, I wrote about WMI or CIM references and associations – https://wordpress.com/read/blogs/16267735/posts/1673 ASSOCIATORS show the end point of the link between CIM classes and REFERENCES shows the linking class. I used the Win32_NetworkAdapter class in the example because it has a known association with Win32_NetworkAdapterConfiguration. […]

under: PowerShell and CIM

Change a function definition

Posted by: | April 23, 2018 Comments Off on Change a function definition |

Functions in PowerShell are based on scriptblocks and as I showed in my session at the recent PowerShell Summit its possible to change a function definition. Let’s start with a simple function: PS> function f1 { >> $x = 1 >> $y = 2 >> $x + $y >> } PS> f1 3 Our function […]

under: PowerShell

Older Posts »