Functions/IEcom/New-IEInstance.ps1
Function New-IEInstance { [CmdletBinding()] Param ( [Parameter(Mandatory=$false)] [switch] $Invisible, [Parameter(Mandatory=$false)] [int] $width = 1936, [Parameter(Mandatory=$false)] [int] $height = 1048 ) while (!$IE) { try {$ie = New-Object -ComObject InternetExplorer.Application -ErrorAction Stop} catch{Remove-IEInstance} } [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds $ie.visible = if ($Invisible){$false}else{$true} $ie.width = $width $ie.Height = $height $ie.FullScreen = $false $ie.Top = 0 $ie.Left = -8 $ie } |