Parameter validation

Validating parameters in a Powershell function

Parameter validation In this article we will talk about an option available in Powershell: the validation of parameters The purpose of this option is, as the name suggests, to validate that a parameter passed to a function is indeed the one we expect. Throughout this article we will keep the following script as a guideline. function Do-SomeThing { [CmdletBinding()] param ( [String[]]$ComputerName, [Int]$Age ) begin { #The value of computername must not be null or empty if (($null -eq $ComputerName) -or ($ComputerName -eq "")) { throw "ComputerName cannot be empty or null" } #Test to verify that the computer name does not exceed 13 characters If ($ComputerName. [Read More]

Scope of variables

The different scopes for the variables used in Powershell

Information This article was written for a presentation of the French Powershell UserGroup. This presentation can be seen on Youtube on the FRPSUG channel The scope of variables in Powershell Several scopes are possible for the use of variables according to need Some basic rules: An element that you include in a scope is visible in the scope in which it was created and in any child scope, unless you explicitly make it private If you create an element in a scope and the element shares its name with an element in another scope, the original element can be hidden under the new element. [Read More]

Credential: how to use them ?

The different ways to use credentials

Information This article was written for a presentation of the French Powershell UserGroup. This presentation can be seen on Youtube on the FRPSUG channel The different ways to use credentials… Initial Request From my beginnings on powershell, I quickly asked myself the question of managing credentials in my scripts From the simple need that is perhaps managed in a basic way to the use of credentials in automatic scripts I have long sought the best way to do it. [Read More]

Credential: how to best use them ?

The module BetterCredentials

Information This article was written for a presentation of the French Powershell UserGroup. This presentation can be seen on Youtube on the FRPSUG channel Module : BetterCredentials During my last research, I came across, by chance, the module BetterCredentials from Jaykul Please note that the module is not completely dry :-) As he says himself so well ;-) The goal of BetterCredentials is to provide a Get-Credential command fully compatible with previous versions that improves the original Get-Credential by adding additional functionality that is not present in the integrated command. [Read More]