Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 获取CsUserSession StartDate参数错误&;没有提示输入密码的凭据_Powershell - Fatal编程技术网

Powershell 获取CsUserSession StartDate参数错误&;没有提示输入密码的凭据

Powershell 获取CsUserSession StartDate参数错误&;没有提示输入密码的凭据,powershell,Powershell,编辑: 我想使用从特定帐户检索会话数据 PowerShell。根据本文件: Get CsUserSession命令可以执行此操作。我在用这个 根据上层链接示例的命令 Get-CsUserSession -User account@companyX.onmicrosoft.com -StartDate "6/1/2018 07:00 PM" 然后我得到以下错误: A parameter cannot be found that matches parameter name 'StartDate'

编辑:

  • 我想使用从特定帐户检索会话数据 PowerShell。根据本文件:
    Get CsUserSession
    命令可以执行此操作。我在用这个 根据上层链接示例的命令

    Get-CsUserSession -User account@companyX.onmicrosoft.com -StartDate "6/1/2018 07:00 PM"
    
    然后我得到以下错误:

    A parameter cannot be found that matches parameter name 'StartDate'.
        + CategoryInfo          : InvalidArgument: (:) [Get-CsUserSession], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Rtc.Management.Hosted.Data.GetCsUserSessionCmdlet
        + PSComputerName        : admin1e.online.lync.com
    
    这有什么问题?正确的声明是什么

  • 我正在使用以下脚本连接到Skype for business service:
    
    $credential=获取凭证
    导入模块MSOnline
    连接MsolService-凭据
    $credential导入模块SkyLineConnector
    $lyncSession=新建CsOnlineSession-凭证
    $credential Import PSSession$LynchSession
    
  • 我想做的是使用PowerShell脚本中的特定静态帐户和密码(使用某种声明变量字符串)进行设置,而不是运行此命令,并且必须在单独的窗口中键入凭据。这意味着我希望避免使用
    $credential=Get credential
    命令。这可能吗?

    如中所述(仅在顶部段落),您必须使用
    StartTime
    而不是
    StartDate
    。您收到的错误是一个典型的症状,即您的参数名有输入错误,或者该函数不存在此参数

    稍后我会要求更改文档中的示例,似乎编写这些示例的人与另一个cmdlet混在一起了

    编辑:要存储凭据,可以按如下方式导出密码:

    "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File C:\Users\username\password2.txt
    
    $password = Get-Content -Path "C:\Users\USUARIOPC\password2.txt" | ConvertTo-SecureString -String $password
    $credential = New-Object System.Management.Automation.PsCredential("yourlogin@domain.com", $password)
    
    然后像这样导入:

    "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File C:\Users\username\password2.txt
    
    $password = Get-Content -Path "C:\Users\USUARIOPC\password2.txt" | ConvertTo-SecureString -String $password
    $credential = New-Object System.Management.Automation.PsCredential("yourlogin@domain.com", $password)
    

    同时,我尝试了以下查询。在脚本中使用密码可能不太安全,但对于我们这些希望这样做的人来说,这是一个很好的解决方案

    $username = "account1@companyX.onmicrosoft.com"
    $password = "abcdefg"
    $secstr = New-Object -TypeName System.Security.SecureString
    $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
    
    $credential = $cred
    Import-Module MSOnline
    Connect-MsolService -Credential $credential
    Import-Module SkypeOnlineConnector
    $SFBSession = New-CsOnlineSession -Credential $credential
    Import-PSSession $SFBSession
    

    谢谢你的回答,这确实是你所缺少的。你能看看我编辑过的问题吗?嘿,我刚刚加了这个,因为它很容易解释。但是,我不认为这是正确的继续方式(编辑您的问题以询问另一个问题)。对于未来,请针对这种情况提出另一个问题。这将是一个更清楚的人谁会阅读后一段时间,因此对其他人有用,而不仅仅是对你。谢谢谢谢我编辑了问题的标题以便更清楚。不客气。不知道我是否清楚,但我添加了如何摆脱获取凭证和保存文件中的密码的信息-您可以检查它。