Random Windows Commands
Collection of interesting and useful commands in Windows command prompt and PowerShell.
Command Prompt
Change Computer Name
In CMD as Admin:
1
wmic computersystem where caption='CURRENT_PC_NAME' rename 'NEW_PC_NAME'
View BitLocker Status
BitLocker status of all connected drives will be shown (inc USBs).
In CMD as Admin:
1
manage-bde -status
Executing an Application in the Context of a Domain User
1
runas /netonly /user:DOMAIN\USERNAME "PROGRAM_TO_EXECUTE"
Force Apply Group Policy Updates
1
gpupdate /force
Set Windows KMS
- Set KMS server:
1
cscript C:\Windows\System32\slmgr.vbs /skms KMS_SERVER
- Where
KMS_SERVER
is the IP/Hostname of the KMS server.
- Where
- Force activate Windows:
1
cscript C:\Windows\System32\slmgr.vbs -ato
Lock Computer
1
Rundll32.exe user32.dll,LockWorkStation
PowerShell
Get PowerShell Version
1
2
$PSVersionTable
$PSVersionTable.PSVersion
Execution Policy Bypass
1
powershell -executionpolicy bypass
See Current SMB Connections
In PowerShell as Admin:
1
Get-SMBConnection
See Shared Folders
In PowerShell:
1
Get-SmbShare
Change Creation Time
Change the “Created At” time of a file:
1
(Get-ChildItem -Path FILE_PATH).CreationTime='12.31.2010 10:30:59AM'
Change Last Modified Time
Change the “Modified At” time of a file:
1
(Get-ChildItem -Path FILE_PATH).LastWriteTime='12.31.2010 17:12:06'
This post is licensed under CC BY 4.0 by the author.