Powershell Flashcards
Show basic networking info.
Get-NetAdapter
Show ip info. Similar to ipconfig
Get-NetIPConfiguration
Set IP, subnet, and gateway.
Set-NetIPAddress -InterfaceIndex 2 -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set DNS server.
Set-DNSClientServerAddress -InterfaceIndex 2 -ServerAddress (“8.8.8.8”, “8.8.4.4”)
View firewall information
Get-NetFirewallProfile
Set firewall.
Set-NetFirewallProfile - Profile private,public,domain -Enabled True
Rename computer.
Rename-Computer -NewName COMPUTERNAME -Restart
Rename domain joined computer.
Rename-Computer -NewName COMPUTERNAME -DomainCredential “domain\username” -Force -Restart
View computer name.
$env:COMPUTERNAME
View all powershell commands.
Get-Command
View specific powershell commands.
Get-Command -Module or net or -Noun net*
View powershell help.
Get-Help powershell-command-name
Add computer to domain.
Add-Computer -DomainName domainname.com
Update powershell help files.
Update-Help
Start powershell connection to remote computer.
Enter-PSSession -ComputerName COMPUTERNAME
View all available features/roles.
Get-WindowsFeature
View installed features/roles.
Get-WindowsFeature | Where-Object Installed -eq True
Install a server role/feature.
Install-WindowsFeature -Name Web-Server, Web-Mgmt-Service
Configure server for remote management.
Set-ItemProperty -Path “HKLM:\Software\Microsoft\WebManagement\Server” -Name “EnableRemoteManagerment” -Value 1
Set remote management service to start automatically.
Set-Service WMSCV -StartupType Automatic
Exit remote powershell connection.
Exit-PSSession
Send a powershell command to a remote computer using http (firewall on).
Invoke-Command -ComputerName COMPUTERNAME -ScriptBlock {Get-Service W3SVC, WMSVC }
Send a powershell command to a remote computer using dcom (will not work with firewall on).
Get-Service -ComputerName COMPUTERNAME