This commit is contained in:
2023-07-04 12:59:44 +02:00
parent 2cef42a718
commit 09c2faad93
231 changed files with 261001 additions and 4 deletions

View 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

View 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 }
}

View 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."
}
}
}

View 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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
# Azure Active Directory

View 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
}

View 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)
}

View 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
}

View 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;
1 FirstName LastName AccountSkuId UsageLocation Username Password City Department
2 Paul Dupont reseller-account:O365_BUSINESS_PREMIUM FR p.dupont@hitea.fr Test123Test1 AGEN
3 Bernard Durand reseller-account:O365_BUSINESS_PREMIUM FR b.durand@hitea.fr Test123Test2 AGEN
4 David Bellier reseller-account:O365_BUSINESS_PREMIUM FR d.bellier@hitea.fr Test123Test3 AGEN
5 Joël Tartas reseller-account:O365_BUSINESS_PREMIUM FR j.tartas@hitea.fr Test123Test4 AGEN
6 Benoît Canu reseller-account:O365_BUSINESS_PREMIUM FR b.canu@hitea.fr Test123Test5 AGEN

View 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
1 Upn NewUpn
2 user1@olddomain.com user1@newdomain.com
3 user2@olddomain.com user2@newdomain.com
4 user3@olddomain.com user3@newdomain.com