Windows PowerShell Basic Commands running on Windows Server 2019
Basic PowerShell Commands for General Purpose running on Windows Server 2019 Datacenter Edition by VMware Workstation.
OS basic verification:
To get the version of the PowerShell, use the following command:
"Get-host | select Version"
"$PSVersionTable"
Windows Updates
Some modules are not available by default on the PowerShell.
So you will need to manually download it.
I downloaded the module PSWindowsUpdate
which will enable me to update the OS from
PowerShell:
"Get-Module PSWindowsUpdate"
"Get-Service"
Display available commands
This will display all commands that are available
based on the modules that are loaded:
"Get-Command" [Press Tab] for autocorrect the spelling if needed
Get the process running on Windows Server:
"Get-Process"
One of the first things you might want to do is to get the updates that need to be installed
on the Operating System first which I did with the following command:
"Get-WindowsUpdateLog"
Search Get Help
Use this to search the help files. This is useful if you don’t know the
command or want to see if one exists:
command or want to see if one exists:
"Get-Help" *keyword*
Use this command to download module for Microsoft PowerShell Utilities:
"Update-Help"
Use this to get the help information for a command:
"Get-Help command-name"
This will list all available modules on the computer:
"Get-Module -ListAvailable"
The Execution Policy helps protect you from scripts that you do not trust:
"Get-Executionpolicy"
Changing the execution policy might expose you to the security risks
described in the about_Execution_Policies help topic:
"Set-Executionpolicy unrestricted"
Replace *ntfs* with the keyword you want to search for. This searches
modules at https://www.powershellgallery.com/
"Find-Module *ntfs*"
Installs modules from https://www.powershellgallery.com/
I found a module called NTFSSecurity, to install it. And I run this command:
"Install-Module NTFSSecurity"
Finding the rules on the firewall:
"Get-NetFirewallRule"
"Get-NetIPConfiguration"
"Get-NetAdapterLso"
"Get-NetRoute"
Get the disk space information:
"Get-WmiObject win32_logicaldisk"
"Get-PhysicalDisk"
"Get-PSDrive C | Select-Object Used, Free"
"Find-Module -Name PendingReboot | Install-Module"
To get information which command to use for a pending reboot use:
"Get-Command -Module PendingReboot"
Getting help with commands arguments are pretty easy. Let’s say
you want to know the possible arguments of the command
Get-Command, simply do:
"Get-Command -?"
Restart-Computer -ComputerName "Server01", "Server02",
"localhost"
Discovering Cmdlets and aliases looks like inside PowerShell:
"ls"
Directory: C:\ contents [All show you same results]
Directory Command:
"dir"
Directory: C:\ contents [All show you same results]
"Get-ChildItem"
Directory: C:\ contents [All show you same results]
"Get-Help set-vm"
Export the list of Services running on Windows Server 2019
Datacenter Edition:
"get-service | out-file c:\services.txt"
"$env:computername"
"Rename-Computer -computername WIN-380VDOFU2K5
-newname BIBEK-007"
To verify check also at "Active Directory Users and Computers"
& if needed type "sysdm.cpl" from Win+R.
& if needed type "sysdm.cpl" from Win+R.
"Restart-Computer"
"Get-Hotfix"
Thank you
ReplyDelete