Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
When installing and running FixHostFilePermissions.ps1 if there is left empty sid in registry error pops up:
Cannot bind argument to parameter 'Path' because it is an empty string.
However it is not an error but a bug in script.
Bracket which closes if $properties on line 51 should be moved between 56 and 57.
When there is empty properties it should not try to join paths.
Expected behavior
When there is empty properties it should not try to join paths.
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" -ErrorAction SilentlyContinue | % {
$properties = Get-ItemProperty $_.pspath -ErrorAction SilentlyContinue
$userProfilePath = ""
if($properties)
{
$userProfilePath = $properties.ProfileImagePath
$filePath = Join-Path $userProfilePath .ssh\authorized_keys
if(Test-Path $filePath -PathType Leaf)
{
Repair-AuthorizedKeyPermission -FilePath $filePath @psBoundParameters
}
}
}
Actual behavior
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" -ErrorAction SilentlyContinue | % {
$properties = Get-ItemProperty $_.pspath -ErrorAction SilentlyContinue
$userProfilePath = ""
if($properties)
{
$userProfilePath = $properties.ProfileImagePath
}
$filePath = Join-Path $userProfilePath .ssh\authorized_keys
if(Test-Path $filePath -PathType Leaf)
{
Repair-AuthorizedKeyPermission -FilePath $filePath @psBoundParameters
}
}
Error details
Join-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\Program Files\OpenSSH\FixHostFilePermissions.ps1:52 char:27
+ $filePath = Join-Path $userProfilePath .ssh\authorized_keys
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Join
PathCommand
Environment data
Can not do that
Version
on all versions it exist
Visuals
No response