Windows Server 2016 Exam – PowerShell Commands to Know (70-740)

Here’s a short list of PS commands that you may not know now, but they have a high likelihood of showing up on the exam:
NANOSERVER
New-NanoServerImage:
This module is imported from the Windows 2016 ISO D:\NanoServer\NanoServerImageGenerator\NanoServerImageGenerator.psm1
Commands that are included with this module:
gcm -module
Edit-NanoServerImage, Get-NanoServerPackage, and New-NanoServerImage.
Creating a new image:

new-nanoserverimage -deploymenttype guest -edition standard -mediapath d:\ -targetpath
c:\temp\nanoserver1.vhdx -computername nano1

Different packages for different features:
Microsoft-NanoServer-DSC-Package Installs the Desired State Configuration
(DSC) package on the image specified by the TargetPath variable.
Microsoft-NanoServer-DNS-Package Installs the DNS Server role on the image
specified by the TargetPath variable.
Microsoft-NanoServer-IIS-Package Installs the IIS role on the image specified
by the TargetPath variable.
Microsoft-NanoServer-SCVMM-Package Installs the System Center Virtual
Machine Manager agent on the image specified by the TargetPath variable.
Microsoft-NanoServer-SCVMM-Compute-Package Installs the Hyper-V role – Can you use the -compute switch when created a new NanoServer Image.
on the image specified by the TargetPath variable, so that is it manageable with
Microsoft-NanoServer-NPDS-Package Installs the Network Performance
Diagnostics Service on the image specified by the TargetPath variable.
Microsoft-NanoServer-DCB-Package Installs Data Center Bridging on the
image specified by the TargetPath variable.
Microsoft-NanoServer-SecureStartup-Package Installs Secure Startup on the
image specified by the TargetPath variable.
Microsoft-NanoServer-ShieldedVM-Package Installs the Shielded Virtual
Machine package on the image specified by the TargetPath variable (Datacenter
edition only).
Adding a package to an existing image:

edit-nanoserverimage -basepath c:\nanoserver\base -targetpath
c:\nanoserver\nano1.vhdx
-packages microsoft-nanoserver-iis-package

Get-WindowsOptionalFeature – This can be used to check what roles on installed inside the PS session.
Find-NanoServer Package: Searches online for nano package.
Install-PackageProvider (part of PowerShell Gallery) and Save-NanoServerPackage – Use this two modules to download and save a nano server package to install.
NanoServer-Storage-Package – Install package to allow formatting of ReFS.
CLUSTERING
Move-ClusterGroup: Move a VM from one server to another minimizing downtime. Nodes are both members of a cluster.
Convert-VHD: To use a virtual disk as a shared virtual disk for a guest fail-over cluster.
Get-ClusterLog – View logs of cluster, e.g., server fails and you need to identify the cause.
(Get-Cluster).AutoBalancerLevel – Change load balancing for a cluster.
wmic ComputerSystem Set Workgroup =’workgroupb’ and New-Cluster-Name Cluster1 -Node Server1,Server2 -AdministrativeAccessPoint DNS – Create a fail-over cluster in a workgroup mode.
NETWORKING
Set-VMNetworkAdapter – Limit the maximum network bandwidth available to a VM.
Set-NetQosPolicy – Use to limit traffic bandwidth between servers.
Set-VMNetworkAdapter -MacAddressSpoofing On/Off – Ensure machines inside a nested Hyper-V can communicate with each other
Set-VMSwitch – Ensure VMs can communicate with each other.
Add-VMNetworkAdapterAcl – resource metering of traffic to track amount of network traffic VMs send between each other.
Storage
Set-SRPartnership – A server fails in a replica, from another server you can ensure access is still available.
Optimize-VHD – Limit the amount of space used by a VHD.
Resize-VirtualDisk – Extend a partition in a storage pool.
Resize-IscsiVirtualDisk – change size of an iSCSI disk on a server.
Set-SmbBandwidthLimit – Ensure that the replication between servers is limited to a maximum of 100 Mbps.
New-SRPartnership – asynchronously replicate volumes on two different servers.
New-NetQosPolicy – Configure replication policy between servers
Creating, mounting, initializing, partitioning, and formatting a new VHDX all in one line of Powershell:

new-vhd -path c:\data\disk1.vhdx -sizebytes 256gb -dynamic |
mount-vhd -passthru |
initialize-disk -passthru | new-partition -driveletter x -
usemaximumsize | format-volume
-filesystem ntfs -filesystemlabel data1 -confirm:$false -force

New SMB Share:

new-smbshare –name sharename -path pathname [-fullaccess
groupname] [-readaccess
groupname] [-changeaccess groupname] [-noaccess groupname]

 
Hyper-V
Set-VMProcesser – Use to enable nested virtualization.
Export-VM, and then Import-VM – Create multiple copies of VMs to use on a Hyper-V Host.
Set-VMHost – Ensure virtual machines use all available networks to perform a live migration.
Set-IpamConfiguration – Modify GPO prefix by IPAM.