PowerShell Enable Disable Delete


    Command to Enabled / Disable Local Account from Machine/s

    Gets input from file and Enables / Disables local Account

    Run script with rights on machines
    Have correctly prepared CSV file for input

    Header--> Server,Account
    Data  --> Servername1,TestAccount

    Update Syntax as Needed:

  # Import List of Computers and Accounts  
  $MyData=Import-CSV C:\TEMP\Enable_LocalAccount.csv
  # Command to enable local computer account 
      Net User $Args /active:yes 
      Get-WMIObject Win32_UserAccount -Filter "Name='$Args'" | Select Caption, Disabled
  # Loop through records 
  Foreach($Computer in $MyData){
      # Executes command on machines from file
      Invoke-Command $Computer.Server -ScriptBlock $MyCommand -ArgumentList $Computer.Account | Format-Table | Out-File C:\temp\MyFile.csv -Append

2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator