I turned that corner a long time ago and really like the verbosity of it now. When you combine that with clean code best practices that create self documenting code, Powershell becomes so easy to read and work with. I like it when my code makes it very easy to see what the intent of it is. I share a lot of code so this is something I find to be important in my work.
My simple example is trying to split a string and skipping the first item in the list. This is the code sample that was getting passed around:
$obj = (Get-ADGroup 'GroupName').DistinguishedName.split(',')
$obj[1..$($obj.count - 1)]
(Get-ADGroup 'GroupName').DistinguishedName -split
',' | Select-Object
-Skip 1
$ADGroup = Get-ADGroup 'GroupName'
$ADGroup.DistinguishedName
-split ','
| Select-Object -Skip 1
No comments:
Post a Comment