Last active
April 12, 2017 14:30
-
-
Save johnrc/3403bd06f16957f9a2de to your computer and use it in GitHub Desktop.
Powershell commands to remote access a computer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get credentials for the box | |
$credentials = (Get-Credential) | |
# If above doesn't work do | |
$password = ConvertTo-SecureString "password" -AsPlainText -Force | |
$credentials = New-Object System.Management.Automation.PSCredential ("username", $password) | |
Enter-PSSession -ComputerName <computername> -Credential $credentials | |
# Remove an item | |
Remove-Item -Recurse -Force <directory> | |
# Run cmd commands | |
cmd /c "net localgroup administrators" | |
cmd /c "net localgroup administrators <domain>\<username> /add" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment