首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Set-User:无法找到与使用Connect-ExchangeOnline的参数名称“Title”匹配的参数

Set-User:无法找到与使用Connect-ExchangeOnline的参数名称“Title”匹配的参数
EN

Stack Overflow用户
提问于 2020-06-19 20:35:52
回答 1查看 2.5K关注 0票数 0

我正在编写一个脚本,它将从CSV文件中更新Exchange邮箱属性。当我运行我的脚本时,我会得到一个'A参数不能找到与参数名称‘title’相匹配的参数。“错误。任何想法。我正在尝试更改Exchange组织选项卡中的title属性。

我知道错误消息意味着什么,但我在任何地方都找不到用于更改title属性的语法。

剧本:

代码语言:javascript
复制
# Updates AD user attributes from CSV file


$Credential = Get-Credential
Connect-ExchangeOnline -Credential $Credential

# Load data from file.csv
$ADUsers = Import-csv file_path

# Count variable for number of users update
$count = 0

# Go through each row that has user data in the CSV we just imported 
ForEach($User in $ADUsers)
{
    # Ppopulate hash table for Get-ADUser splatting:
    $GetParams =
    @{
        Identity     = $User.Username
    }

    # Initialize hash table for Set-ADUser splatting:
    $SetParams =
    @{
        Title        = $User.Title  
    }

    # Check to see if the user already exists in AD. If they do, we update.
    if ( Get-EXORecipient @GetParams)
    {
         # Set User attributes
         Set-User @SetParams -WhatIf

         # Print that the user was updated 
         Write-Host -ForegroundColor Yellow "$User - User attributes have been updated." 

         # Update Count
         $count += 1    
     }
}

# Print the number of updated users
Write-Host $count "Users have been updated" -ForegroundColor Green

错误信息:

代码语言:javascript
复制
A parameter cannot be found that matches parameter name 'Title'.
    + CategoryInfo          : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Set-Mailbox
    + PSComputerName        : outlook.office365.com
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-26 12:01:41

Set-User的params不包含-Identity,因此PowerShell不知道应该将标题设置给谁。你需要加一句:

代码语言:javascript
复制
$SetParams =
@{
    Identity     = $User.Username
    Title        = $User.Title  
}

确保Username包含有效的标识,这样就可以根据它来确定用户。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62478206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档