问题描述
我正在尝试创建一个脚本,以使用 ForEach 语句将一些用户添加到 O365 组。我一直在链接上收到一个错误,指出它是 NULL,但我正在向它传递一个值。关于为什么不使用传递的值的任何想法?也许是语法问题?
# User that needs access
$endusers = "user2","user1"
# List of the O365 Groups names user needs access to.
$o365groups = "o365group1","o365group2"
# loop to add permissions to above Office365 Groups
ForEach ($o365group in $o365groups)
{
Try
{
Add-UnifiedGroupLinks `
-Identity $o365group `
-LinkType Members `
-Links @enduser
}
Catch [System.Exception]
{
if($_.FullyQualifiedErrorId -match 'AlreadyExists')
{
Write-Output "`t $enduser is already a member of $o365group."
}
else
{
Write-Output "`t $_.Exception"
}
}
}
我不断得到:
Cannot bind argument to parameter 'Links' because it is null.
+ CategoryInfo : InvalidData: (:) [Add-UnifiedGroupLinks],ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterargumentValidationErrorNullNotAllowed,Add-UnifiedGroupLinks
+ PSComputerName : outlook.office365.com
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)