Skip to main content

PoSh Disable and Move AD Users

A quick and easy way to disable user accounts and move them into designated OU:

  1. Import-Csv "C:\TEMP\users.csv" | ForEach-Object { `  
  2.     $u=$_."sAMAccountName"; $l="Disabling and moving: " +$u; write-output $l; `  
  3.     Get-ADUser -Identity $u | `  
  4.     Disable-ADAccount -PassThru | `  
  5.     Move-ADObject -TargetPath "OU=Disabled Users,OU=Organization,DC=domain,DC=local"  

Input is provided via a CSV file:

users.csv (username)
  1. sAMAccountName  
  2. jdoe1  
  3. jdoe2  
  4. jdoe3  
  5. jdoe4  
  6. jdoe5  


To generate input file run something like this, review and edit as necessary:

  1. Search-ADAccount –UsersOnly –AccountInactive –TimeSpan 180.00:00:00 | `  
  2.     where {$_.enabled} | `  
  3.     Get-ADUser | `  
  4.     select sAMAccountName | `  
  5.     Export-Csv -Path "C:\TEMP\users.csv"  

Comments

  1. how do you spend your free time i play great best game slot online so this site is the best I've met

    ReplyDelete

Post a Comment

Popular posts from this blog

  Copilot Studio: Capabilities, Strategies, Scenarios 💡 Ready to Supercharge Your Team with AI? 🧠 A critical question for every leader: How do you transform the massive potential of AI into a practical, powerful, and cost-effective tool for your entire organization? 🤔 This guide explores various nuances of the AI adoption: 1️⃣ The Innovation Opportunity: The drive to deploy generative AI is reshaping the modern workplace, offering a monumental leap in productivity and creativity. This is the moment to empower your teams. 🚀 2️⃣ The Strategic Blueprint: Unlocking this potential requires a clear strategy. Navigating the licensing models for powerful tools like Microsoft Copilot Studio is the key to maximizing value and avoiding unexpected costs. 🗺 ️▶️ Our new interactive guide makes it simple. We break down the licensing paths, visualize the costs, and provide a clear, actionable roadmap for implementing a winning hybrid AI strategy. See how you can empower everyone, from citizen...
  AI Agents as Trusted IoT/Software Defined Devices 🤖 Your Newest Endpoint Isn’t a Laptop; It’s an AI Agent. Are You Ready to Secure It? Dive into the next frontier of cybersecurity. Autonomous AI agents are no longer just code; they are powerful actors in our digital ecosystems. Treating them as simple software leaves a massive security gap. Our latest report introduces a new paradigm: The AI Agent as a Software-Defined Device. Discover the essential framework for securing the agentic future: ➡️ The Agent-as-Device Model: Learn why abstracting agents as software-defined devices, similar to IoT endpoints, is the key to managing their complexity and risk. Secure the “hardware” (host), “software” (agent logic), and “network” (communications). ➡️ A Digital Passport for AI: Move beyond static API keys. Explore how Decentralized Identifiers (DIDs) and Verifiable Credentials (VCs) create a cryptographic root of trust, giving every agent a verifiable identity and provable permissions. ➡️...
  AI Trends in DevSecOps 🤖 The AI Co-Developer Is Here: Is Your DevSecOps Ready? Dive into the symbiotic evolution of AI and DevSecOps. While AI coding assistants are accelerating development at an incredible pace, they’re also scaling security risks and introducing a new, complex attack surface. Discover the critical shifts redefining secure software development: ➡️ Secure the Foundation First: Learn why 99% of organizations have sensitive data exposed and how to tame the “blast radius” of GenAI tools before deployment by focusing on data security posture. ➡️ The Intelligent IDE: Move beyond just finding flaws. See how AI-generated fixes are revolutionizing secure coding by slashing remediation times and empowering developers to fix vulnerabilities in seconds. ➡️ The War on Noise: Understand how AI is finally solving the false positive problem in CI/CD pipelines, making fully automated security gates an operational reality. ➡️ Think Like the Adversary: Explore the rise of AI Red ...