diff --git a/Examples/AddImage/Add-ExcelImage.ps1 b/Examples/AddImage/Add-ExcelImage.ps1 index c3e6d17..38ce80e 100644 --- a/Examples/AddImage/Add-ExcelImage.ps1 +++ b/Examples/AddImage/Add-ExcelImage.ps1 @@ -75,6 +75,10 @@ function Add-ExcelImage { ) begin { + if ($IsWindows -eq $false) { + throw "This only works on Windows and won't run on $([environment]::OSVersion)" + } + <# These ratios work on my machine but it feels fragile. Need to better understand how row and column sizing works in Excel and what the diff --git a/Examples/AddImage/AddImage.ps1 b/Examples/AddImage/AddImage.ps1 index d5e04fe..4d38e09 100644 --- a/Examples/AddImage/AddImage.ps1 +++ b/Examples/AddImage/AddImage.ps1 @@ -1,3 +1,7 @@ +if ($IsWindows -eq $false) { + throw "This only works on Windows and won't run on $([environment]::OSVersion)" +} + Add-Type -AssemblyName System.Drawing . $PSScriptRoot\Add-ExcelImage.ps1 @@ -24,7 +28,8 @@ try { $image = [System.Drawing.Image]::FromFile($octocat) $xlpkg = $data | Export-Excel -Path $path -PassThru $xlpkg.Sheet1 | Add-ExcelImage -Image $image -Row 4 -Column 6 -ResizeCell -} finally { +} +finally { if ($image) { $image.Dispose() }