Share via

Cannot use PowerShell to block access to multiple user accounts

Anonymous
2016-07-19T03:56:55+00:00

Hi Microsoft,

We would like to block multiple users account to access to Office 365 by PowerShell. By this KB:

https://technet.microsoft.com/en-us/library/mt628066.aspx

After I connect to Office 365 and run this command

Get-Content "D:\UserBlock.txt" | Set-MsolUser -UserPrincipalName $_.UserPrincipalName -BlockCredential $true

Then we found this error:

Set-MsolUser : The input object cannot be bound to any parameters for the command either because the command does not

take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

At line:1 char:34

  • ... lock.txt" | Set-MsolUser -UserPrincipalName $_.UserPrincipalName -Blo ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (******@tnc2016.onmicrosoft.com:PSObject) [Set-MsolUser], ParameterBindi

   ngException

    + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.Online.Administration.Automation.SetUser

Set-MsolUser : The input object cannot be bound to any parameters for the command either because the command does not

take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

At line:1 char:34

  • ... lock.txt" | Set-MsolUser -UserPrincipalName $_.UserPrincipalName -Blo ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (******@tnc2016.onmicrosoft.com:PSObject) [Set-MsolUser], ParameterBindi

   ngException

    + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.Online.Administration.Automation.SetUser

As we notice, I type this command correctly and txt file is no problem. Please recommend how to resolve this problem.

Regards,

Thanachart R.

Microsoft 365 and Office | Subscription, account, billing | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-07-19T08:32:51+00:00

Hi Thanachart,

Thanks for your feedback, we will report the content issue in this TechNet article to related teams. For now, you may achieve this requirement via the steps below

  1. Create a txt file like this: (Add UserPrincipalName at the top line of the TXT)

  1. After Connecting to Office 365, run this command in PowerShell.

Import-Csv C:\My Documents\Accounts.txt | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -BlockCredential $true}

Note: C:\My Documents\Accounts.txt is the Path for the TXT file in step 1

Thanks,

Frank

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2016-07-20T16:29:26+00:00

    Hi Frank,

    It's successfully.

    Thanks

    Thanachart R.

    Was this answer helpful?

    0 comments No comments