Tuesday, October 12, 2021

Get Disk Space Info Remotely

One of the quick and easy ways to get a remote computer/server's disk space info is to use the PowerShell command GET-PSDrive. 

You can create a batch file that runs the GET-PSDrive command remotely using PSTools' PSExec. 


@echo off

psexec \\{ip_address} cmd /c powershell.exe "Get-PSDrive"

pause


Assign local admin rights remotely

To view the local admin users of  the PC you are currently using: 

net localgroup administrators



After downloading and saving PSTools to a folder, which include psexec.exe, and making it available globally through System Variables -> Path, you can run the "net locagroup" command on remote PCs, given that you already have local admin rights to those PCs.

To view the local admin users of another PC remotely, try

psexec  \\<ip_address>  net  localgroup administrators




To add a user to the local admin group remotely: 

psexec \\<ip_address>  net localgroup administratos "<domain_name>\<username>" /add




To remove a user from the local admin group remotely:

psexec \\<ip_address>  net localgroup administratos "<domain_name>\<username>" /delete