Improved checks for Linux, Mac and PS 5.1 - #1056, #1057

This commit is contained in:
dfinke
2021-07-30 19:21:37 -04:00
parent c641eea10a
commit 0192f4d822
3 changed files with 22 additions and 23 deletions

View File

@@ -1,3 +1,4 @@
#Requires -Version 5
function Read-Clipboard {
<#
.SYNOPSIS
@@ -22,30 +23,24 @@ function Read-Clipboard {
$Header
)
if ($IsWindows) {
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
if ($osInfo.ProductType -eq 1) {
$cvtParams = @{
Data = Get-Clipboard -Raw
}
if ($Delimiter) {
$cvtParams.Delimiter = $Delimiter
}
if ($Header) {
$cvtParams.Header = $Header
}
ReadClipboardImpl @cvtParams
}
else {
Write-Error "This command is only supported on the desktop."
}
if ($IsLinux -or $IsMacOS) {
Write-Error "Read-Clipboard only runs on Windows"
return
}
else {
Write-Error "This function is only available on Windows desktop"
$cvtParams = @{
Data = Get-Clipboard -Raw
}
if ($Delimiter) {
$cvtParams.Delimiter = $Delimiter
}
if ($Header) {
$cvtParams.Header = $Header
}
ReadClipboardImpl @cvtParams
}
function ReadClipboardImpl {