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'
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
这有什么问题?正确的声明是什么
$credential=获取凭证
导入模块MSOnline
连接MsolService-凭据
$credential导入模块SkyLineConnector
$lyncSession=新建CsOnlineSession-凭证
$credential Import PSSession$LynchSession
$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
谢谢你的回答,这确实是你所缺少的。你能看看我编辑过的问题吗?嘿,我刚刚加了这个,因为它很容易解释。但是,我不认为这是正确的继续方式(编辑您的问题以询问另一个问题)。对于未来,请针对这种情况提出另一个问题。这将是一个更清楚的人谁会阅读后一段时间,因此对其他人有用,而不仅仅是对你。谢谢谢谢我编辑了问题的标题以便更清楚。不客气。不知道我是否清楚,但我添加了如何摆脱获取凭证和保存文件中的密码的信息-您可以检查它。