Add-AccountToDockerAccess fails in pwsh 7.0
Opened this issue · 4 comments
When running in pwsh 7.0 the following errors are generated:
InvalidOperation: C:\Users\CpUser\Documents\PowerShell\Modules\dockeraccesshelper\0.0.3\Add-AccountToDockerAccess.psm1:65
Line |
65 | $dSec = $dInfo.GetAccessControl()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Method invocation failed because [System.IO.DirectoryInfo] does not contain a method named
| 'GetAccessControl'.
InvalidOperation: C:\Users\CpUser\Documents\PowerShell\Modules\dockeraccesshelper\0.0.3\Add-AccountToDockerAccess.psm1:67
Line |
67 | $dSec.AddAccessRule($rule)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| You cannot call a method on a null-valued expression.
InvalidOperation: C:\Users\CpUser\Documents\PowerShell\Modules\dockeraccesshelper\0.0.3\Add-AccountToDockerAccess.psm1:68
Line |
68 | $dInfo.SetAccessControl($dSec)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Method invocation failed because [System.IO.DirectoryInfo] does not contain a method named
| 'SetAccessControl'.
My $PSVersionTable:
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Running Add-AccountToDockerAccess
in a powershell session with version 5.1.17763.1007 runs to completion successfully.
Thanks for opening the issue. As PS 7 is using .net Core, I probably need to use different classes and / or methods. Unfortunately, I won't have time for that in the foreseeable future but would keep this issue open as a reminder
I got this same error while using Powershell (Preview) 7.1.3
.
The Solution
Open up the standard Powershell (5.1
or something), and try again. For me, it worked using the regular Powershell.
You should also be able to do this from pwsh:
powershell Install-Module -Name dockeraccesshelper
powershell Add-AccountToDockerAccess $UserName
My Power shell version Table :
> $PSVersionTable
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
as Admin user in powershell 7 i've done it with this command:
> $acl = Get-Acl "\\.\pipe\docker_engine"
> $acl.access
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : AUTORITE NT\Système
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrateurs
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
> $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("<Domain>\<user>","FullControl","Allow")
> $acl.SetAccessRule($rule)
> $acl.Access
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : AUTORITE NT\Système
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrateurs
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : <Domain>\<user>
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
> Set-Acl "\\.\pipe\docker_engine" -AclObject $acl
From <user> powershell i can now use docker command:
PS C:\Users\<user>> docker info
Client:
Context: default
Debug Mode: false
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 20.10.13
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 19044 (19041.1.amd64fre.vb_release.191206-1406)
Operating System: Windows 10 Enterprise Version 2009 (OS Build 19044.2130)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 8GiB
Name: <hostname>
ID: <id>
Docker Root Dir: C:\ProgramData\docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine