Last active
October 13, 2018 05:21
-
-
Save queirozsc/89d14aac761f443476d9f871215c4dbc to your computer and use it in GitHub Desktop.
[Manipulando usuários do Office 365 via PowerShell] Comandos para manipular o Office 365. Fonte: https://docs.microsoft.com/pt-br/office365/enterprise/powershell/getting-started-with-office-365-powershell #office365 #powershell #azuread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-MsolAccountSku | |
(Get-MsolAccountSku | where {$_.AccountSkuId -eq "reseller-account:O365_BUSINESS_PREMIUM"}).ServiceStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-MsolUser -UserPrincipalName pedro.castro@hobrasil.com.br -BlockCredential $true | |
Get-MsolUser -UserPrincipalName pedro.castro@hobrasil.com.br | Select DisplayName,BlockCredential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Accounts.txt : | |
#akol@contoso.com | |
#tjohnston@contoso.com | |
#kakers@contoso.com | |
Get-Content Accounts.txt | ForEach { Set-MsolUser -UserPrincipalName $_ -BlockCredential $true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Command -Verb Get | |
Get-Command -Noun Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-MsolUser -All | where {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[5].ProvisioningStatus -ne "Disabled" -and $_.Licenses[0].ServiceStatus[8].ProvisioningStatus -ne "Disabled"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br" | Select-Object * | |
Get-MsolUser -All -UnlicensedUsersOnly | |
Get-MsolUser -All | where {$_.UsageLocation -eq $null} | |
Get-MsolUser -All -Department "Marketing" -UsageLocation "BR" -UnlicensedUsersOnly | |
Get-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br" | Select-Object UsageLocation | |
Get-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br" | Format-List DisplayName,Licenses | |
(Get-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br").Licenses.ServiceStatus | |
Get-MsolUser -All -ReturnDeletedUsers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userAccountUPN="sergio.queiroz@hobrasil.com.br" | |
$AllLicenses=(Get-MsolUser -UserPrincipalName $userAccountUPN).Licenses | |
$licArray = @() | |
for($i = 0; $i -lt $AllLicenses.Count; $i++) | |
{ | |
$licArray += "License: " + $AllLicenses[$i].AccountSkuId | |
$licArray += $AllLicenses[$i].ServiceStatus | |
$licArray += "" | |
} | |
$licArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module -Name AzureAD | |
Connect-AzureAD | |
Install-Module MSOnline | |
Connect-MsolService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-MsolUser -DisplayName "Sergio Carvalho Queiroz" -FirstName "Sergio" -LastName "Queiroz" -UserPrincipalName "sergio.queiroz@hobrasil.com.br" -UsageLocation "BR" -LicenseAssignment "reseller-account:SPE_F1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-MsolUserLicense -UserPrincipalName "sergio.queiroz@hobrasil.com.br" -AddLicenses "reseller-account:POWER_BI_PRO" | |
Get-MsolUser -All -UnlicensedUsersOnly | Set-MsolUserLicense -AddLicenses "reseller-account:SPE_F1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-AzureAD | |
Connect-MsolService | |
Set-MsolUser -UserPrincipalName "sergio.queiroz@hobrasil.com.br" -Title "Coordenador de TI" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fonte: https://docs.microsoft.com/pt-br/office365/enterprise/powershell/block-user-accounts-with-office-365-powershell