It usually occurs that you’ve got many, many parameters in PowerShell. The command then extends over a number of traces. That doesn’t look fairly. On this article, I’ll present you easy methods to summarize these parameters after which use them within the command. Let’s get began.
Outline Hash Desk with Parameter Names and Values
Let’s summarize these parameters in a hash desk.
$params = @{
Parameter1 = "Value1"
Parameter2 = "Value2"
Parameter3 = "Value3"
}
Subsequent, we name the command by utilizing our hash desk which incorporates all of the parameters and their values.
That’s it. Mission accomplished.
However wait, let me present you one other instance which is extra from the actual phrase, additionally referred to as a real-world-scenario. The code under creates a brand new Energetic Listing person utilizing splatting.
$hash=@{
GivenName="Florian"
Surname="Perfekt"
Title="Florian Perfekt"
Enabled = $true
AccountPassword = (ConvertTo-SecureString -AsPlainText '123user!' -Drive)
DisplayName="Florian Perfekt"
UserPrincipalName="florian.perfekt@pagr.loc"
Path="OU=Benutzer,DC=pagr,DC=loc"
}
New-ADUser @hash
Hope this was useful.
Printed by