0% found this document useful (0 votes)
22 views

PowerShell_Cheat_Sheet.pdf

Uploaded by

demy2014
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

PowerShell_Cheat_Sheet.pdf

Uploaded by

demy2014
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PowerShell Cheat Sheet: 70-410

(For all cmdlets, be sure to substitute your own values)

Video Function PowerShell Cmdlet


Installing and Configuring Add a Feature Install-WindowsFeature
Servers You can deploy a feature to a remote computer
using the “–computer” flag, as in:
Install-WindowsFeature <Feature> -Computer
<ComputerName>
Add Migration Tools Install-WindowsFeature Migration
Modifying Your Installation Switch from Full to Core Uninstall-WindowsFeature Server-Gui-Mgmt-Infra, Server-
Gui-Shell –Restart
(Also using “–Remove” actually removes the underlying
binaries)
Switch from Core to Full Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-
Gui-Shell –Restart
Switch from Core to Full Dism /online /enable-feature /featurename:ServerCore-
Using DISM (not actually FullServer /featurename:Server-Gui-Shell
/featurename:Server-Gui-Mgmt
PowerShell)
Switch from Full to Core Dism /online /disable-feature /featurename:ServerCore-
Using DISM (not actually FullServer
PowerShell)
Install Minimal Server Install-WindowsFeature Server-Gui-Mgmt-Infra
Interface from Core
Install Minimal Server Uninstall-WindowsFeature Server-Gui-Shell
Interface from Full (Note: you can add the –WhatIf flag to see other
dependent components that might also be uninstalled)
Features on Demand Simply use “Unintall-Windows Feature” and include the
“-Remove” flag to remove the binaries. In the video, I
used this on a VHDX file as follows:
“Uninstall-WindowsFeatgure –name Gpmc –Vhd <Path>
-Remove”
To perform this on a remote computer, include “-
Computer <ComputerName>”

This study source was downloaded by 100000800085370 from CourseHero.com on 09-24-2024 21:53:23 GMT -05:00
Configuring Server Core Configure IP Address New-NetIPAddress -IPAddress 10.10.10.73 -InterfaceAlias
"Ethernet" -DefaultGateway 10.10.10.1 -PrefixLength 24
Configure DNS address Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -
ServerAddresses 10.10.10.70, 10.10.10.1
Join Computer to Add-Computer -DomainName nuggetlab.com
Domain
Active Directory Domain Installing Active Install-WindowsFeature –name AD-Domain-Services
Controller Installation Directory Binaries (See http://cbt.gg/TgXz7S for arguments)

Installing New Forest Install-ADDSForest


Installing New Domain Install-ADDSDomain
Installing Additional Install-ADDSDomainController
Domain Controller
Uninstall Active Uninstall-WindowsFeature –name AD-Domain-Services
Directory Binaries
Uninstall Domain Uninstall-ADDSDomainController
Controller (Applies to all
domain installations
above)
Enable Active Directory Enable-ADOptionalFeature –Identity ‘CN=Recycle Bin
Recycle Bin Feature,CN=Optional Features,CN=Directory
Service,CN=Windows
NT,CN=Services,CN=Configuration,DC=nuggetlab,DC=com’ –
Scope ForestOrConfigurationSet –Target ‘nuggetlab.com’
Active Directory: Automating Create new users New-ADUser (see the files ImportBulkUsers.ps1 and
User Accounts ImportBulkUsers.csv)

Active Directory: Computer Create Groups New-ADGroup -Name PhoenixAdmins -SamAccountName


Accounts, Groups Part 1 PhoenixAdmins -GroupCategory Security -GroupScope
Global -DisplayName PhoenixAdmins -Path "OU=User
Accounts,ou=Phoenix
Admins,ou=Phoenix,ou=Arizona,dc=nuggetlab,dc=com" -
Description "Phoenix Administrators"
Add Members to Group add-adgroupmember PhoenixAdmins
PhoenixAdmin01,PhoenixAdmin02

This study source was downloaded by 100000800085370 from CourseHero.com on 09-24-2024 21:53:23 GMT -05:00
Group Policy: Windows Firewall Settings Enable Windows Firewall: Set-NetFirewallProfile
Firewall New Firewall Rule: New-NetFirewallRule
Modify Existing Firewall Rule: Set-NetFirewallRule
IPv6 Advertise IPv6 on set-NetIPInterface -InterfaceAlias "Ethernet 2" -
interface AddressFamily IPv6 -Advertising Enabled

Configure Network New-NetRoute -InterfaceIndex 13 -DestinationPrefix


Route for ISATAP 2001:ABCD:/64 -Publish Yes
Interface
Configuring Hyper-V Enable Resource Get-VM -Computername <HostComputerName>
Metering for Hyper-V | Enable-VMResourceMetering

View Resource Metering Get-VM -ComputerName <HostComputerName> -Name


for a Specific Guest <GuestComputerName> | Measure-VM
Change Measurement Set-vmhost –computername <HostComputerName> –
Interval (default 1:00) ResourceMeteringSaveInterval HH:MM:SS
Obtain all VMS Metering Get-VM -ComputerName <HostComputerName> | Measure-
Data VM
Obtain Specific Guest Get-VM -ComputerName <HostComputerName> -Name
Metering Data <GuestComputerName> | Measure-VM
Configuring Local Storage Show Storage Pools Get-StoragePool
Show Virtual Disks Get-VirtualDisk
Repair Virtual Disk Repair-VirtualDisk
Show Unhealthy Get-PhysicalDisk | Where{$_.HealthStatus –ne
Physical Disks “Healthy”}
Remove Physical Disk Reset-PhysicalDisk
from Storage Pool
List Physical Disks Used Get-VirtualDisk | Get-PhysicalDisk
for Virtual Disks
Add a Physical Disk to Add-PhysicalDisk
Storage Pool
More Storage Cmdlets http://technet.microsoft.com/en-
us/library/hh848705.aspx

This study source was downloaded by 100000800085370 from CourseHero.com on 09-24-2024 21:53:23 GMT -05:00
The following is sample script that I use to install a domain controller on a GUI Win-12 server. Note that PS scripts are disabled by default and can
be enabled by following instructions here: http://cbt.gg/RQ7azX. General-purpose PowerShell scripts end in “.PS1” Further details about the
specific ADDSDeployment module can be found here: http://cbt.gg/Rbp9DB.

To install AD on a Core installation, much of the script would be the same, but this article explains some additional items you might need:
http://cbt.gg/MfHtet.

Before installing the DC, you will have to install Active Directory Domain Services by running:
Install-windowsfeature -name AD-Domain-Services

(On a GUI, add “–IncludeManagementTools” for MMC console tools)

Run the PowerShell script as Administrator.

Begin Script:
#
# Windows PowerShell script for AD DS Deployment
#

Import-Module ADDSDeployment
Install-ADDSDomainController `
-NoGlobalCatalog:$false `
-CreateDnsDelegation:$false `
-Credential (Get-Credential) `
-CriticalReplicationOnly:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainName "nuggetlab.com" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SiteName "Default-First-Site-Name" `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true

This study source was downloaded by 100000800085370 from CourseHero.com on 09-24-2024 21:53:23 GMT -05:00
This study source was downloaded by 100000800085370 from CourseHero.com on 09-24-2024 21:53:23 GMT -05:00
Powered by TCPDF (www.tcpdf.org)

You might also like