Я пытаюсь получить csv-файл всех пользователей в среде Live @ edu с помощью LastLogonTime, но у меня возникают некоторые проблемы, вот мой сценарий:
foreach ($i in (Get-Mailbox -ResultSize unlimited))
{ Get-MailboxStatistics -LastLogonTime $i.DistinguishedName | where {$_.LastLogonTime} | select-object MailboxOwnerID,Name,LastLogonTime | export-csv -path "c:\filepath\UserLastLogon.csv" }
Я получаю сообщение об ошибке:
A positional paparameter cannot be found that accepts argument 'CN=username@domain.edu,OU=domain.edu,OU=Microsoft Exchange Hosted Organizations,DC=prod,DC=exchangelabs,DC=com'.
+ Информация о категории: InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException + FullyQualifiedErrorId: PositionalParameterNotFound, Get-MailboxStatistics
Любая помощь была бы замечательной!
Кажется, у вас проблема с синтаксисом PowerShell в Get-MailboxStatistics
вызов.
Должно быть
foreach ($i in (Get-Mailbox -ResultSize unlimited))
{Get-MailboxStatistics -Identity $i.DistinguishedName | where {$_.LastLogonTime -ne $null} | select-object MailboxOwnerID,Name,LastLogonTime | export-csv -path "c:\filepath\UserLastLogon.csv" }
Нет CSV, но Eyecandy :-)
$LiveCred = Get-Credential -Credential admin@live-edu-domain.com-net
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
cls
set-alias list format-list
set-alias table format-table
Get-Mailbox |
Get-MailboxStatistics |
Select DisplayName,LastLogonTime,TotalItemSize,ItemCount |
sort -property lastlogontime |
ft @{expression={$_.displayname};label=”Postfachbesitzer”}, @{expression={$_.lastlogontime};label=”letzte Anmeldung am”}, @{expression={$_.totalitemsize};label=”Größe”}, @{expression={$_.itemcount};label=”Anzahl Objekte”}>C:\liste.txt
Remove-PSSession $Session