PowerShell Local Account Delete


    Command to remove local account from machine/s

    Gets input from file and removes local account from machine

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

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

  # Import List of Computers and Accounts  
  $MyData=Import-CSV C:\TEMP\Remove_LocalAccount.csv
  # Loop through records 
  Foreach($Computer in $MyData){   
      # Command to delete local computer account 
      $MyCommand={Net USER $Args /Delete}
      # Executes command on machines from file
      Invoke-Command $Computer.Server -ScriptBlock $MyCommand -ArgumentList $Computer.Account