Skip to content

Instantly share code, notes, and snippets.

@gsmitheidw
Last active January 26, 2018 15:12
Show Gist options
  • Save gsmitheidw/39f72c6b0648a8540cd96d022ff637b7 to your computer and use it in GitHub Desktop.
Save gsmitheidw/39f72c6b0648a8540cd96d022ff637b7 to your computer and use it in GitHub Desktop.
Useful Windows Commands
:: Resizing with ImageMagick example. Source image goes first before operation, criteria and output image:
magick test.jpg -resize "1280x1280" test2.jpg
::auto logins
netplwiz
:: press F11 to fullscreen a command prompt
:: pipe to clipboard
dir | clip
:: where
PS C:\>cmd /c where clip.exe
C:\Windows\System32\clip.exe
:: Create a textfile without an editor
copy con textfile.txt
Text contents of file
[ctrl] + z
:: type kinda like cat
type file.txt
:: doskey still exists
doskey /?
:: filesystem utilities
fsutil
:: use [F7] to show previously typed commands
:: Annoyingly this is cmd only not in powershell
:: universal software switch finder (from chocolately)
ussf
:: Fix quotas - run elevated:
dirquota quota scan /path:d:\homedir\*
::Find stale AD Computer Objects:
dsquery computer -inactive 1 -limit 100 -o samid | select-string "Lab"
:: Find lastlogon for domain computer objects
Get-ADComputer -Filter * -Properties * | FT Name, LastLogonDate -Autosize
:: Fix computers that have dropped off domain:
Reset-ComputerMachinePassword [-Credential <PSCredential>] [-Server <String>]
-------------------------- EXAMPLE 1 --------------------------
PS C:\>Reset-ComputerMachinePassword
This command resets the machine password for the local computer. The command runs with the credentials of the
current user.
-------------------------- EXAMPLE 2 --------------------------
PS C:\>Reset-ComputerMachinePassword -Server DC01 -Credential Domain01\Admin01
This command resets the machine password of the local computer using the DC01 domain controller. It uses the
Credential parameter to specify a user account that has permission to reset a machine password in the domain.
-------------------------- EXAMPLE 3 --------------------------
PS C:\>Invoke-Command -ComputerName Server01 -ScriptBlock {Reset-ComputerMachinePassword}
This command uses theInvoke-Command cmdlet to run a Reset-ComputerMachinePassword command on the Server01 remote
computer.
For more information about remote commands in Windows PowerShell, see about_Remote and Invoke-Command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment