Emad Adel Hanna

I am a Cloud Solution Architect

Emad Adel

With over 15 years of experience in IT, I am a seasoned cloud solution architect and a Microsoft Certified Trainer. I currently work at KlayyTech, a leading IT company that provides cloud services and solutions to clients across various industries.
Erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper.

  • Cairo, Egypt
  • +20-12-4892008, +20-016-3008167
  • me@emadadel.com
  • it.emadadel@hotmail.com
  • www.emadadel.com
Me

My Professional Skills

I have successfully led numerous cloud migration projects, ensuring a smooth transition from on-premises to cloud-based environments. I also have expertise in cloud security and compliance, ensuring data protection and regulatory adherence. .

Microsoft Azure 90%
Microsoft 365 95%
Amazon AWS 70%
Enterprise Architect 60%

Training Services

I give people practical skills and knowledge for the workplace. It can help and improving their skills (Azure ,AWS , Microsoft 365 and SharePoint ).

IT consultant services

Helping businesses use technology to achieve their goals. and offer expertise in areas like cloud computing, cybersecurity, and software selection, and can improve efficiency, reduce risk, and save costs..

Professional Services

As and Azure expert and microsoft 365, I provide the best services, support and advice for all things Microsoft (Microsoft migration, support, and optimisation services).

Enterprise Architect services

help organizations align their IT infrastructure with business strategy. They basically design, evaluate, and build a blueprint for how technology supports the company's goals..

0
Completed project
0
Certifications Award
0
Success Training and Sessions
Completed Consultant projects
Showing posts with label ⚙️ Automation. Show all posts
Showing posts with label ⚙️ Automation. Show all posts
  • 📊 How to Get a Report of All Users and Devices Last Sign-In in Active Directory Using PowerShell 💻


    Active Directory (AD) is a critical component for IT administrators to manage users and devices in a network. 🚀 One common requirement is to generate reports on the last sign-in activity for users and devices in AD. 🔄 In this guide, I will show you how to use PowerShell to achieve this efficiently. 🔧


    📄 Prerequisites

    To follow this guide, you need:

    1. 💻 PowerShell installed on your system (version 5.1 or later).

    2. 📝 Active Directory PowerShell module installed.

    3. 🔒 Appropriate permissions to query Active Directory.


    🔢 PowerShell Commands to Get Last Sign-In Reports

    1. 👤 For Users

    The following command retrieves all users in Active Directory along with their last logon time:

    # Get all users and their last logon time
    Get-ADUser -Filter * -Property DisplayName, SamAccountName, LastLogonTimestamp |
    Select-Object DisplayName, SamAccountName, @{Name="LastLogon"; Expression={[datetime]::FromFileTime($_.LastLogonTimestamp)}} |
    Export-Csv -Path "C:\Reports\UsersLastSignIn.csv" -NoTypeInformation -Encoding UTF8
    • 🔍 What It Does:

      • Get-ADUser: Retrieves user information from AD.

      • -Filter *: Fetches all users.

      • LastLogonTimestamp: Retrieves the last logon time for each user.

      • Export-Csv: Exports the results to a CSV file for review.

    • 📈 Output: The command generates a CSV file named UsersLastSignIn.csv in the C:\Reports directory.

    2. 📚 For Devices

    Similarly, use the command below to get the last sign-in details for devices:

    # Get all computers and their last logon time
    Get-ADComputer -Filter * -Property Name, LastLogonTimestamp |
    Select-Object Name, @{Name="LastLogon"; Expression={[datetime]::FromFileTime($_.LastLogonTimestamp)}} |
    Export-Csv -Path "C:\Reports\DevicesLastSignIn.csv" -NoTypeInformation -Encoding UTF8
    • 🔍 What It Does:

      • Get-ADComputer: Retrieves computer information from AD.

      • LastLogonTimestamp: Retrieves the last logon time for each device.

      • Export-Csv: Saves the output to a CSV file named DevicesLastSignIn.csv.


    📊 Understanding the Commands

    • 🔹 LastLogonTimestamp vs. LastLogon:

      • LastLogonTimestamp: Replicated across domain controllers but may be up to 14 days old.

      • LastLogon: Real-time but requires querying all domain controllers.

    • 🔹 File Path: You can change the file path (C:\Reports\) to save the report to your preferred directory.


    🚨 Benefits of Using PowerShell

    • ⏳ Time-Saving: Automates a manual task.

    • 🎨 Customizable: You can add or remove properties as needed.

    • 📄 Portable Reports: The CSV files can be easily shared and analyzed.


    📚 Conclusion

    Using PowerShell to get reports on the last sign-in activity for users and devices in Active Directory is a straightforward and powerful approach. 🚀 These commands not only provide valuable insights but also save time by automating repetitive tasks.

    Try these commands in your environment and let me know in the comments if you have any questions or suggestions! 😊


    Tags: 🔧 PowerShell, 🔰 Active Directory, 🔒 IT Administration, 🌐 Last Logon Report, ⚙️ Automation