Querying Office 365 Exchange to create a license usage report.. but getting an IO error intermittently

I have included the powershell function that i am using.  The script returns the data i am looking for.  The issue i am having is the intermittent error:
The I/O operation has been aborted because of either a thread exit or an application request
I found one blog on this here: http://blogs.msdn.com/b/ashour/archive/2014/04/30/large-tenant-and-powershell-i-o-timeout.aspx 
so my question is, does anyone know a way i can cycle through the users in chunks without having to import them from a csv file first?
Function Get-LicenseReport {
<#
.Synopsis
This Cmdlet generates a report off all Office 365 licensed users
.Description
Get-LicenseReport queries Azure AD and generates a CSV report of the users that are licensed and they license SKU assigned to them
.Example
Get-LicenseReport -Verbose
#>
[CmdletBinding()]
param()
$date = Get-Date -Format g
$msolcred = Get-Credential -Message "Office 365 Username and Password"
#Clear any current PSSessions
Get-PSSession | Remove-PSSession
#Connect to Office 365
connect-msolservice -credential $msolcred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $msolcred -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber -DisableNameChecking | Out-Null
#Verify Admindir and create CSV
$admindir = "$env:HOMEDRIVE\PS_logs"
If ((Test-Path $admindir) -eq 'false')
New-Item $admindir -ItemType directory -Force
$CSV = "$admindir\O365LicenseReport.csv"
$props = [ordered]@{'UserPrincipalName' = '';'Disabled' = '';'RecipientType' = '';'IsLicensed' = '';'LastLogonDate' = '';'License 1' = '';'License 2' = ''}
New-Object psobject -Property $props | Export-Csv $CSV -NoTypeInformation -Force
$users = Get-MsolUser -all | Where {$_.islicensed -eq $true}
#Loop through each user and write the details to the CSV
foreach ($user in $users)
$mbxstats = Get-MailboxStatistics -Identity $user.userprincipalname
$mbx = Get-Mailbox -Identity $user.UserPrincipalName
If ($user.licenses.accountskuid.count -gt 1)
$datastring = ($user.UserPrincipalName + "," + $mbx.accountdisabled + "," + $mbx.recipienttype + "," + $user.IsLicensed + "," + $mbxstats.lastlogontime + "," + $user.Licenses.accountskuid[1] + "," + $user.Licenses.accountskuid[0])
Out-File $CSV -InputObject $datastring -Encoding UTF8 -append
Else
$datastring = ($user.UserPrincipalName + "," + $mbx.accountdisabled + "," + $mbx.recipienttype + "," + $user.IsLicensed + "," + $mbxstats.lastlogontime + "," + $user.Licenses.accountskuid)
Out-File $CSV -InputObject $datastring -Encoding UTF8 -append
Write-Host "License report has been saved to $CSV"
Remove-PSSession $Session

I updated the Azure AD PowerShell module to the latest version and the intermittent I/O error seems to have stopped...

Similar Messages

  • Office 365 Exchange Account Deleted & Overwritten?

    I've run into a problem where I need to recover an Office 365 Exchange account, but it doesn't exist in Deleted Accounts. Below is a summary of the events leading up to this problem:
    An Office 365 account was deleted
    A shared mailbox (using the exact same email address as the deleted account in step 1) was created
    It was determined that there were email and contacts that needed to be saved from the original account
    In the Deleted Mailboxes list, the deleted mailbox did not exist
    The shared mailbox was deleted
    In the Deleted Mailboxes list, the deleted shared mailbox existed, but not the original
    I'm currently in the process of using eDiscovery to try to recover the email from the account, but is there a way to actually recover the original account at this point?
    I realize that the smarter option would have been to convert the original account into a shared mailbox, but at the time none of the old data was needed. Deleting the account was an easy way to clean out all of the old data.

    Hi,
    Please note in this forum we mainly discuss questions and feedbacks about Office client issues, since your question is related to Office 365 Exchange Account, I suggest you post the question in Office 365 Community Forum:
    http://community.office365.com/en-us/f/default.aspx
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Office 365 Exchange for Non-profit

    Hi
    Previous a Website Hosting was own mailing server (Sample)
    [email protected]   is Mailbox only in the hosting
    [email protected]  (as non-mailbox)  come automatic-forward to     [email protected]
    [email protected]  (as non-mailbox) come automatic-forward to    
    joe@other_isp.co.nz
    Now, We bought a Office 365 non-profit in clouding.   I setup a new user for 
    [email protected] in the mailbox via exchange clouding.  And I changed our DNS in our Web hosting, Then I setting a exchange with Outlook app were successfully. 
    I tried find Office 365 about the another add user for [email protected] (as non-mailbox) should be automatic forward to 
    [email protected] (in own mailbox). 
    My experience Windows Server with Exchange 2003, 2008 & 2011.  Now, I first time this Office 365 exchange for business & non-profit.  I never seen this. 
    Help me, Where I can find the "Domain email (non-mailbox) Auto-Forward email to domain email (mailbox) or also external email"
    Thanks for your help
    Mike

    You can nicely do this with Distribution Group or by Transport Rules. Distribution Group will be maybe the easy way.
    You can referer to article Create and use distribution groups.
    Basically, you create DL with address [email protected] and allow to receive e-mail from external sources. Then you add [email protected] as member of this group.
    If you want also sent e-mails from this DL, you can use PowerShell to set rights for it.

  • Email configuration with Office 365 exchange- MS CRM online 2015

    Hi,
    Is there any link available which I can refer to configure Office 365 exchange with Ms Dynamics CRM 2015?
    Thanks
    Regards.

    Please refer this:
    https://msdn.microsoft.com/en-us/library/hh670607.aspx?f=255&MSPPError=-2147217396
    Regards, Abhishek Bakshi If you find this post helpful then please Vote as Helpful and Mark As Answer. Check my blog on https://mydynamicscrmblog.wordpress.com/

  • ADFS, Office 365 + Exchange 2012

    Need information on How to configure the ADFS, Office 365 + Exchange 2012 on IOS device.

    Hi,
    Based on my research, we can join iOS devices to a workplace with
    Windows Server 2012 R2:
    Overview: Join to Workplace from Any Device for SSO and Seamless Second Factor Authentication Across Company Applications
    http://technet.microsoft.com/en-us/library/dn280945.aspx
    Walkthrough Guide: Workplace Join with an iOS Device
    http://technet.microsoft.com/en-us/library/dn280933.aspx
    Best Regards,
    Amy

  • Questions on managing Office 365/Exchange Online Mailboxes in Server 2012 Essentials

    Wondered if anyone could answer a couple of queries:
    When managing Office 365/Exchange Online mailboxes in Windows Server 2012 Essentials:-
    1. Does the server itself act as the Exchange server i.e. does it do all of the downloading/sending of emails or does Outlook on each workstation still communicate direct with the Office 365/Exchange Online server address?
    2. Does Outlook on each workstation have the Exchange server address set to the internal address of the Server 2012 Essentials box or does it still have the external Office 365/Exchange Online server address?
    I don&amp;#39;t work for Microsoft - I just use their products.

    Hi,
    When you integrate Office 365/Exchange Online mailboxes in Windows Server 2012 Essentials,you can see the mailbox usage information on the Essentials Dashboard and manager users. However, the essentials server won't download/send emails and Outlook
    will still communicate with the O365/Exchange Online Server. In addition, the Exchange server address would be point to the external server address.
    You can also refer to the article below to get more related information:
    Email Options Supported by Windows Server 2012 Essentials
    Best regards,
    Susie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Apple Mail with Office 365 Exchange server

    Is anyone here using Apple Mail with Office 365 Exchange server on Mountain Lion? I have just upgraded to Mt Lion and decided to switch from Outlook to Apple Mail.app. My account was added successfully. Even contacts, calendar, tasks and notes work very well. My problem with Mail.app is that it does not sync any emails in subfolders prior to the day I added the account to Mail. For any older emails I have to open Outlook for Mac and look it up there. Other than this issue Mail is working well for all new incoming and outgoing emails.
    Thanks

    I Found a workaround.  Please look at this other link:  https://discussions.apple.com/thread/6615135

  • Synchronize Lotus Domino Directory with Office 365/Exchange Online

    I have someone who is asking me to migrate them from a Lotus Domino server to Office 360/Exchange online. However they want to maintain a sync between Lotus Domino Directory and Office 365/Exchange Online. I'm wondering if that is even possible
    or would they need to have a regular Active Directory server act as a go between the two. Can anyone provide me some guidance/suggestions?
    Vincent Sprague

    Curious, did you ever get this setup?
    Reason I'm asking is I was involved with a large MSO365 migration (15k) from Lotus Notes. We had a separate AD forest just for email Dirsync. We involved a third party to setup the sync and migration between Notes and AD, and coexistence. It was rather complex.
    Out of the box, it would have been extremely difficult.
    Ace Fekay
    MVP, MCT, MCSE 2012, MCITP EA & MCTS Windows 2008/R2, Exchange 2013, 2010 EA & 2007, MCSE & MCSA 2003/2000, MCSA Messaging 2003
    Microsoft Certified Trainer
    Microsoft MVP - Directory Services
    Complete List of Technical Blogs: http://www.delawarecountycomputerconsulting.com/technicalblogs.php
    This posting is provided AS-IS with no warranties or guarantees and confers no rights.

  • Office 365 / Exchange Online - Hybrid Setup - On Premise User cannot see calendar of an Exchange Online User.

    Hi All, 
    The below will help if:
    You have a hybrid setup and cannot see Free/Busy info from an On Premise user for anyone on Office 365 / Exchange Online.
    You have your network firewall configured to allow your Exchange servers out through the proxy for O365/EXO url's
    - Get hold of SysInternals PSEXEC from Microsoft. 
    Run PSEXEC -i -s C"\Program Files (x86)\Internet Explorer\iexplore.exe"  (This opens Internet Explorer as the SYSTEM account)
    Goto Internet Options > Connections > LAN Settings and untick the "Automatically Detect Settings"
    Had this bouncing around at Microsoft for a few days until one of the guys tried this and it worked immediately.

    Forgot to mention, the PSEXEC command needs to be run as an Administrator
    Run PSEXEC -i -s C"\Program Files (x86)\Internet Explorer\iexplore.exe"  (This opens Internet Explorer as the SYSTEM account)
    Goto Internet Options > Connections > LAN Settings and untick the "Automatically Detect Settings"

  • Consultation on License Usage Report.

    Hi;
    From one day to another, the "License Usage Report" section began the following message:
    "The system is operating With An Insufficient number of licenses. If additional licenses to cover the shortage are not configured in your Enterprise License Manager Within 59 days, you will no longer be able to provision users and devices."
    The query that I have is that the aggregate IP Phone says "Unassigned" then;
    Should I add a Onwed each User ID? What with that that message would be solved?
    image.
    regards

    refer the link which says
    Licenses in the non-compliant state for Unified Communications Manager are enforced after a 60-day grace period. At the conclusion of the grace period,Unified Communications Manager enforces non-compliance with the following service degradation:
    Devices and Users cannot be provisioned. Changing the configuration of a user that affects licensing (For example: the Enable IM and Presence and the Enable Mobility check boxes) is not allowed.
    Devices and Users cannot be de-provisioned. Any configuration changes that involve licensing (For example: disabling IM and Presence or Mobility) is allowed.
    you need to buy additional licenses to make the non-compliant phones work .
    http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/admin/9_1_1/ccmfeat/CUCM_BK_C3E0EFA0_00_cucm-features-services-guide-91/CUCM_BK_C3E0EFA0_00_cucm-features-services-guide-91_chapter_0100100.html
    regds,
    aman

  • Old Exchange Script to Office 365 Exchange

    Previously, I was using the script (on our old Exchange server) below to create a report on all emails sent to a different domain name aside from our company's registered domains. Now, we are using Office 365 and I don't know how to make this work.
    Here is my script for collecting emails not sent to our company's registered domains:
    Get-MessageTrackingLog -ResultSize Unlimited -EventID "SEND" | where{$_.recipients -notlike "*@company.com, *@company-1.com"} |select-object Timestamp,Source,EventId,Sender,{$_.Recipients},MessageSubject | Format-Table -Wrap -AutoSize|
    Out-File -FilePath "X:\EmailLogs\EmailLog $(get-date -f yyyy-MM-dd).txt" -width 1000
    Now this is the second script I use to "pull" the logs and send emails for notification:
      $date = Get-Date -Format d.MMMM.yyyy
      $source = "X:\EmailLogs\EmailLog $(get-date -f yyyy-MM-dd).txt"
      $destination = "\\Company-Shared\EmailLogs\"
      $path = test-Path $destination
      $smtp = "EXCH01"
      $from = "Sender <[email protected]>"
      $to = "Recipient <[email protected]>"
      $body = "This is a scheduled-automated e-mail message. Exchange Log file copied to \\Company-Shared\EmailLogs shared folder: $date"
      $subject = "Exchange Log Backup on $date" 
      if ($path -eq $true) {
                 copy-Item  -Path $source -Destination $destination
                 $backup_log = Dir -Recurse $destination | out-File "$destination\backup_log.txt"
                 $attachment = "$destination\backup_log.txt"
                 send-MailMessage -SmtpServer $smtp -From $from -To $to -Subject $subject -Body $body -BodyAsHtml
                 send-MailMessage -SmtpServer $smtp -From $from1 -To $to1 -Subject $subject1 -Attachments $attachment -Body $body1 -BodyAsHtml
                 write-host "Copy Sucessfull"
    How can I make this work for our new Office365?
    Thank you.

    I tried converting it with Get-MessageTrackingLog but I get this error. Can someone help me out on the conversion of this script:
    A parameter cannot be found that matches parameter name 'ResultSize':
    +CategoryInfo : InvalidArgument: <:> [Get-MessageTrace], ParameterBindingException
    + FullyQualifiedErrorID: NamedParameterNotFound, Get-MessageTrace
    + PSComputerName: xxxxxxxxx.outlook.com
    Thank you.
    Look at the link I posted for Get-MessageTrace.  
    It does not have the same parameters as Get-MessageTrackingLog.  
    You cannot specify an Event type, and Sender and Recipient addresses can only be filtered by either a list of addresses or a single wildcard string (you can't use multiple wildcards), so if you have multiple accepted domains you're either looking at late
    filtering or getting multiple traces, each one filtered on one accepted domain.
    Here's an example using late filtering. 
    $O365_SessionParams =
    ConfigurationName = 'Microsoft.Exchange'
    ConnectionUri = 'https://ps.outlook.com/powershell/'
    Authentication = 'Basic'
    AllowRedirection = $true
    # ErrorAction = 'Stop'
    # Credential = $Credential
    $O365_Session = New-PSSession @O365_SessionParams
    Import-PSSession $O365_Session -CommandName Get-MessageTrace
    $TraceParams =
    StartDate = (Get-Date).AddDays(-1).ToShortDateString()
    EndDate = (Get-Date).ToShortDateString()
    PageSize = 1000
    # ErrorAction = 'Stop'
    $AcceptedDomains = '@company\.com$|@company-1\.com$'
    $TraceResults =
    Get-MessageTrace @TraceParams |
    Where-Object { ($_.SenderAddress -match $AcceptedDomains) -and
    ($_.RecipientAddress -notmatch $AcceptedDomains) }
    That was copied from script I have message tracing, and those Credential and ErrorAction parameters are for accepting alternate credentials and error handling in the script, and I left that code out for the example, so they've been commented.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Connect Office 365 Exchange Online through Powershell

    I am trying to perform some operations on Exchange online(Office 365) through powershell.
    First I created a new powershell session and exported the modules to local as "o365", so that on any later operation I no need to use Import-PsSession to download the required modules
    $cred = Get-Credential
    $s = New-PSSession -ConfigurationName "Microsoft.Exchange" -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
    Export-PsSession -session $s -outputModule o365
    Now, I am creating new session and importing the existing module "o365".
    $cred = Get-Credential
    $s = New-PSSession -ConfigurationName "Microsoft.Exchange" -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
    Import-Module o365
    Get-DistributionGroup
    While running the command "Get-DistributionGroup", powershell prompts me to enter the office 365 credentials once again. Is it possible to avoid entering the credentials once again? I don't want to use Import-PsSession, since it takes more time.

    Hi,
    Not sure, if the following cmdlets can make a difference. Anyway, suggest you to try these:
    $UserCredential = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
    Import-PSSession $SessionGet-DistributionGroup
    Regards from ExchangeOnline.in|Windows Administrator Area | Skype:[email protected]

  • Office 365 Exchange

    Guys,
    I am testing Office 364 Exchange. According to the manual, I need to change the dns servers from my hostingprovidor into ns1.bdm.microsoftonline.com  and ns2.bdm.microsoftonline.com . But when I do that, my website isn't available anymore.
    So, I would like to use office 365 and exchange but I would like to keep my website @ my hostingprovidor.How an I get that done?
    regards,

    Hi,
    You do not need to change the NS record to be able to test Office 365.
    The only reason for doing so, is to let Office 365 manage you DNS entirely.
    http://office.microsoft.com/en-us/office365-suite-help/verify-your-domain-and-change-name-servers-at-any-dns-hosting-provider-or-domain-registrar-HA103480040.aspx
    What you probably want is to just change MX, and a few CNAMEs and some SRV records. You get the values for the records if you add your domain in the Office 365 admin center.
    Take a look at these two support documents.
    http://office.microsoft.com/en-us/office365-suite-help/add-your-domain-to-office-365-HA102818660.aspx
    http://office.microsoft.com/en-us/office365-suite-help/create-dns-records-at-any-dns-hosting-provider-for-office-365-HA103479204.aspx
    Hope this helps :)
    /Anders Eide

  • Office 365 Exchange ActiveSync Autodiscovery & iPad

    Hi All,
    The story:
    We have configured Hybrid coexistence of our local exchnage server and office 365.
    We are experiencing the problem with the configuring office 365 account using exchange activesync autodiscovery settings on the iPads and iPhones.
    Outlook desktop clients are able to locate the settings automatically.
    Only device which can locate servername and settings automatically using actiesync autodiscover is Windows Phone Device.
    Per Microsoft:
    Certain mobile device that won't autoconfigure this problem occurs if the mobile device does not fully support certain Exchange ActiveSync protocol requirements for redirection. Since we are not the provider of the OS for these devices we apologize as we cannot troubleshoot beyond the information provided to configure mobile devices.
    This is a problem for us. Because if we want to migrate user's mailbox to cloud and he has configured the ActiveSync account after migration he need to reconfigure his active sync profile on his mobile device.
    Can someone confirm that iOs devices might not fully support certain Exchange ActiveSync protocol requirements from Microsoft for redirection?

    Hi
    http://blogs.technet.com/b/canitpro/archive/2013/11/20/step-by-step-migrating-from-exchange-2007-to-office-365.aspx
    Hope this helps. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Email address missing from account info in Office 365 exchange console, unable to access inbox

    Hi
    we have successfully migrated our on premise Exchange environment to Office 365. We came from a 3 domain environment and we are having some issues accessing accounts. I have tried to add the smtp:[email protected] address using ADSI Edit but after
    DirecSync, I'm not able to locate this address on the account. is there a different way to add email address to Office 365 accounts?

    I would recommend asking them in Office 365  forum: http://community.office365.com/en-us/f/default.aspx
    This posting is provided AS IS with no warranties or guarantees , and confers no rights.
    Ahmed MALEK
    My Website Link
    My Linkedin Profile
    My MVP Profile

Maybe you are looking for

  • IPod and iTunes 7 issues

    I have a 3g iPod. I have a G5 mac which I mistakenly upgraded to iTunes version 7.0.2. Since upgrading to version 7 I have major problems when trying to transfer music to my Ipod. I can transfer 1 song, then the rainbow spinner comes up and says it i

  • PSE 5 - Which Camera Raw Do I need

    I have been searching the Adobe site and several forums with no luck. I have a Canon EOS 50D and PSE 5.0. Does anyone know whick Camera Raw version works with this combo?

  • How to write code in smartforms

    Hello Abapers, I am new to smartform.I dont know where to declare internal tables,Data fetchings(selection queries) for headers and line items from database. what to declare in <b>form interface</b> and in <b>global definitions</b>. Please Give your

  • Installation of Adobe Reader on my mac?

    Hello, I can't install Adobe Reader on my Mac Mini. This prohibits me from printing PDF files. Any assistance would be appreciate

  • Help me, I can't refresh oracle connection

    14:07:23.88 Warn: ORA: 22151: ora-22151-1076128096-fresher00831: Last autorefresh for interval 1000 ms has not finished after 60000 ms 14:07:27.05 Info: ORA: 22151: ora-22151-1078729056-eporter00372: object_id 47506, bookmark 0 14:07:37.03 Info: ORA: