update
This commit is contained in:
34
Azure Active Directory/Get-AadGroups.ps1
Normal file
34
Azure Active Directory/Get-AadGroups.ps1
Normal file
@ -0,0 +1,34 @@
|
||||
$creduser = Read-Host "Admin email"
|
||||
$credpassword = Read-Host "Admin Password"
|
||||
|
||||
[securestring]$secStringPassword = ConvertTo-SecureString $credpassword -AsPlainText -Force
|
||||
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($creduser, $secStringPassword)
|
||||
|
||||
Connect-AzureAD -Credential $credObject
|
||||
|
||||
$Table = New-Object 'System.Collections.Generic.List[System.Object]'
|
||||
|
||||
$Groups = Get-AzureAdGroup -All $True | Where-Object { $_.MailEnabled -eq $false -and $_.SecurityEnabled -eq $true } | Sort-Object DisplayName
|
||||
|
||||
$obj1 = [PSCustomObject]@{
|
||||
'Name' = 'Security Group'
|
||||
'Count' = $Groups.count
|
||||
}
|
||||
|
||||
$obj1
|
||||
|
||||
Foreach ($Group in $Groups) {
|
||||
$Users = (Get-AzureADGroupMember -ObjectId $Group.ObjectID | Sort-Object DisplayName | Select-Object -ExpandProperty DisplayName) -join ", "
|
||||
$GName = $Group.DisplayName
|
||||
|
||||
$hash = New-Object PSObject -property @{ Name = "$GName"; Members = "$Users" }
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
'Name' = $GName
|
||||
'Members' = $users
|
||||
}
|
||||
|
||||
$table.add($obj)
|
||||
}
|
||||
|
||||
$table | Export-Csv -Path "Groupe-SharePoint.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation
|
12
Azure Active Directory/Get-MsolUser.ps1
Normal file
12
Azure Active Directory/Get-MsolUser.ps1
Normal file
@ -0,0 +1,12 @@
|
||||
# Demande un nom d'utilisateur
|
||||
$User = read-host -Prompt "User Name"
|
||||
|
||||
# Obtenir les infos de l'utilisateur
|
||||
$user_dn = (get-mailbox $user).distinguishedname
|
||||
|
||||
# Liste des liste de distribution
|
||||
"User " + $User + " is a member of the following groups:"
|
||||
foreach ($group in get-distributiongroup -resultsize unlimited) {
|
||||
if ((get-distributiongroupmember $group.identity | select -expand distinguishedname) -contains $user_dn) { $group.name }
|
||||
|
||||
}
|
37
Azure Active Directory/Import-MsolUsers.ps1
Normal file
37
Azure Active Directory/Import-MsolUsers.ps1
Normal file
@ -0,0 +1,37 @@
|
||||
# Import active directory module for running AD cmdlets
|
||||
Import-Module MSOnline
|
||||
|
||||
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||
$AADUsers = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||
|
||||
#Loop through each row containing user details in the CSV file
|
||||
foreach ($User in $AADUsers) {
|
||||
|
||||
$FullName = "$($User.firstname) $($User.lastname)"
|
||||
|
||||
if ((Get-MsolUser -UserPrincipalName $User.username -ErrorAction SilentlyContinue)) {
|
||||
Write-Warning "A user account with UPN $($User.username) already exist in Azure Active Directory."
|
||||
}
|
||||
elseif (([string]::IsNullOrEmpty($User.password))) {
|
||||
Write-Warning "The password for $($User.username) is nul or empty."
|
||||
}
|
||||
else {
|
||||
try {
|
||||
New-MsolUser -DisplayName $FullName `
|
||||
-FirstName $User.FirstName `
|
||||
-LastName $User.LastName `
|
||||
-UserPrincipalName $User.Username `
|
||||
-UsageLocation $User.UsageLocation `
|
||||
-LicenseAssignment $User.AccountSkuId `
|
||||
-Password $user.password `
|
||||
-City $User.City `
|
||||
-Department $User.Department `
|
||||
-PasswordNeverExpires $true `
|
||||
-ForceChangePassword $False
|
||||
Write-Host "The user $($User.firstname) $($User.lastname) ($($User.username)) was created."
|
||||
}
|
||||
catch {
|
||||
Write-Error "The user $($User.firstname) $($User.lastname) ($($User.username)) was not created."
|
||||
}
|
||||
}
|
||||
}
|
29
Azure Active Directory/MSolLicences.ps1
Normal file
29
Azure Active Directory/MSolLicences.ps1
Normal file
@ -0,0 +1,29 @@
|
||||
$License = 'hitea:STANDARDPACK'
|
||||
$EnabledPlans = @(
|
||||
'TEAMS1'
|
||||
'WHITEBOARD_PLAN1'
|
||||
)
|
||||
$Exclusions = @(
|
||||
'Sync_ADCONNECT1@hitea.onmicrosoft.com'
|
||||
)
|
||||
$AllPlans = (Get-MsolAccountSku | Where-Object { $_.AccountSkuId -eq $License } | Select-Object -ExpandProperty ServiceStatus).ServicePlan.ServiceName
|
||||
$DisabledPlans = $AllPlans | Where-Object { $EnabledPlans -notcontains $_ }
|
||||
$E1CustomizedLicense = New-MsolLicenseOptions -AccountSkuId $License -DisabledPlans $DisabledPlans
|
||||
$Users = Get-MsolUser -UnlicensedUsersOnly -All -EnabledFilter EnabledOnly
|
||||
foreach ($User in $Users) {
|
||||
if ($User.UsageLocation -ne 'FR') {
|
||||
Set-MsolUser -UserPrincipalName $User.UserPrincipalName -UsageLocation PL
|
||||
}
|
||||
if ($User.IsLicensed -eq $false -and $Exclusions -notcontains $User.UserPrincipalName) {
|
||||
Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $License -LicenseOptions $E1CustomizedLicense
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$LicensePlans = Get-MsolAccountSku | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
LicenseName = $_.AccountSkuId
|
||||
Plans = $_.ServiceStatus.ServicePlan.ServiceName -join ', '
|
||||
}
|
||||
}
|
||||
$LicensePlans | Format-Table -AutoSize
|
1370
Azure Active Directory/O365HTMLReport.ps1
Normal file
1370
Azure Active Directory/O365HTMLReport.ps1
Normal file
File diff suppressed because it is too large
Load Diff
1
Azure Active Directory/README.md
Normal file
1
Azure Active Directory/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Azure Active Directory
|
10
Azure Active Directory/Set-MsolUsersPassword.ps1
Normal file
10
Azure Active Directory/Set-MsolUsersPassword.ps1
Normal file
@ -0,0 +1,10 @@
|
||||
# Import active directory module for running AD cmdlets
|
||||
Import-Module MSOnline
|
||||
|
||||
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||
$AADUsers = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||
|
||||
#Loop through each row containing user details in the CSV file
|
||||
foreach ($User in $AADUsers) {
|
||||
Set-MsolUserPassword -UserPrincipalName $User.Username -NewPassword $user.password -ForceChangePassword $false
|
||||
}
|
17
Azure Active Directory/Set-Upn.ps1
Normal file
17
Azure Active Directory/Set-Upn.ps1
Normal file
@ -0,0 +1,17 @@
|
||||
$creduser = Read-Host "Admin email"
|
||||
$credpassword = Read-Host "Admin Password"
|
||||
|
||||
[securestring]$secStringPassword = ConvertTo-SecureString $credpassword -AsPlainText -Force
|
||||
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($creduser, $secStringPassword)
|
||||
|
||||
$Users = Import-Csv -Path "Set-Upn.csv" -Delimiter ";" -Encoding UTF8
|
||||
|
||||
Connect-MsolService -Credential $credObject
|
||||
|
||||
foreach ($User in $Users) {
|
||||
|
||||
Write-host "Changement de $($User.Upn) pour $($User.NewUpn)"
|
||||
|
||||
Set-MsolUserPrincipalName -UserPrincipalName $($User.Upn) -NewUserPrincipalName $($User.NewUpn)
|
||||
|
||||
}
|
26
Azure Active Directory/Set-UsersLIcences.ps1
Normal file
26
Azure Active Directory/Set-UsersLIcences.ps1
Normal file
@ -0,0 +1,26 @@
|
||||
# Importer le fichier CSV
|
||||
$users = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||
|
||||
# Get-MsolAccountSku
|
||||
|
||||
# Renseigner le SKU de la licence
|
||||
$accountSkuId = "reseller-account:O365_BUSINESS_PREMIUM"
|
||||
|
||||
# Renseigner les options déactivées
|
||||
# Get-MsolAccountSku | select -ExpandProperty ServiceStatus
|
||||
$BannedList = @("MICROSOFTBOOKINGS", "KAIZALA_O365_P2", "Deskless", "PROJECTWORKMANAGEMENT", "POWERAPPS_O365_P1", "DYN365BC_MS_INVOICING", "O365_SB_Relationship_Management", "STREAM_O365_SMB", "SWAY", "YAMMER_ENTERPRISE")
|
||||
|
||||
$licenseOptions = New-MsolLicenseOptions -AccountSkuId $accountSkuId -DisabledPlans $BannedList
|
||||
|
||||
# Définir les licences pour les utilisateurs
|
||||
ForEach ($user in $users) {
|
||||
|
||||
$upn = $user.Username
|
||||
|
||||
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $accountSkuId
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $licenseOptions
|
||||
|
||||
}
|
6
Azure Active Directory/Templates/Import-MsolUsers.csv
Normal file
6
Azure Active Directory/Templates/Import-MsolUsers.csv
Normal file
@ -0,0 +1,6 @@
|
||||
FirstName;LastName;AccountSkuId;UsageLocation;Username;Password;City;Department
|
||||
Paul;Dupont;reseller-account:O365_BUSINESS_PREMIUM;FR;p.dupont@hitea.fr;Test123Test1;AGEN;
|
||||
Bernard;Durand;reseller-account:O365_BUSINESS_PREMIUM;FR;b.durand@hitea.fr;Test123Test2;AGEN;
|
||||
David;Bellier;reseller-account:O365_BUSINESS_PREMIUM;FR;d.bellier@hitea.fr;Test123Test3;AGEN;
|
||||
Joël;Tartas;reseller-account:O365_BUSINESS_PREMIUM;FR;j.tartas@hitea.fr;Test123Test4;AGEN;
|
||||
Benoît;Canu;reseller-account:O365_BUSINESS_PREMIUM;FR;b.canu@hitea.fr;Test123Test5;AGEN;
|
|
4
Azure Active Directory/Templates/Set-Upn.csv
Normal file
4
Azure Active Directory/Templates/Set-Upn.csv
Normal file
@ -0,0 +1,4 @@
|
||||
Upn;NewUpn
|
||||
user1@olddomain.com;user1@newdomain.com
|
||||
user2@olddomain.com;user2@newdomain.com
|
||||
user3@olddomain.com;user3@newdomain.com
|
|
Reference in New Issue
Block a user