Closed virain closed 3 years ago
Can you run the following on your Windows host to see what happens?
[System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
Can you run the following on your Windows host to see what happens?
[System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
PS C:\Users\Administrator> [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
\\.\pipe\InitShutdown
\\.\pipe\lsass
\\.\pipe\ntsvcs
\\.\pipe\scerpc
\\.\pipe\Winsock2\CatalogChangeListener-230-0
\\.\pipe\epmapper
\\.\pipe\Winsock2\CatalogChangeListener-170-0
\\.\pipe\LSM_API_service
\\.\pipe\Winsock2\CatalogChangeListener-1d4-0
\\.\pipe\W32TIME_ALT
\\.\pipe\eventlog
\\.\pipe\Winsock2\CatalogChangeListener-374-0
\\.\pipe\atsvc
\\.\pipe\Winsock2\CatalogChangeListener-13c-0
\\.\pipe\wkssvc
\\.\pipe\spoolss
\\.\pipe\Winsock2\CatalogChangeListener-480-0
\\.\pipe\winreg
\\.\pipe\trkwks
\\.\pipe\srvsvc
\\.\pipe\Winsock2\CatalogChangeListener-1cc-0
\\.\pipe\Winsock2\CatalogChangeListener-700-0
\\.\pipe\TermSrv_API_service
\\.\pipe\Ctx_WinStation_API_service
\\.\pipe\SessEnvPublicRpc
\\.\pipe\TSVCPIPE-365ba63a-4648-42c3-9a67-762a0a02f821
An error occurred while enumerating through a collection: Illegal characters in path..
At line:1 char:1
+ [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.IO.FileS...[System.String]:FileSystemEnumerableIterator`1) [],
RuntimeException
+ FullyQualifiedErrorId : BadEnumeration
Interesting it looks like you have a named pipe with an a character that .NET considers as illegal and thus breaks the enumeration. Can you try the following instead and see if it continues to list the pipes from the illegal one?
$WarningAction = 'Continue'
$enumerator = [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*').GetEnumerator()
while ($true) {
try {
$remaining = $enumerator.MoveNext()
}
catch {
Write-Warning -Message "Failed to MoveNext: $($_.Exception.Message)"
continue
}
if (-not $remaining) {
break
}
$enumerator.Current
}
I'm hoping it will display the warning message but also continue on from that particular pipe that's causing the problem.
Interesting it looks like you have a named pipe with an a character that .NET considers as illegal and thus breaks the enumeration. Can you try the following instead and see if it continues to list the pipes from the illegal one?
$WarningAction = 'Continue' $enumerator = [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*').GetEnumerator() while ($true) { try { $remaining = $enumerator.MoveNext() } catch { Write-Warning -Message "Failed to MoveNext: $($_.Exception.Message)" continue } if (-not $remaining) { break } $enumerator.Current }
I'm hoping it will display the warning message but also continue on from that particular pipe that's causing the problem.
I don't understand powershell, and it's like this:
>>
\\.\pipe\InitShutdown
\\.\pipe\lsass
\\.\pipe\ntsvcs
\\.\pipe\scerpc
\\.\pipe\Winsock2\CatalogChangeListener-240-0
\\.\pipe\epmapper
\\.\pipe\Winsock2\CatalogChangeListener-174-0
\\.\pipe\LSM_API_service
\\.\pipe\eventlog
\\.\pipe\Winsock2\CatalogChangeListener-2c8-0
\\.\pipe\atsvc
\\.\pipe\Winsock2\CatalogChangeListener-2ec-0
\\.\pipe\wkssvc
\\.\pipe\spoolss
\\.\pipe\Winsock2\CatalogChangeListener-320-0
\\.\pipe\winreg
\\.\pipe\trkwks
\\.\pipe\srvsvc
\\.\pipe\Winsock2\CatalogChangeListener-1d0-0
\\.\pipe\Winsock2\CatalogChangeListener-69c-0
\\.\pipe\TermSrv_API_service
\\.\pipe\Ctx_WinStation_API_service
\\.\pipe\SessEnvPublicRpc
\\.\pipe\Winsock2\CatalogChangeListener-1d8-0
WARNING: Failed to MoveNext: Exception calling "MoveNext" with "0" argument(s): "Illegal characters in path."
\\.\pipe\TSVCPIPE-75cff16a-de6b-4d25-b63f-5b5fb92c8a4b
\\.\pipe\PSHost.132791731517587602.2148.DefaultAppDomain.powershell
Thanks for running, looks like it will do the trick. Essentially you have a named pipe running on your host that .NET thinks has illegal characters and raises an error. The weird code I shared will manually move through the enumeration and ignore those particular pipes allowing it to find the one required for win_updates
.
The PR https://github.com/ansible-collections/ansible.windows/pull/292 incorporates this change and should fix your issue.
I ended up in similar error
<xxx.xxx.xxx.xxx> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO xxx.xxx.xxx.xxx
EXEC (via pipeline wrapper)
<xxx.xxx.xxx.xxx> PUT "/root/.ansible/tmp/ansible-local-32qfdzd7a7/tmpf2cc_0j4/poll.ps1" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1668521120.6813464-48-227397937674959\poll.ps1"
<xxx.xxx.xxx.xxx> PUT "/root/.ansible/tmp/ansible-local-32qfdzd7a7/tmpqnvbq1x9/cancel.ps1" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1668521120.6813464-48-227397937674959\cancel.ps1"
<xxx.xxx.xxx.xxx> Running win_updates - round 1
<xxx.xxx.xxx.xxx> Starting update task
Using module file /root/.ansible/collections/ansible_collections/ansible/windows/plugins/modules/win_updates.ps1
Pipelining is enabled.
EXEC (via pipeline wrapper)
EXEC (via pipeline wrapper)
TASK [Pre Check for Security Updates] ******************************************
task path: /builds/SRE/ansible/app11755/test/windows-updates/playbook.yml:37
The full traceback is:
Task failed to connect to pipe
At line:483 char:13
+ throw "Task failed to connect to pipe"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Task failed to connect to pipe:String) [], RuntimeException
+ FullyQualifiedErrorId : Task failed to connect to pipe
ScriptStackTrace:
at Invoke-AsBatchLogon, <No file>: line 483
at <ScriptBlock>, <No file>: line 1600
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {
"changed": false,
"failed_update_count": 0,
"filtered_updates": {},
"found_update_count": 0,
"installed_update_count": 0,
"invocation": {
"module_args": {
"accept_list": null,
"category_names": [
"SecurityUpdates"
],
"log_path": null,
"reboot": false,
"reboot_timeout": 1200,
"reject_list": null,
"server_selection": "default",
"skip_optional": false,
"state": "searched",
"use_scheduled_task": false
}
},
"msg": "Failed to invoke batch script: Task failed to connect to pipe",
"updates": {}
}
Output of command [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
PS C:\Users\btsre> [System.IO.Directory]::EnumerateFiles('\\.\pipe\', '*')
\\.\pipe\InitShutdown
\\.\pipe\lsass
\\.\pipe\ntsvcs
\\.\pipe\scerpc
\\.\pipe\Winsock2\CatalogChangeListener-70-0
\\.\pipe\epmapper
\\.\pipe\Winsock2\CatalogChangeListener-2f0-0
\\.\pipe\LSM_API_service
\\.\pipe\eventlog
\\.\pipe\Winsock2\CatalogChangeListener-458-0
\\.\pipe\atsvc
\\.\pipe\Winsock2\CatalogChangeListener-224-0
\\.\pipe\TermSrv_API_service
\\.\pipe\Ctx_WinStation_API_service
\\.\pipe\wkssvc
\\.\pipe\SessEnvPublicRpc
\\.\pipe\Winsock2\CatalogChangeListener-36c-0
\\.\pipe\trkwks
\\.\pipe\W32TIME_ALT
\\.\pipe\yvWQhjcwCqul5ChEPaGfdNYivsaiJzpIelDcwC5k2olNv6f8YmS9NXGb0HCBLaeILnMNUUrctQG9yyiDGCBpFEeUL1O0WlrW38woHs5lHJGbxTrJfJKzJJ
\\.\pipe\srvsvc
\\.\pipe\Winsock2\CatalogChangeListener-a58-0
\\.\pipe\CrowdStrike\{1A9F1ABA-7AAE-4276-88AA-40AAAD0F53BF}
\\.\pipe\Winsock2\CatalogChangeListener-944-0
\\.\pipe\vgauth-service
\\.\pipe\cygwin-7d2b541f81e048bd-4144-sigwait
\\.\pipe\cygwin-7d2b541f81e048bd-4268-sigwait
\\.\pipe\iislogpipe8ec0ae95-b356-477a-a7c9-24a0e96ff9d8
\\.\pipe\6ea2cc9a-e59f-43ce-b43b-7b00ba0b3602
\\.\pipe\Winsock2\CatalogChangeListener-344-0
\\.\pipe\CrowdStrike\{2C9EE953-4BF4-4B98-8234-2527445B0CC2}
\\.\pipe\boost_process_auto_pipe_10252_0
\\.\pipe\boost_process_auto_pipe_10252_1
\\.\pipe\boost_process_auto_pipe_10252_2
\\.\pipe\boost_process_auto_pipe_10252_3
\\.\pipe\discovery_entry_point1
\\.\pipe\discovery_entry_point2
\\.\pipe\discovery_entry_point3
\\.\pipe\discovery_entry_point4
\\.\pipe\discovery_entry_point5
\\.\pipe\discovery_entry_point
\\.\pipe\boost_process_auto_pipe_10252_8
\\.\pipe\boost_process_auto_pipe_10252_9
\\.\pipe\wbhstipmb68f7d10-67fb-4a8d-88b6-c48f8ddf40a9
\\.\pipe\wbhstipme928ffc8-87bd-4722-a3b5-5cfe09f368c4
\\.\pipe\wbhstipm96b3e8b1-954d-4d52-bbb5-810cb6e60edb
\\.\pipe\wbhstipme1dba238-e340-4e52-b45a-0e796f8b97a3
\\.\pipe\816864ee-6111-47c3-8575-ec54c31cb3b4
\\.\pipe\01378e9e-88fb-4bce-9b7c-b979f3101c97
\\.\pipe\0e902fd0-7e34-4118-8b1b-d08650285748
\\.\pipe\c8e3b4f7-d728-4407-863b-c8527b0404b6
\\.\pipe\dff7255e-d515-4af0-afcf-7c73af3c40c8
\\.\pipe\iisipm390dfea9-1483-4463-8e38-e18e5be8d46c
\\.\pipe\iislogpipe4e84ad2c-3c86-4a97-b1ab-020ef07383de
\\.\pipe\p1QFQCa2AgTi807CvTm4GcmWxzUvEZAT1myfUAgBObK5bmuuoLFrAT7A9HyT6hJmoG0HsibVcMe2JuUkmGlqlQYHq3XxYyq4P4Dt2AWyUlUCKWCMnlx1lv
\\.\pipe\CPFATP_12724_v4.0.30319
\\.\pipe\TSVCPIPE-c85f3ec1-9f1e-4bf8-a475-c29499d34133
\\.\pipe\TSVCPIPE-86eae252-4b5b-4004-854b-0d6b5b0037bc
\\.\pipe\TSVCPIPE-dddb320f-07b6-4263-a357-4788f71ccc9e
\\.\pipe\TSVCPIPE-128566ba-4310-4227-b962-85d4b43db99c
\\.\pipe\TSVCPIPE-0b1f8db5-0962-41c1-ab97-a4d459a63af8
\\.\pipe\TSVCPIPE-fe16860e-1ecb-43a1-b027-ce27300a8861
\\.\pipe\TDLN-4348-41
\\.\pipe\TDLN-11460-41
\\.\pipe\PSHost.133130127963183968.2100.DefaultAppDomain.powershell
PS C:\Users\btsre>
Versions ansible-playbook [core 2.12.6] ansible.windows:1.12.0 Target: windows Server 2016 Datacentre
Summary
PowerShell 5.1 on Windows 2012
Issue Type
Bug Report
Component Name
pip
Ansible Version
OS / Environment
target OS versions:Windows2012R2
Steps to Reproduce
Expected Results
It should have been successful because I had no problem executing in Windows 2012 R2 and PowerShell 4.0
Actual Results