added new scripts

This commit is contained in:
Bobban
2023-07-23 17:04:57 +02:00
parent f4bc2c2394
commit 515ba781cb
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
name,
firstname lastname
1 name,
2 firstname lastname

View File

@@ -0,0 +1,19 @@
Import-Module ActiveDirectory
$AdminUsers = Import-Csv -Path "C:\Temp\New-admins.csv" -Encoding UTF8 -delimiter ","
$AdminUPNAddress = "upnadress"
$UsernamePrefix = "suffix"
$AdminOU = "oupath"
foreach ($Adminuser in $AdminUsers)
{
$AdminFistname,$AdminLastname = ($Adminuser.name).Split(" ")
$AdminUsernamePart = $AdminFistname.substring(0,2)+$AdminLastname.substring(0,2)
#$AdminDisplayName = $AdminFistname $AdminLastname
$AdminUsername = "$UsernamePrefix.$AdminUsernamePart"
New-ADUser -DisplayName "ADM - $AdminFistname $AdminLastname" -Name "ADM - $AdminFistname $AdminLastname" -GivenName "$AdminFistname" -Surname "$AdminLastname" -SamAccountName "$AdminUsername" -UserPrincipalName "$AdminUsername@$AdminUPNAddress" -Path "$AdminOU" -AccountPassword(ConvertTo-SecureString "2de!9F&y$!xCUvbB" -AsPlainText -force) -Enabled $true -Description "autocreated account"
Add-ADGroupMember -Identity "Tietoevry-Servicedesk" -Members $AdminUsername
Write-Output "ADM - $AdminFistname $AdminLastname - $AdminUsername";
}

View File

@@ -0,0 +1,18 @@
$Info = @()
$AAD_users = Get-AzureADUser -All:$true
foreach ($AAD_User in $AAD_users) {
$objInfo = [PSCustomObject]@{
Name = $AAD_User.DisplayName
Email = $AAD_User.mail
userType = $AAD_User.userType
jobTitle = $AAD_User.jobTitle
accountEnabled = $AAD_User.accountEnabled
Country = $AAD_User.Country
creationType = $AAD_User.creationType
UserState = $AAD_User.UserState
CreationDateTime = (Get-AzureADUserExtension -ObjectId $AAD_User.ObjectId).Get_Item("createdDateTime")
#signin = (Get-AzureADAuditSignInLogs -Filter userId = $AAD_User.ObjectId and status/errorCode eq 0 | Select CreatedDateTime -First 1)
}
$Info += $objInfo
}
$Info | Export-csv -Path "c:\temp\AzureADUsers.csv" -NoTypeInformation -Force -Append -Encoding UTF8