Hyper-V Server Core 2016 PowerShell Cheat Sheet
To receive further 4D Cheat Sheets or share your tips for productivity, please email info@[Link]. Improve productivity
More insights here: [Link]/insight
Help Commands Logging
Get-Help To list all PowerShell commands Hyper-V events logs are stored in the Event Viewer under “Applications and Services
Get-Help Get-VM To get help with a particular command Logs“, “Microsoft“, “Windows“
Creation of VMs If you do not know where to start, start with Hyper-V-VMMs. As the central
management service it usually has something to say about everything.
“New-VM -Name “New Virtual Machine Hyper-V-Config Anything that relates to virtual machine config files
Name“ -MemoryStartupBytes 2GB Will create a new VM with 2Gb Ram Actions and changes that happen because of
-NewVHDPath and a new HDD size of [Link] VHD Hyper-V-High-Availibility Hyper-V
C:\ClusterStorage\VolumeX\ will be stored on the path specified on Hyper-V-Hypervisor Hypervisor specific events
[Link] “NewVHDPath”
-NewVHDSizeBytes 60GB” Hyper-V-Image- Virtual hard disk operations - like creating, converting
Management-Service and editing virtual hard disks
Set-vmDvDDrive Attach DVD drive Hyper-V-Integration Relate specifically to integration services
Set-VMProcessor <virtual machine name> Changing VM processor type to Hyper-V-Network Creation and configuration of virtual networks
-CompatibilityForMigrationEnabled $true compatible Hyper-V-SynthNic Virtual machine and virtual network adapters
Start-Up / Shutdown VMs Hyper-V-SynthStor Virtual hard disks
Get-VM | where {$_.state -eq ‘running‘} To list all running VMs Hyper-V-VMMS Virtual machine management services files its events
Get-VM | where {$_.state -eq ‘off‘} To list all off VMs Hyper-V-Worker Worker process that is used for the running of the VM
Start-VM -Name <virtual machine name> To start an individual VM Networking
Stop-VM -Name <virtual machine name> To stop an individual VM Get-VMNetworkAdapter Displays Virtual Network Adapters of Virtual Machine
Get-VM | where {$_.state -eq ‘off‘ | Start-VM} To turn on all off VMs Get-VMNetworkAdapterVlan Will provide VLAN settings of Virtual Adapter
Import and Export
Restore the VM Import-VM -Path ‘C:\<vm export path>\<GUIDID>.vmcx’ -Copy
Register in-place Import-VM -Path ‘C:\<vm export path>\<GUIDID>.vmcx’ -VhdDestPath ‘D:\Virtual Machines\’ -VirtualMachinePath ‘D:\Virtual Machines\’
Restore the virtual machine to a location you choose, or use the default to Hyper-V.
This type assumes export files are in the location where you’ll store and run the This import type creates a copy of the exported files and moves them to the selected
virtual machine. The imported virtual machine has the same ID as it did at the time location. When imported, the virtual machine has the same ID as it did at the time of
of export. Because of this, if the virtual machine is already registered with Hyper-V, it export. Because of this, if the virtual machine is already running in Hyper-V, it needs
needs to be deleted before the import works. When the import has completed, the to be deleted before the import can be completed. When the import has completed,
export files become the running state files and can’t be removed. the exported files remain intact and can be removed or imported again.
Cloud | Colo | Connect 020 7183 0603 [Link]
Exchange 2016 PowerShell Cheat Sheet
To receive further 4D Cheat Sheets or share your tips for productivity, please email info@[Link]. Improve productivity
More insights here: [Link]/insight
General
Get-Service -Name *Exchange* | select Status, DisplayName | sort Status | ft -AutoSize Checking the Microsoft Exchange Server status
Get-Queue -Identity Submission Check the contents of the submission queue
Get-MailboxDatabase | fl Name,EdbFilePath,LogFolderPath View mailbox, database and log file location
Set-TransportService Mailbox01 -ReceiveProtocolLogPath “C:\Logs\[Link]” Change the location of SMTP protocol logs
Test-ServiceHealth Test the services on the local server
Get-HealthReport -Identity Mailbox01-RollupGroup Health Report on Mailbox01
-WhatIf WhatIf switch simulates the actions of the command without applying
Connection Filtering (Disabled by default)
Get-TransportAgent “Connection Filtering Agent” Checks the status of the agent
Enable-TransportAgent “Connection Filtering Agent” Enables Filtering Agent
Add-IPBlockListEntry -IPRange [Link]/24 This will block messages that come from the [Link]/24 network
Recipient Filtering (Enabled by default)
Set-RecipientFilterConfig –BlockedRecipients “brian@[Link]” Will block emails sent to brian@[Link]
Set-RecipientFilterConfig -RecipientValidationEnabled $true Will enable recipient validation
Permissions on Mailboxes
Get-MailboxPermission -Identity ian@[Link] | Format-List Gets permissions on Mailbox that has address ian@[Link]
Get-MailboxPermission -Identity ian@[Link] -User “BenB” Gets permissions that user BenB has on ian@[Link]
Add-DistributionGroupMember -Identity “Allusers” -Member “ian@[Link]” Adds user Ian to Distribution Group “Allusers”
Add-ADPermission -Identity BenB@[Link] -User “Ian” -ExtendedRights Send-As Gives user Ian permissions to “Send As” BenB@[Link]
Set-Mailbox -Identity Ian@[Link] -GrantsendOnBehalfTo Brian@[Link] Allows user Brian to “Send on Behalf” Ian@[Link]
Add-MailboxPermission -Identity Ben@[Link] -User Ian -AccessRights FullAccess Gives user Ian Full Access permissions to Ben’s Mailbox
Manage Mailboxes
4DPSCS18
Enable-Mailbox Ian@[Link] Creates Mailbox and associates it with existing user. Database automatically chosen
Get-MailboxDatabase | fl Name,EdbFilePath,LogFolderPath View Mailbox, database and log file location
New-Mailbox -Shared Support@[Link] -OrganizationaUnit Shared Creates Shared Mailbox on the specified OU. Database automatically chosen
Add-DistributionGroupMember -Identity “New Project” -Member Ian Adds Ian to “New Projects” Distribution Group
Cloud | Colo | Connect 020 7183 0603 [Link]