我有System.Array
定义文件夹上特定安全组的权限,如下所示:
$Permissions
C\Department : FINANCE
BEL ROL-STAFF-FIN Accountants : L
BEL ROL-STAFF-SA Sales Employees : F
C\Department : SALES
BEL ROL-STAFF-FIN Accountants : C
BEL ROL-STAFF-SA Sales Employees : F
$Permissions.Count # Returns 2
我想知道的是如何添加其他安全组?
如果我想将值BEL ROL-STAFF-IT Service Desk
的安全组F
添加到上面的示例中,结果将是:
$Permissions
C\Department : FINANCE
BEL ROL-STAFF-FIN Accountants : L
BEL ROL-STAFF-SA Sales Employees : F
BEL ROL-STAFF-IT Service Desk : F
C\Department : SALES
BEL ROL-STAFF-FIN Accountants : C
BEL ROL-STAFF-SA Sales Employees : F
BEL ROL-STAFF-IT Service Desk : F
$Permissions.Count # Returns 2
向数组添加row
似乎很容易,但是如何将一个键/值对添加到数组中的现有row
,以便计数保持不变?
感谢您的帮助。
答案 0 :(得分:0)
向您的数组添加哈希表
$i=0
$permissions|%{
$permissions[$i]+=@{'BEL ROL-STAFF'='F'}
$i++
}
答案 1 :(得分:0)
找到它,我必须在单个NoteProperty
或row
添加$Item
,因为我在下面命名:
[int]$i = '0'
foreach ($Item in $Permissions) {
Write-Host "Item $([int]$i++)" -ForegroundColor Yellow
$Item
foreach ($d in $DefaultPermissions) {
Add-Member -InputObject $Item -MemberType NoteProperty -Name $d.GroupName -Value $d.Permissions
}
$Item
}