If you like my tips, buy me a coffee
I believe that it is my responsibility to transfer the knowledge I gathered through the years of my experience with Windows Server Administrating using PowerShell
Change CDROM drive letter (from D: to F:)
Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = 'd:'" ) -Arguments @{DriveLetter='f:'}
WinRM (Windows Remote Management)
With Windows Remote Management (WinRM), you can use Remote Shell, remote Windows PowerShell, and other management tools and consoles to manage a server. With this method the graphical shell of the remote machine is not accessed. WinRM is enabled by default in Windows Server 2012
** Note: User powershell to run the commands of WinRM.
Enable WinRM command
WinRM qc
Show WinRM configuration parameters
WinRM Get WinRM/config
Show trusted hosts
Get-Item WSMan:\localhost\Client\TrustedHosts
Set trusted hosts
Set-Item WSMan:\localhost\Client\TrustedHosts -Value *
Connecting to remote server PowerShell session
Enter-PSSession -ComputerName <Computer FQDN, IP or host name> -Credential <Remote Account Username>
Install or Uninstall Roles, Role Services, or Features
List all features
Get-WindowsFeature
List a feature by name
Get-WindowsFeature -Name <feature name>
List installed features
Get-WindowsFeature | Where-Object {$_.InstallState -eq 'Installed'}
List available features
Get-WindowsFeature | Where-Object {$_.InstallState -eq 'Available'}
Install feature by name
Install-WindowsFeature -Name <feature name>
Uninstall feature by name
Uninstall-WindowsFeature -Name <feature name>
Change the Remote Desktop (RDP) listening port
Check the current portList all features
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"
List installed features
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value <NEW PORT>
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort <NEW PORT>
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort <NEW PORT>