diff --git a/Get-UserReport.ps1 b/Get-UserReport.ps1 new file mode 100644 index 0000000..4f0568f --- /dev/null +++ b/Get-UserReport.ps1 @@ -0,0 +1,40 @@ +$LogonEmail = Read-Host "Enter Logon Email" +Connect-ExchangeOnline -UserPrincipalName $LogonEmail +Connect-MgGraph -Scopes "Directory.Read.All" + +Class User { + [string]$DisplayName + [string]$UserPrincipalName + [string]$Mail + [string]$AccountId + [string]$Id + [string]$SkuId + [string]$SkuPartNumber + [string]$Aliases +} + + +$accounts = Get-mgUser | Select-Object DisplayName,UserPrincipalName,Mail,Id + +$Users = +ForEach ($account in $accounts){ + $User = [User]::new() + $User.DisplayName = $account.DisplayName + $User.UserPrincipalName = $account.UserPrincipalName + $User.Mail = $account.Mail + $User.Id = $account.Id + + $licence = Get-MgUserLicenseDetail -UserId $account.UserPrincipalName + $User.SkuId = $licence.SkuId + $User.SkuPartNumber = $licence.SkuPartNumber + + $mailbox = Get-Mailbox -Identity $account.UserPrincipalName | Select-Object DisplayName,@{Name="EmailAddresses";Expression={$_.EmailAddresses | Where-Object {$_ -LIKE "SMTP:*"}}} + $User.Aliases = $mailbox.EmailAddresses + + $User +} + +$Users | Select-Object DisplayName,UserPrincipalName,SkuPartNumber,Mail,Aliases | ConvertTo-Csv | Out-File ".\UsersReport.csv" + +Disconnect-MgGraph +Disconnect-ExchangeOnline diff --git a/Install-MicrosoftGraph.ps1 b/Install-MicrosoftGraph.ps1 new file mode 100644 index 0000000..7adeabc --- /dev/null +++ b/Install-MicrosoftGraph.ps1 @@ -0,0 +1 @@ +Install-Module -Name Microsoft.Graph diff --git a/Replace-GroupMembers.ps1 b/Replace-GroupMembers.ps1 new file mode 100644 index 0000000..ad1f914 --- /dev/null +++ b/Replace-GroupMembers.ps1 @@ -0,0 +1,12 @@ +Connect-ExchangeOnline + +$newnames = Import-Csv "" #Path to CSV with 1 column called 'Name' with the list of UserPrincipleNames to be added to the group + +$group = "" #Name of the Group + +$oldnames = Get-UnifiedGroupLinks -Identity $group -LinkType Members + +ForEach ($oldname in $oldnames){Remove-UnifiedGroupLinks -Identity $group -LinkType Members -Links $oldname.name -Confirm $true} + +ForEach ($newname in $newnames){Add-UnifiedGroupLinks -Identity $group -LinkType Members -Links $newname.Name} +