$users = Get-MsolUser how do I collect from a CSV into the variable $users ?

From Alan Byrne's Script (but I am trying to get just a few hundred users from a CSV)

Source: https://gallery.technet.microsoft.com/scriptcenter/Export-a-Licence-b200ca2a

$licensetype = Get-MsolAccountSku | Where {$_.ConsumedUnits -ge 1} 
# Loop through all licence types found in the tenant 
foreach ($license in $licensetype)  
    # Build and write the Header for the CSV file 
    $headerstring = "DisplayName,UserPrincipalName,AccountSku" 
    foreach ($row in $($license.ServiceStatus))  
        # Build header string 
        switch -wildcard ($($row.ServicePlan.servicename)) 
            "EXC*" { $thisLicence = "Exchange Online" } 
            "MCO*" { $thisLicence = "Lync Online" } 
            "RMS*" { $thisLicence = "Azure AD Rights Mgmt" }
            default { $thisLicence = $row.ServicePlan.servicename } 
        $headerstring = ($headerstring + "," + $thisLicence) 
    Out-File -FilePath $LogFile -InputObject $headerstring -Encoding UTF8 -append 
    write-host ("Gathering users with the following subscription: " + $license.accountskuid) 
    $users = Get-MsolUser -all | where {$_.isLicensed -eq "True"}

    $skuid = $license.accountskuid

	foreach ($user in $users) {
		$userLicences = $user.Licenses

        for ($i=0; $i -lt $($userLicences.count); $i++)
            $userSkuId = $userLicences[$i].AccountSkuId
            #write-host "$($user.DisplayName) , $userSkuId"

            if ($userSkuId -eq $skuid)
                write-host ("Processing " + $user.displayname)
                $datastring = ($user.displayname + "," + $user.userprincipalname + "," + $Sku.Item($userLicences[$i].AccountSku.SkuPartNumber))

		        foreach ($row in $($userLicences[$i].servicestatus)) {
			        # Build data string
			        $datastring = ($datastring + "," + $($row.provisioningstatus))
		        Out-File -FilePath $LogFile -InputObject $datastring -Encoding UTF8 -append

write-host ("Script Completed.  Results available in " + $LogFile)

Open in new window

Notice line 28 is the line I would like to use a CSV as apposed to "Get-MsolUser -All"

K BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
What for?  The result of the cmdlet is a complex hierarchical object array, and you can't have that structure in a CSV using standard methods.
What is the exact content of the CSV you want to use?  How do build it?

I assume what you really want to do is to have a text file with user names, and use those names against Get-MsolUser instead of the -all.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
That is, you would run
$users = Get-MsolUser (Get-Content c:\msolusers.txt) | where {$_.isLicensed -eq "True"}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.