|
1 | | -function Test-PSDCHyperVEnabled { |
| 1 | +function Test-PSDCHyperVEnabled { |
| 2 | + <# |
| 3 | + .SYNOPSIS |
| 4 | + Test-PSDCHyperVEnabled tests if Hyper-V is enabled |
| 5 | +
|
| 6 | + .DESCRIPTION |
| 7 | + For the module to work properly the module needs Hyper-V to be enabled |
| 8 | + The function tests is that's the case |
| 9 | +
|
| 10 | + .PARAMETER HostName |
| 11 | + Hostname to check. The default is the current hostname |
| 12 | +
|
| 13 | + .PARAMETER EnableException |
| 14 | + By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. |
| 15 | + This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. |
| 16 | + Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch. |
| 17 | +
|
| 18 | + .PARAMETER WhatIf |
| 19 | + If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run. |
| 20 | +
|
| 21 | + .PARAMETER Confirm |
| 22 | + If this switch is enabled, you will be prompted for confirmation before executing any operations that change state. |
| 23 | +
|
| 24 | + .NOTES |
| 25 | + Author: Sander Stad (@sqlstad, sqlstad.nl) |
| 26 | +
|
| 27 | + Website: https://psdatabaseclone.io |
| 28 | + Copyright: (C) Sander Stad, sander@sqlstad.nl |
| 29 | + License: MIT https://opensource.org/licenses/MIT |
| 30 | +
|
| 31 | + .LINK |
| 32 | + https://psdatabaseclone.io/ |
| 33 | +
|
| 34 | + .EXAMPLE |
| 35 | + Test-PSDCHyperVEnabled -HostName APPSRV1 |
| 36 | +
|
| 37 | + Test if APPSRV1 has Hyper-V enabled |
| 38 | +
|
| 39 | + .EXAMPLE |
| 40 | + Test-PSDCHyperVEnabled |
| 41 | +
|
| 42 | + Test if the current host has Hyper-V enabled |
| 43 | + #> |
| 44 | + |
| 45 | + [CmdLetbinding()] |
| 46 | + |
| 47 | + [OutputType([bool])] |
2 | 48 |
|
3 | 49 | param( |
4 | | - [string]$HostName = $env:COMPUTERNAME |
| 50 | + [string]$HostName = $env:COMPUTERNAME. |
| 51 | + [switch]$EnableException |
5 | 52 | ) |
6 | 53 |
|
7 | 54 | $osDetails = Get-CimInstance Win32_OperatingSystem -ComputerName $HostName | Select-Object Caption, Description, Name, OSType, Version |
|
0 commit comments