Ultimate PowerShell Guide: Active Directory User Management Made Easy

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 12

  • @No1001-w8m
    @No1001-w8m 5 місяців тому +2

    Yes, we want longer video on get-aduser and set-aduser :D

    • @mwcloud
      @mwcloud  5 місяців тому +1

      @@No1001-w8m okay, I’ll sort one out with a bit of scripting how to in there too for making lots of user accounts and adding people to groups and what not

  • @supriyochatterjee4095
    @supriyochatterjee4095 5 місяців тому +3

    Always great information, wish to see lots of PowerShell deep dive videos covering various troubleshooting aspects and scenarios in AWS and Azure using PowerShell and how to use PowerShell in those cloud environments conveniently.

    • @mwcloud
      @mwcloud  5 місяців тому +3

      @@supriyochatterjee4095 ok I will try and make in the future

    • @supriyochatterjee4095
      @supriyochatterjee4095 5 місяців тому +1

      @@mwcloud Thanks, much appreciated.

  • @ehlinna_4612
    @ehlinna_4612 5 місяців тому +3

    Nice video bro

    • @mwcloud
      @mwcloud  5 місяців тому +1

      Thanks

  • @srinivas1623
    @srinivas1623 5 місяців тому +1

    HI MIke thanks for nice videos if possible could u please do some realtime scnarios for devops enginner please interview prospect

    • @mwcloud
      @mwcloud  5 місяців тому +1

      What do you mean by realtime scenarios ?

    • @srinivas1623
      @srinivas1623 5 місяців тому +1

      @@mwcloud what kind of activities we do using powershell to automate some the tasks as devops engineer some scenarios

    • @cat19649
      @cat19649 Місяць тому

      @@mwcloud request: create x# of new accounts. reality of admin: some accounts already exist, some need email updated, some need name updated.

    • @mwcloud
      @mwcloud  Місяць тому

      @@cat19649 Here
      # Define the path to the CSV file
      $csvFilePath = "C:\Scripts\Users.csv"
      # Import the CSV
      if (Test-Path $csvFilePath) {
      $users = Import-Csv -Path $csvFilePath
      } else {
      Write-Error "CSV file not found at $csvFilePath"
      exit
      }
      # Loop through each user in the CSV
      foreach ($user in $users) {
      # Check if the user already exists
      $existingUser = Get-ADUser -Filter {SamAccountName -eq $user.SamAccountName} -ErrorAction SilentlyContinue
      if ($existingUser) {
      Write-Host "User $($user.SamAccountName) already exists. Skipping..." -ForegroundColor Yellow
      continue
      }
      # Create a new user
      try {
      New-ADUser `
      -SamAccountName $user.SamAccountName `
      -UserPrincipalName "$($user.SamAccountName)@yourdomain.com" `
      -GivenName $user.GivenName `
      -Surname $user.Surname `
      -Name $user.DisplayName `
      -DisplayName $user.DisplayName `
      -AccountPassword (ConvertTo-SecureString $user.Password -AsPlainText -Force) `
      -Enabled $true `
      -Path $user.OU
      Write-Host "User $($user.SamAccountName) created successfully." -ForegroundColor Green
      } catch {
      Write-Error "Failed to create user $($user.SamAccountName). Error: $_"
      }
      }
      and here is example data for the csv
      SamAccountName,GivenName,Surname,DisplayName,Password,OU
      jdoe,John,Doe,John Doe,P@ssw0rd1,OU=Users,DC=example,DC=com
      asmith,Alice,Smith,Alice Smith,P@ssw0rd2,OU=IT,DC=example,DC=com
      bwhite,Bob,White,Bob White,P@ssw0rd3,OU=HR,DC=example,DC=com
      kpatel,Karen,Patel,Karen Patel,P@ssw0rd4,OU=Finance,DC=example,DC=com
      tgreen,Tom,Green,Tom Green,P@ssw0rd5,OU=Marketing,DC=example,DC=com