My most useful 8 liner yet
In my line of work, Iām constantly copying and pasting from e-mails, SharePoint, into PowerShell to do some meaningful work. Ā This means all day long Iām setting variables equal to paste, then removing blank entries, and then splitting them (because people never say āplease migrate these computersā and provide a list like $computers=ācompAā,ācompBā,ācompCā.
I then end up Pasting, and running $variable= Paste, then $variable.Trim().Split(ā`nā). Ā I finally decided to speed things up by making this short little few-liner. Ā I always forgot whether it was Split-N-Trim or not, so I made an alias for the other way around.
It now has a permanent place within my $PSProfile
```powershell Function Split-N-Trim { param( [Parameter(Mandatory=$True,ValueFromPipeline=$True)][string[]]$Objects) Write-Host ("-Recieved " + $Objects.Count +" objects") $Objects = $Objects.Trim().Split("`n") Write-Host ("Returning " + $Objects.Count +" objects") Return $Objects } new-alias Trim-N-Split Split-N-Trim
```