powershell新手,需要格式帮助,如下所示。由于变量对象数组没有任何属性可供选择,因此不确定如何获取键值并转换为html格式的表。
$localAccounts
Principal Is Group Role Role Description
---------- -------- ------ ---------------------------------------------------------
User1 false Admin Full access rights
User2 false Admin Full access rights
User3 false Admin Full access rights
User4 false Custom User-defined roles or roles on non-root inventory objects
User5 false Custom User-defined roles or roles on non-root inventory objects
$localAccounts.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
I need an output as html as table
UserName Role Description
User1 Admin Full access rights
User2 Admin Full access rights
User3 Admin Full access rights
User4 Custom User-defined roles or roles on non-root inventory objects
User5 Custom User-defined roles or roles on non-root inventory objects发布于 2021-04-29 22:07:41
你可以试试$localAccounts | select Principal,Role,"Role Description" | ConvertTo-Html。
但是,如果您想要更改头名称,则需要首先将项转换为PSCustomObjects。
$localAccounts | %{ [PSCustomObject]@{
UserName=$_.Principal
Role=$_.Role
Description=$_.'Role Description'} | ConvertTo-Htmlhttps://stackoverflow.com/questions/67318683
复制相似问题