Difference between revisions of "MyWinCmds"

From TheBestLinux.com
Jump to navigation Jump to search
Line 2: Line 2:
  
 
=== PowerShell Commands ===
 
=== PowerShell Commands ===
 +
 +
==== '''Windows Server - Specific''' ====
 +
This one-liner will give you the EXACT version of Windows currently running:
 +
<pre style"color:blue">
 +
(Get-WmiObject -class Win32_OperatingSystem).Caption
 +
 +
 +
 +
Query Detailed System Information - Here is an example of how to obtain detailed system information about the server you are currently working on:
 +
<pre style="color:blue">
 +
 +
 
SConfig Start Server Configuration text-mode command-line tool for Server Core without GUI
 
SConfig Start Server Configuration text-mode command-line tool for Server Core without GUI
 
Get-History Gets history of current session
 
Get-History Gets history of current session

Revision as of 07:55, 9 August 2023

WINDOWS COMMAND-LINE COMMANDS & TOOLS

PowerShell Commands

Windows Server - Specific

This one-liner will give you the EXACT version of Windows currently running:

(Get-WmiObject -class Win32_OperatingSystem).Caption



Query Detailed System Information - Here is an example of how to obtain detailed system information about the server you are currently working on:


SConfig						Start Server Configuration text-mode command-line tool for Server Core without GUI
Get-History					Gets history of current session
(Get-PSReadlineOption).HistorySavePath		This gives you the path where all of the history is saved.
cat (Get-PSReadlineOption).HistorySavePath	Spit out all history!
cat (Get-PSReadlineOption).HistorySavePath | select -Last 10 --> get the last 10 lines
Get-Content (Get-PSReadlineOption).HistorySavePath > C:\PowerShellHistory.txt  --> Copy all history to file
notepad (Get-PSReadlineOption).HistorySavePath	Open all history in Notepad GUI
Select-String "<search pattern>" (Get-PSReadlineOption).HistorySavePath  --> Search All History
		Same as above but without the details/line numbers/etc:
Get-Content (Get-PSReadlineOption).HistorySavePath | Select-String "<search pattern>" 

Basic Command:
cat (Get-PSReadlineOption).HistorySavePath

SSH Server & Client Setup on Windows Using PowerShell commands:
From URL:
https://techcommunity.microsoft.com/t5/itops-talk-blog/installing-and-configuring-openssh-on-windows-server-2019/ba-p/309540

Add-WindowsCapability -Online -Name OpenSSH.ServerJamie Rubinstein | Jamie@dawgland.com | https://www.dawgland.com 19:07, 8 May 2023 (UTC)0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.ClientJamie Rubinstein | Jamie@dawgland.com | https://www.dawgland.com 19:07, 8 May 2023 (UTC)0.0.1.0

If you’re intending to use key based, rather than password based, authentication, you should also run the following command on the server to install an OpenSSH related PowerShell module that includes tools to help you configure that functionality:

Install-Module -Force OpenSSHUtils -Scope AllUsers

To install NANO text editor, as per URL this is based on (I prefer the VI/VIM text editor, which is included with the GitHub command-line client, which also provides basic BASH shell functionality and tools and support for the built-in Windows OpenSSH Server & Clients!

Other Miscellaneous Commands:

mstsc.exe Start MS Remote Desktop Client (RDP) sysdm.cpl Start Rename Windows Hostname & Join Domain/Workgroup & Device Manager & RDP Enable. appwiz.cpl Start Add/Remove Programs control netconnections Open and edit network connections control update Start Windows Updates

Windows Server LICENSE MANAGER Commands:

Check Activation Status slmgr /xpr View Current License Info slmgr /dli View Detailed License Info slmgr /dlv Reset Activation Timers slmgr /rearm Remove Windows Product Key slmgr /cpky Activate Windows Online slmgr /ato Change Windows Product Key slmgr /ipk 12345-12345-12345-12345-1234 Change Remote Product Key slmgr /ipk Win10Vm10 jamie MyPasswd 12345-12345-12345-12345-12345 Deactivate Windows slmgr /upk DETAILED SLMGR USAGE WITH ALL AVAILABLE SWITCHES & OPTIONS: slmgr [MachineName [username [password]]] [option] Slmgr Command Options Item Explanation MachineName The machine to administer. Defaults to the local machine if omitted. username The username of an administrator account on the remote machine. password The password for username. /ato Activate Windows license and product key against Microsoft's server. /atp Confirmation_ID Activate the product with a user-provided Confirmation_ID. /cdns Disable DNS publishing by the KMS host. /ckhc Disable KMS host caching. /ckms Clear the name of KMS server used to default and port to default. /cpky Delete the Windows product key from Windows Registry. /cpri Set the KMS priority to low. /dli Display the current license information with activation status and partial product key. /dlv Display additional license information. Similar to /dli but more detailed. /dti Display Installation ID for offline activation. /ipk key Change the Windows product key. Replaces the current product key if present. /ilc file Install a license file. /rilc Reinstall system license files. /rearm Reset the evaluation period/licensing status and activation state of the computer. Use /rearm-app to specify an app, or /rearm-sku for a specific sku. /skms Set the Volume Licensing KMS server and/or the port used for KMS activation. /skhc Enable KMS host caching (enabled by default). This blocks the use of DNS priority and weight after the initial discovery of a working KMS host. /sai interval Sets the interval in minutes for unactivated clients to attempt KMS connection. /spri Set the KMS priority to normal (default). /sprt port Set the port on which the KMS host listens for client activation requests (default TCP port is 1688). /sdns Enable DNS publishing by the KMS host (default). /upk Uninstall the currently installed Windows product key and return the license status back to a trial state. /xpr Show the expiry date of the current license or indicate whether activation is permanent. The MachineName option can't be used across platforms. For example, you can't manage Windows activation on a Windows 7 computer from a Windows Vista computer. Slmgr Uses Software Licensing Management Tool (slmgr) is a VBS file in Windows against which you can run commands to perform advanced Windows product activation tasks. Slmgr.vbs is used only for the Windows operating system. Ospp.vbs manages volume licensing for Microsoft Office products.

MSC - Microsoft Management Console Commands

* adsiedit.msc * azman.msc * certlm.msc * certmgr.msc * certsrv.msc * certtmpl.msc * comexp.msc * compmgmt.msc * devmgmt.msc * DevModeRunAsUserConfig.msc * dfsmgmt.msc * diskmgmt.msc * dnsmgmt.msc * domain.msc * dsa.msc * dssite.msc * eventvwr.msc * fsmgmt.msc * fsrm.msc * gpedit.msc * gpmc.msc * gpme.msc * gptedit.msc * lsdiag.msc * lusrmgr.msc * nfsmgmt.msc * ocsp.msc * perfmon.msc * pkiview.msc * printmanagement.msc * rrasmgmt.msc * rsop.msc * secpol.msc * services.msc * taskschd.msc * tpm.msc * tsgateway.msc * WF.msc * WmiMgmt.msc

More Useful Command Lists From Other Sites

* https://www.lifewire.com/windows-run-command-guide-3401937