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

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1'
# Version number of this module.
ModuleVersion = '7.2.1'
ModuleVersion = '7.2.2'
# ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede'

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 {

View File

@@ -1,7 +1,11 @@
# v7.2.2
- Improved checks for Linux, Mac and PS 5.1
# v7.2.1
- Improve auto-detection of data on the clipboard
# v7.2.0
- Added `Read-Clipboard` support for Windows. Read text from clipboard. It can read CSV or JSON. Plus, you can specify the delimiter and headers.