Skip to content

Instantly share code, notes, and snippets.

@johnrc
Last active April 12, 2017 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnrc/3403bd06f16957f9a2de to your computer and use it in GitHub Desktop.
Save johnrc/3403bd06f16957f9a2de to your computer and use it in GitHub Desktop.
Powershell commands to remote access a computer
# 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