So I have this:
get-ADUser -SearchRoot 'boogers.com/Locations/Kleenex' |
Where-Object { $_.TITLE -ne 'Snot' } |
Select LastName,FirstName,Description,SamAccountName,Department,TITLE, @{Name='bs_value';Expression=@{Name='TITLE'; Expression={(Get-Culture).TextInfo.ToTitleCase($_.Title.ToLower())}}
And it works great, until, oh I dunno, I want another calculated field...then it becomes JUST TOO LONG!
So I write a function:
function tc($name, $str) {
return @{Name=$name; Expression={(Get-Culture).TextInfo.ToTitleCase($str.ToLower())}}
}
Seems reasonable enough, no?
But if I run the function:
$bob = tc 'Title' 'bob'
I get:
Name Value
---- -----
Expression (Get-Culture).TextInfo.ToTitleCase($str.ToLower())
Name Title
Instead of...
Name Value
---- -----
Expression "Bob"
Name Title
I just want the code to be shorter! I'm using a computer!