Categories
Admin Tools Powershell Remote Access Technology

Killing Processes in Windows Remotely

Sometimes I have a workstation that is not responsive, and I have to find a way remotely to find the issue, kill a process and sometimes reboot the windows computer.

  • Open a remote command prompt to the windows computer
  • Run the command tasklist | more
  • find the process PID id. I like to look for processes that are taking the largest amount of memory, or most open sessions
  • Run the command taskkill /F /PID 5411
  • Note 5411 was just a PID number that was in the task list. the PID (Process Identifier) will be different for you for each process.
  • If the computer still does not respond, sometimes you have to force a reboot. Run: shutdown /r /f r is for restart and f is for force

To open a remote command to a windows computer get online and do some searching, many ways to do that with windows. PSExec and Powershell are common ways to do this.

Categories
Powershell Technology

Update Active Directory Users from csv file

 $userUpdate = Import-Csv -Delimiter "," -Path ("c:\FaxNumberUpdate.csv")
$rowCount = 1
foreach($user in $userUpdate){
    Write-Host  ($rowCount.ToString() + ") Update " + $($user.DisplayName) + " to " + $($user.Fax))
    # Find user
    $ADUser = Get-ADUser -Filter "displayname -eq '$($user.name)'" 

    if ($ADUser){
        Set-ADUser -Identity $ADUser -Fax $user.fax
        Write-Host  ($rowCount.ToString() + ") Completed Update " + $($user.name) + " to " + $($user.fax))
    }else{
        Write-Warning ("Failed to update " + $($user.name))
    }
    $rowCount = $rowCount + 1
}
 

The idea is to have a CSV file with column headers, and powershell reads the CSV file into memory, assigns the memory a label called $userUpdate. Then iterates through the memory label $userUpdate row by row finding a matching AD user (Get-ADUser -Filter) matching the AD value called displayname to the spreadsheet column cell being read with the header named “name”. Its case sensitive. Set-ADUser does the actual update updating the matched $ADUser.