Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prerelease] trying to access registry on a non-Windows machine #5617

Closed
nvarscar opened this issue May 27, 2019 · 4 comments · Fixed by #5663
Closed

[Prerelease] trying to access registry on a non-Windows machine #5617

nvarscar opened this issue May 27, 2019 · 4 comments · Fixed by #5663

Comments

@nvarscar
Copy link
Contributor

Environmental information

#### PowerShell version:

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Darwin 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

#### dbatools Module version:

Name    : dbatools
Path    : /Users/kkravtsov/.local/share/powershell/Modules/dbatools/0.9.822/dbatools.psd1
Version : 0.9.822

Report

Module tries to access registry on my Mac upon Import:

Import-Module ./dbatools.psd1
Get-ItemProperty : Cannot find drive. A drive with the name 'HKLM' does not exist.
At /Users/kkravtsov/git/dbatools/internal/scripts/smoLibraryImport.ps1:131 char:6
+ if ((Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\ND ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (HKLM:String) [Get-ItemProperty], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand

Errors Received


writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Management.Automation.DriveNotFoundException: Cannot find drive. A drive with the name 'HKLM' does not exist.
                           at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
                           at System.Management.Automation.SessionStateInternal.AutomountBuiltInDrive(String name)
                           at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
                           at System.Management.Automation.SessionStateInternal.GetDrive(String name)
                           at System.Management.Automation.DriveManagementIntrinsics.Get(String driveName)
                           at System.Management.Automation.LocationGlobber.GetDriveRootRelativePathFromPSPath(String path, CmdletProviderContext context, Boolean escapeCurrentLocation, PSDriveInfo& workingDriveForPath, CmdletProvider& providerInstance)
                           at System.Management.Automation.LocationGlobber.GetProviderPath(String path, CmdletProviderContext context, Boolean isTrusted, ProviderInfo& provider, PSDriveInfo& drive)
                           at System.Management.Automation.LocationGlobber.GetProviderPath(String path, CmdletProviderContext context, ProviderInfo& provider, PSDriveInfo& drive)
                           at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, ProviderInfo& provider, CmdletProvider& providerInstance)
                           at System.Management.Automation.SessionStateInternal.GetProperty(String[] paths, Collection`1 providerSpecificPickList, CmdletProviderContext context)
                           at System.Management.Automation.PropertyCmdletProviderIntrinsics.Get(String path, Collection`1 providerSpecificPickList, CmdletProviderContext context)
                           at Microsoft.PowerShell.Commands.GetItemPropertyCommand.ProcessRecord()
TargetObject          : HKLM
CategoryInfo          : ObjectNotFound: (HKLM:String) [Get-ItemProperty], DriveNotFoundException
FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, /Users/kkravtsov/git/dbatools/internal/scripts/smoLibraryImport.ps1: line 131
                        at <ScriptBlock>, /Users/kkravtsov/git/dbatools/dbatools.psm1: line 200
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

Steps to Reproduce

Expected Behavior

no errors

Actual Behavior

errors :|

@potatoqualitee
Copy link
Member

thank u

@wsmelton
Copy link
Member

wsmelton commented May 28, 2019

Notes...

NET Core on Linux can be checked in various methods that I have found. I think dotnet --list-runtimes will be something we need to do in order to validate it is installed on the hosted machine if we need to validate it is there.

When dealing with Mac OS it varies, found an issue on core repo here:

/usr/local/share/dotnet/dotnet --info

SO question notes following: https://stackoverflow.com/a/42309484

On macOS you could check .net core version by using below command.

ls /usr/local/share/dotnet/shared/Microsoft.NETCore.App/
On Ubuntu or Alpine:

ls /usr/share/dotnet/shared/Microsoft.NETCore.App/
It will list down the folder with installed version name.

@potatoqualitee
Copy link
Member

thank you 🙇

@potatoqualitee
Copy link
Member

@wsmelton - can you take a stab at this? I have to work on my PSConf Presentation and write Chapter 8 in the next few days and won't be available much until June 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants