I am trying to run a powershell Office365 command "(Get-MsolUser -UserPrincipalName $test).Licenses.ServiceStatus" from a csv input.
My scripts looks like
$test = Import-Csv -Path "C:\temp\test.csv"
ForEach ($tests in $test)
{
(Get-MsolUser -UserPrincipalName $test).Licenses.ServiceStatus
}
The command runs fine if i put a user principle name instead of $test "(Get-MsolUser -UserPrincipalName Test@test.com).Licenses.ServiceStatus"
Could you please advise how can i run this command using csv input
Error that i get is
PS C:\WINDOWS\system32> (Get-MsolUser -UserPrincipalName $test).Licenses
Get-MsolUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'UserPrincipalName'.
Specified method is not supported.
At line:1 char:34
+ (Get-MsolUser -UserPrincipalName $test).Licenses
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-MsolUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Online.Administration.Automation.GetUser