Find the Current User Logged on Remote Computer and Take Action

Поделиться
HTML-код
  • Опубликовано: 20 авг 2024
  • In This video you will learn how to get user information logged on remote computer with the help of PowerShell script. you can use this script for two use case. First you can only get information about user logged on remotely and Second Base on the user information you get it from first part, you can either remove access or provide access as per your requirement.
    ======= Script Here =====
    $ComputerName = gc "C:\Scripts\LivePCs.txt"
    foreach ($comp in $ComputerName)
    {Get-CimInstance -ComputerName $comp -ClassName Win32_ComputerSystem | Select-Object Name, UserName | Export-Csv "C:\Scripts\RAWUser.csv" -Append -NoTypeInformation}
    $users = Import-Csv "C:\Scripts\RAWUser.csv"
    $users | where { $_.PsObject.Properties.Value -notcontains $null -and $_.PsObject.Properties.Value -notcontains '' } | Export-Csv "C:\Scripts\RDPUser.csv" -Append -NoTypeInformation
    $RDPUsers = import-csv "C:\Scripts\RDPUser.csv"
    foreach ($user in $RDPUsers)
    {
    $Computer = $user.Name
    $RDPUser = $user.UserName
    Invoke-Command -ComputerName $Computer -ScriptBlock{
    Add-LocalGroupMember -Group "Administrators" -Member $using:RDPUser
    }}
    ==========================
    Remove User Account or Group from Local Groups on Remote Computers
    • Remove User Account or...
    Automate The Creation of Virtual Machines in VMWare
    • Automate The Creation ...
    PowerCLI Exclude List of VM's From Script Deleting Snapshots in VMware
    • PowerCLI Exclude List ...
    PowerCLI Power On a Suspended VMware Virtual Machine
    • PowerCLI Power On a Su...
    PowerShell Installing software remotely on Multiple Computers
    • PowerShell Installing ...
    PowerShell Send Email if Windows Service is in Stopped State
    • PowerShell Send Email ...
    PowerShell Send email if windows service is not running
    • PowerShell Send email ...
    Get Local Group Members From Remote computers
    • Get Local Group Member...
    Powershell Script To Change Service Account or Update Password
    • Powershell Script To C...
    Powershell How To Change Remote Computer (Workgroup) Local Account Password
    • Powershell How To Chan...
    Delete Virtual Machine Snapshots Older Than Specific Days
    • Delete Multiple Virtua...
    How To Create File Selection Dialog Box in PowerShell
    • How To Create File Sel...
    Add User/Group To The Local Administrators/RDP Group On Multiple Computers
    • Add User/Group To The ...
    Get Windows Updates list from Remote Computer
    • Get Windows Updates li...
    PowerShell Remotely Uninstall Software from Multiple Computers
    • PowerShell Remotely Un...
    PowerShell Search Specific KB Status on Remote Computers
    • PowerShell Search Inst...
    PowerShell Script to Connect Multiple Server's Remote Session
    • PowerShell Script to C...
    PowerCLI Script to power ON dedicated VMs listed in a text file
    • PowerCLI Script to pow...
    PowerCLI Script to power Off dedicated VMs listed in a text file
    • PowerCLI Script to pow...
    Delete Snapshot's from Multiple Virtual Machines
    • Delete Snapshot's from...
    Create Snapshot on Multiple Virtual Machine
    • Create Snapshot on Mul...
    How can I check if a port is open remotely
    • Identify if Windows TC...
    Installing software remotely on Multiple "Workgroup" Computers
    • Installing software re...
    PowerShell Installing software remotely on Multiple Computers
    • PowerShell Installing ...
    Unable to move OU in Active Directory (Access is denied)
    • Unable to move OU in A...
    PowerShell Installing software remotely on Multiple Computers
    • PowerShell Installing ...
    Get Multiple Services Status Remotely | Remotely Start or Stop Services
    • Get Multiple Services ...
    Get Date and Time from Multiple Remote Computers
    • Get Date and Time from...
    PowerCLI - How to get HA restarted VM's List
    • PowerCLI - How to get ...
    Get-Childitem - Search file on Local and Remote Computers
    • Get-Childitem - Search...
    Remotely Create Update Delete Registry Key on Multiple Computers
    • Remotely Create Update...
    Get service status from remote server's using PowerShell
    • Get service status fro...

Комментарии • 4

  • @jamesjames601
    @jamesjames601 3 месяца назад

    This great. I have similar query like this but I can't make it to work. Can you help me to find the computer/s where the user is logged on?

  • @momi2313
    @momi2313 Год назад

    great information and implementation of the script , thank you

  • @jcm200
    @jcm200 Год назад +1

    Excellent video for a complex solution in environments with thousands of users- Thank you very much @SwapnilInfotech