Hyper-V Core 2016 PowerShell Cheat Sheet To receive further 4D Cheat Sheets or share your tips for productivity, please email [email protected]. Improve productivity More insights here: www.4d-dc.com/insight

Help Commands Logging Get-Help To list all PowerShell commands Hyper-V events logs are stored in the under “Applications and Services Get-Help Get-VM To with a particular command Logs“, ““, “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 60Gb.The VHD Hyper-V-High-Availibility Hyper-V C:\ClusterStorage\VolumeX\ will be stored on the path specified on Hyper-V-Hypervisor Hypervisor specific events NewVirtualMachineName.vhdx “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 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 To start an individual VM Networking Stop-VM -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:\\.vmcx’ -Copy Register in-place Import-VM -Path ‘C:\\.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 www.4d-dc.com www.4d-dc.com Improve productivity Improve

Checking the Microsoft Exchange Serverstatus Exchange Microsoft Checking the of the submission queue Check the contents file location and log View database mailbox, logs protocol of SMTP the location Change the services server on the local Test on Mailbox01 Report Health without applying of the command the actions simulates switch WhatIf of the agent Checks the status Agent Enables Filtering the 10.0.0.0/24 network from come that This will block messages [email protected] Will block emails sent to validation Will enable recipient [email protected] has address that permissions on Mailbox Gets on [email protected] user BenB has permissions that Gets “Allusers” Group Distribution Adds user Ian to As” “Send Gives user Ian permissions to [email protected] Behalf” on “Send Allows user Brian to [email protected] Mailbox Ben’s permissions to Access Gives user Ian Full chosen automatically Database user. it with existing and associates Mailbox Creates and log file location View database Mailbox, chosen automatically Database on the specified OU. Mailbox Shared Creates Group Distribution “NewAdds Ian to Projects” 020 7183 0603 Cheat Sheet Cheat

General | ft -AutoSize DisplayName | sort Status Status, | select -Name *Exchange* Get-Service Get-Queue -Identity Submission Get-Queue | fl Name,EdbFilePath,LogFolderPath Get-MailboxDatabase “C:\Logs\Receive.log” -ReceiveProtocolLogPath Mailbox01 Set-TransportService Test-ServiceHealth Mailbox01-RollupGroup -Identity Get-HealthReport -WhatIf default) (Disabled by Filtering Connection Agent” Filtering “Connection Get-TransportAgent Agent” Filtering “Connection Enable-TransportAgent Add-IPBlockListEntry 10.0.0.0/24 -IPRange default) (Enabled by Filtering Recipient “[email protected]” –BlockedRecipients Set-RecipientFilterConfig $true -RecipientValidationEnabled Set-RecipientFilterConfig on Mailboxes Permissions | Format-List -Identity [email protected] Get-MailboxPermission “BenB” -User -Identity [email protected] Get-MailboxPermission -Member “[email protected]” -Identity “Allusers” Add-DistributionGroupMember Send-As -ExtendedRights -User “Ian” -Identity [email protected] Add-ADPermission [email protected] -GrantsendOnBehalfTo -Identity [email protected] Set-Mailbox FullAccess -User Ian -AccessRights -Identity [email protected] Add-MailboxPermission Mailboxes Manage [email protected] Enable-Mailbox | fl Name,EdbFilePath,LogFolderPath Get-MailboxDatabase Shared -OrganizationaUnit [email protected] New-Mailbox -Shared -Member Ian -Identity “New Project” Add-DistributionGroupMember More insights here: www.4d-dc.com/insight here: insights More To receive further 4D Cheat Sheets or share your tips for productivity, please email [email protected]. email [email protected]. please productivity, tips for your or share Sheets 4D Cheat further receive To PowerShell 2016 Exchange Cloud | Colo | Connect  Cloud | Colo | Connect 4DPSCS18