0% found this document useful (0 votes)
128 views2 pages

4D HyperV and Exchange 2016 Powershell Cheat Sheet

This document provides a cheat sheet of useful PowerShell commands for managing Hyper-V servers and virtual machines. It includes commands for creating and configuring VMs, starting and stopping VMs, importing and exporting VMs, and checking VM and hypervisor logs. Logging commands are grouped by log type such as configuration, availability, integration services, and networking.

Uploaded by

m00anj00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views2 pages

4D HyperV and Exchange 2016 Powershell Cheat Sheet

This document provides a cheat sheet of useful PowerShell commands for managing Hyper-V servers and virtual machines. It includes commands for creating and configuring VMs, starting and stopping VMs, importing and exporting VMs, and checking VM and hypervisor logs. Logging commands are grouped by log type such as configuration, availability, integration services, and networking.

Uploaded by

m00anj00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Hyper-V Server 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 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 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 <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 www.4d-dc.com


Exchange 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

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\Receive.log” 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 10.0.0.0/24 This will block messages that come from the 10.0.0.0/24 network
Recipient Filtering (Enabled by default)
Set-RecipientFilterConfig –BlockedRecipients “[email protected]” Will block emails sent to [email protected]
Set-RecipientFilterConfig -RecipientValidationEnabled $true Will enable recipient validation
Permissions on Mailboxes
Get-MailboxPermission -Identity [email protected] | Format-List Gets permissions on Mailbox that has address [email protected]
Get-MailboxPermission -Identity [email protected] -User “BenB” Gets permissions that user BenB has on [email protected]
Add-DistributionGroupMember -Identity “Allusers” -Member “[email protected]” Adds user Ian to Distribution Group “Allusers”
Add-ADPermission -Identity [email protected] -User “Ian” -ExtendedRights Send-As Gives user Ian permissions to “Send As” [email protected]
Set-Mailbox -Identity [email protected] -GrantsendOnBehalfTo [email protected] Allows user Brian to “Send on Behalf” [email protected]
Add-MailboxPermission -Identity [email protected] -User Ian -AccessRights FullAccess Gives user Ian Full Access permissions to Ben’s Mailbox
Manage Mailboxes
4DPSCS18

Enable-Mailbox [email protected] 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 [email protected] -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 www.4d-dc.com

You might also like