SQL `SELECT 'some string value' AS fieldname` 在 Powershell 中等效?

SQL `SELECT 'some string value' AS fieldname` equivalent in Powershell?

在SQL我可以去SELECT actualField, "repeat" AS bs_repeated_value FROM Table1

并且我可以重复 bs_repeated_value 字段的次数,无论我如何命名该字段!

现在我可以在 Powershell 中以类似的方式...几乎...做同样的事情,除了我上面提到的...

get-ADUser -SearchRoot 'boogers.com/Locations/Kleenex' | 
Where-Object { $_.TITLE -ne 'Snot' } | 
Select LastName,FirstName,Description,SamAccountName,Department,TITLE, @{'bs_repeated_value' = 'repeat' }

没有办法吗?

好吧,我做错了......这是它的工作原理,尽管它比你的 SQL 语法更不优雅......

get-ADUser -SearchRoot 'boogers.com/Locations/Kleenex' | 
Where-Object { $_.TITLE -ne 'Snot' } | 
Select LastName,FirstName,Description,SamAccountName,Department,TITLE, @{Name='bs_repeated_value';Expression={'repeat'}}

参考文献: