22Part of PowerShell module : GenXdev.Webbrowser.Playwright
33Original cmdlet filename : Connect-PlaywrightViaDebuggingPort.ps1
44Original author : René Vaessen / GenXdev
5- Version : 1.288 .2025
5+ Version : 1.290 .2025
66################################################################################
77MIT License
88
@@ -39,15 +39,27 @@ Connects to an existing browser instance via debugging port.
3939Establishes a connection to a running Chromium-based browser instance using the
4040WebSocket debugger URL. Creates a Playwright instance and connects over CDP
4141(Chrome DevTools Protocol). The connected browser instance is stored in a global
42- dictionary for later reference.
42+ dictionary for later reference. Automatically handles consent for
43+ Microsoft.Playwright NuGet package installation.
4344
4445. PARAMETER WsEndpoint
4546The WebSocket URL for connecting to the browser's debugging port. This URL
4647typically follows the format 'ws://hostname:port/devtools/browser/<id>'.
4748
49+ . PARAMETER ForceConsent
50+ Force consent for third-party software installation without prompting.
51+
52+ . PARAMETER ConsentToThirdPartySoftwareInstallation
53+ Provide consent to third-party software installation.
54+
4855. EXAMPLE
4956Connect-PlaywrightViaDebuggingPort `
5057 -WsEndpoint "ws://localhost:9222/devtools/browser/abc123"
58+
59+ . EXAMPLE
60+ Connect-PlaywrightViaDebuggingPort `
61+ -WsEndpoint "ws://localhost:9222/devtools/browser/abc123" `
62+ -ConsentToThirdPartySoftwareInstallation
5163###############################################################################>
5264function Connect-PlaywrightViaDebuggingPort {
5365
@@ -61,15 +73,35 @@ function Connect-PlaywrightViaDebuggingPort {
6173 HelpMessage = ' WebSocket URL for browser debugging connection'
6274 )]
6375 [ValidateNotNullOrEmpty ()]
64- [string ]$WsEndpoint
76+ [string ]$WsEndpoint ,
77+ # #######################################################################
78+ [Parameter (
79+ Mandatory = $false ,
80+ HelpMessage = ' Force consent for third-party software installation'
81+ )]
82+ [switch ]$ForceConsent ,
83+ # #######################################################################
84+ [Parameter (
85+ Mandatory = $false ,
86+ HelpMessage = ' Consent to third-party software installation'
87+ )]
88+ [switch ]$ConsentToThirdPartySoftwareInstallation
6589 # #######################################################################
6690 )
6791
6892 begin {
6993 # log connection attempt for debugging purposes
7094 Microsoft.PowerShell.Utility\Write-Verbose " Attempting to connect to browser at: $WsEndpoint "
7195
72- GenXdev.Helpers\EnsureNuGetAssembly - PackageKey ' Microsoft.Playwright'
96+ # prepare parameters for EnsureNuGetAssembly with embedded consent
97+ $params = GenXdev.Helpers\Copy-IdenticalParamValues `
98+ - BoundParameters $PSBoundParameters `
99+ - FunctionName ' GenXdev.Helpers\EnsureNuGetAssembly' `
100+ - DefaultValues (Microsoft.PowerShell.Utility\Get-Variable - Scope Local - ErrorAction SilentlyContinue)
101+
102+ GenXdev.Helpers\EnsureNuGetAssembly - PackageKey ' Microsoft.Playwright' `
103+ - Description ' Browser automation library required for connecting to browser instances via CDP' `
104+ - Publisher ' Microsoft' @params
73105
74106 $Global :GenXdevPlaywrightBrowserDictionary = $Global :GenXdevPlaywrightBrowserDictionary ?
75107 $Global :GenXdevPlaywrightBrowserDictionary :
0 commit comments